title: Access Denied when calling the CreateInvalidation operation on AWS CLI
body: <p>I am attempting to create a command that will invalidate CloudFront distribution when pushing out new code. This is an attempt to fix the issue that new HTML pushed out doesn't take up to 24 hours to appear on my web app. The idea comes from this <a href="http://docs.aws.amazon.com/cli/latest/reference/cloudfront/create-invalidation.html" rel="nofollow noreferrer">AWS CLI COMMAND REFERENCE</a></p>
  
  <p>Here is the command:</p>
  
  <p>aws cloudfront create-invalidation --distribution-id XXXXXXXXXXXXXX --invalidation-batch file://invbatch.json</p>
  
  <p>Here is the response I get when I run the command:</p>
  
  <p>A client error (AccessDenied) occurred when calling the CreateInvalidation operation: User: arn:aws:iam::XXXXXXXXXXXXXX:user/cats-kittens-beanstalk-user is not authorized to perform: cloudfront:CreateInvalidation</p>
  
  <p>Any idea why this might be? I know AWS throws this access denied even though the user is authorized to run commands in some instances - see <a href="https://serverfault.com/questions/673467/access-denied-copying-files-using-s3-cli">here</a>.</p>