Invalid AWS Code Artifact Policy Permission

Viewed 3030

Am not able to assign a policy to a repository which I created in AWS code artifact.

I am getting an error message Policy document isn't a valid policy document

Please help me in where i am going wrong.

Domain name = avc
Repo name = code-repo-maven-SNAPSHOT

{
   "Version":"2012-10-17",
   "Statement":[
      {
         "Action":[
            "codeartifact:*"
         ],
         "Effect":"Allow",
         "Resource":"arn:aws:codeartifact:us-east-1:130000006255:repository/avc/code-repo-maven-SNAPSHOT"
      },
      {
         "Effect":"Allow",
         "Action":"sts:GetServiceBearerToken",
         "Resource":"*",
         "Condition":{
            "StringEquals":{
               "sts:AWSServiceName":"codeartifact.amazonaws.com"
            }
         }
      }
   ]
}```
1 Answers

Repository policy is resource based policy. It means it should have Principal. For more info

    {
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::130000006255:root"
            },
            "Action": "codeartifact:*",
            "Resource": "arn:aws:codeartifact:us-east-1:130000006255:repository/avc/code-repo-maven-SNAPSHOT"
        }
    ]
}
Related