Error finding AWS credentials (did you set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables?)

Hi All,

We use Terraform to manage AWS infrastructure. when I run the terraform locally it seems fine and no issues in deploying infrastructure but it errors out while deploying through Jenkins as no AWS creds were found and it only happens to some of the folders rest all other services in other folders deploy successfully. it was working fine till a week ago but all of a sudden there is an issue. Not sure what went wrong any suggestions pls?

Note: 95% of infrastructure gets deployed and it errors out for few folders as couldn’t find aws creds

Exact Errors

time=2023-09-22T11:41:56Z level=error msg=Module /home/ec2-user/workspace/CI-CD Infrastructure/nft/service-discovery-services has finished with an error: Error finding AWS credentials (did you set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables?): NoCredentialProviders: no valid providers in chain. Deprecated.
	For verbose messaging see aws.Config.CredentialsChainVerboseErrors prefix=[/home/ec2-user/workspace/CI-CD Infrastructure/nft/service-discovery-services] 
time=2023-09-22T11:41:59Z level=error msg=Module /home/ec2-user/workspace/CI-CD Infrastructure/nft/rds-config-null-resource has finished with an error: Error finding AWS credentials (did you set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables?): NoCredentialProviders: no valid providers in chain. Deprecated.
	For verbose messaging see aws.Config.CredentialsChainVerboseErrors prefix=[/home/ec2-user/workspace/CI-CD Infrastructure/nft/rds-config-null-resource] 
time=2023-09-22T11:42:03Z level=error msg=Module /home/ec2-user/workspace/CI-CD Infrastructure/nft/rds-config-null-resource has finished with an error: Error finding AWS credentials (did you set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables?): NoCredentialProviders: no valid providers in chain. Deprecated.

Versions

  • Terraform version:v1.0.7

Any suggestions please?

Hi,

I am also getting the similar error but with different sort of setup. We are using Terragrunt and Terraform to create infrastructure and using IAM Assume role to assume target account IAM Role. And we have recently started using latest Amazon Linux 2023 EC2 machines for execution of Terragrunt/Terraform scripts. And strange thing it’s still working on old Amazon Linux 2018 EC2 machines successfully. :smiling_face_with_tear:

Terraform version - 0.11.15

Error -
Error finding AWS credentials (did you set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables?): NoCredentialProviders: no valid providers in chain. Deprecated.
For verbose messaging see aws.Config.CredentialsChainVerboseErrors

Hey Shubham,

Have you tried increasing EC2 instance size probably more RAM and memory ? If not i would recommend trying this.

Thanks

Ok, Let me try this also. Thanks for quick revert. :+1:

Able to fix issue at your end ?

Hey skkc2,

More RAM and memory doesn’t help to fix issue on my machine. But I have tried Amazon Linux 2022 which is working fine. Trying some insights from AWS Support now, will update if i get some solution on Amazon Linux 2023.

Thanks,
Shubham