The cloudfront invalidation dont work
Asked by Felipe Micheletto:

I set up all variables required but i receive this error  

ERROR: Error creating a cloudfront invalidation  
? Failed to create a cloudfront invalidation: Unable to locate credentials  

I set up, AWS_SECRET_KEY, AWS_ACCESS_KEY_ID, DISTRIBUTION_ID and REGION, and received credential error


Answers:
author: Igor Stoyanov
body: [@Felipe Micheletto](/t5/user/viewprofilepage/user-id/5107292) hi. Thanks for your question.

We need more information. Please, provide us your config details, and a screenshot of your repository variables (values should be hidden).

Alternative way to is to configure some test script in pipeline to check your aws configuration:

```
script:
  - curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-2.2.9.zip" -o "awscliv2.zip" && unzip awscliv2.zip
  - echo 'c778f4cc55877833679fdd4ae9c94c07d0ac3794d0193da3f18cb14713af615f awscliv2.zip' | sha256sum -c - && ./aws/install
  - aws configure list
```

according to [this guide.](https://repost.aws/knowledge-center/s3-locate-credentials-error)

Regards, Igor

comments: author: Felipe Micheletto
body: ![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/231892iA706C61AF56627E2/image-size/large?v=v2&px=999 "image.png")![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/231893i62E633D14A7D3689/image-size/large?v=v2&px=999 "image.png")


author: Felipe Micheletto
body: The S3 deploy steps works fine, and use the same variables as the cloudfront


author: Igor Stoyanov
body: [@Felipe Micheletto](/t5/user/viewprofilepage/user-id/5107292) just for tests. Set up in cloudfront pipe config aws region like in your s3 pipe config.

```
AWS_DEFAULT_REGION: "us-east-1"
```


author: Igor Stoyanov
body: Also try to run cloudfront via aws cli from your local machine (without using pipe, with using the same creds) to understand where the problem exactly is.


author: Felipe Micheletto
body: i alredy tried setting the egion like the s3, but dont work, i will try via cli


author: Felipe Micheletto
body: [@Igor Stoyanov](/t5/user/viewprofilepage/user-id/4550492) via cli works, i used the same credentials from the pipeline


author: Igor Stoyanov
body: [@Felipe Micheletto](/t5/user/viewprofilepage/user-id/5107292) Try to delete/add_again DISTRIBUTION_ID in the repository variables. Check in the logs this line:  
\`\`\`Distibution URL: <https://console.aws.amazon.com/cloudfront/home?region={region}#distribution-settings:{distribution_id>}\`\`\` -- is this the correct link?

<br />

If this will not help, try to call cli command inside pipeline without using pipe.   
How to install aws cli in pipeline:

```
script:
  - curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-2.2.9.zip" -o "awscliv2.zip" && unzip awscliv2.zip
  - echo 'c778f4cc55877833679fdd4ae9c94c07d0ac3794d0193da3f18cb14713af615f awscliv2.zip' | sha256sum -c - && ./aws/install
  - aws <run your command>
```

Also please provide full log output (hide secret data) with DEBUG variable when using pipe to help us understand where is the problem


author: Felipe Micheletto
body: I Found my problem, i was using deployment variables were is not set to use, i added my variables as repository variables and everything works now! Thanks [@Igor Stoyanov](/t5/user/viewprofilepage/user-id/4550492)


Tags: aws

bitbucket-cloud

cloud

cloudfront