To make Terraform to read the AWS credential file, you can follow these steps:
1. Create an AWS credential file:
On a Linux or macOS system, create the file at ~/.aws/credentials.
On a Windows system, create the file at C:\Users\USERNAME\.aws\credentials.
In the file, add the following lines, replacing the ACCESS_KEY and SECRET_KEY with your AWS access key and secret key:
2. Set the AWS_REGION environment variable to the region you want to use. You can do this by running the following command in your terminal:
3. In your Terraform configuration file, add the following code to read the AWS credentials from the file:
This assumes that the credential file is located at /Users/USERNAME/.aws/credentials. If you have placed the file in a different location, replace the file path accordingly.
Note that the profile parameter in the provider block corresponds to the section name in the AWS credential file. In the example above, the section name is [default].
Once you have completed these steps, Terraform should be able to read your AWS credentials from the credential file and use them to authenticate with AWS.