CmdID

CmdID / aws / aws ecr

aws ecr set-repository-policy

Applies a repository policy to the specified repository to control access permissions. AWS CLI reference

1 example 4 options Its page in the AWS CLI reference

Opens CmdID with your command. It is read in your browser and sent nowhere.

Examples

from aws-cli, each command read by CmdID

To set the repository policy for a repository

The following set-repository-policy example attaches a repository policy contained in a file to the cluster-autoscaler repository.

aws ecr set-repository-policy --repository-name cluster-autoscaler --policy-text file://my-policy.jsonIdentify
--repository-nameThe name of the repository to receive the policy.
--policy-textThe JSON repository policy text to apply to the repository.

Contents of my-policy.json:

{
    "Version" : "2008-10-17",
    "Statement" : [
        {
            "Sid" : "allow public pull",
            "Effect" : "Allow",
            "Principal" : "*",
            "Action" : [
                "ecr:BatchCheckLayerAvailability",
                "ecr:BatchGetImage",
                "ecr:GetDownloadUrlForLayer"
            ]
        }
    ]
}
Its output
{
    "registryId": "123456789012",
    "repositoryName": "cluster-autoscaler",
    "policyText": "{\n  \"Version\" : \"2008-10-17\",\n  \"Statement\" : [ {\n    \"Sid\" : \"allow public pull\",\n    \"Effect\" : \"Allow\",\n    \"Principal\" : \"*\",\n    \"Action\" : [ \"ecr:BatchCheckLayerAvailability\", \"ecr:BatchGetImage\", \"ecr:GetDownloadUrlForLayer\" ]\n  } ]\n}"
}

For more information, see Setting a private repository policy statement in Amazon ECR in the Amazon ECR User Guide.

Options

4 in the AWS CLI reference
--forceIf the policy you are attempting to set on a repository policy would prevent you from setting another policy in the future, you must force the SetRepositoryPolicy operation.
--policy-textThe JSON repository policy text to apply to the repository.
--registry-idThe Amazon Web Services account ID associated with the registry that contains the repository.
--repository-nameThe name of the repository to receive the policy.