HEX
Server: LiteSpeed
System: Linux s3604.bom1.stableserver.net 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
User: dmstechonline (1480)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/awscli/examples/ecr/set-repository-policy.rst
**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.json
  
Contents of ``my-policy.json``::

    {
        "Version" : "2008-10-17",
        "Statement" : [ 
            {
                "Sid" : "allow public pull",
                "Effect" : "Allow",
                "Principal" : "*",
                "Action" : [
                    "ecr:BatchCheckLayerAvailability",
                    "ecr:BatchGetImage",
                    "ecr:GetDownloadUrlForLayer" 
                ]
            }
        ]
    }
  
Output::

    {
        "registryId": "012345678910",
        "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}"
    }