title: Unable to Create Policy for AWS ECR
body: <pre class="lang-json prettyprint-override"><code>{
      &quot;Version&quot;: &quot;2012-10-17&quot;,
      &quot;Statement&quot;: [
          {
              &quot;Sid&quot;: &quot;AllowPushPull&quot;,
              &quot;Effect&quot;: &quot;Allow&quot;,
              &quot;Principal&quot;: {
                  &quot;AWS&quot;: &quot;arn:aws:iam::&lt;account_id&gt;:user/root&quot;
              },
              &quot;Action&quot;: [
                  &quot;ecr:BatchGetImage&quot;,
                  &quot;ecr:BatchCheckLayerAvailability&quot;,
                  &quot;ecr:CompleteLayerUpload&quot;,
                  &quot;ecr:GetDownloadUrlForLayer&quot;,
                  &quot;ecr:InitiateLayerUpload&quot;,
                  &quot;ecr:PutImage&quot;,
                  &quot;ecr:UploadLayerPart&quot;
              ],
              &quot;Resource&quot;: [
                  &quot;xxx.dkr.ecr.us-west-2.amazonaws.com/yyy&quot;
              ]
          }
      ]
  }
  </code></pre>
  <p>Command I try to use is:</p>
  <pre><code>aws ecr set-repository-policy --repository-name yyy --policy-text file://ecr-policy.json
  </code></pre>
  <p>If I do <code>ls</code> in my linux machine I can see this <code>ecr-policy.json</code> in same folder where I run this command.</p>
  <p>I want to grant access to myself.</p>
  <p>I am always getting error:</p>
  <blockquote>
  <p>An error occurred (InvalidParameterException) when calling the SetRepositoryPolicy operation: Invalid parameter at 'PolicyText' failed to satisfy constraint: 'Invalid repository policy provided'</p>
  </blockquote>
  <p>I checked my AWS ARN and it ends with <code>root</code>.</p>