- An AWS account and a user with permission to create IAM users and access keys.
- Terraform installed locally.
- (Optional) AWS CLI installed for managed credential storage.
- Open the AWS Management Console

- Navigate to IAM

- Create a new IAM user for Terraform
- Click “Users” in the left navigation, then “Create user”.
- Give the user a name (for example,
terraform) — you can choose any naming convention you prefer. - Enable programmatic access so AWS generates an access key ID and secret access key for the user.

- Attach permissions (least privilege recommended)

AdministratorAccess only if you truly need full administrative scope). Limiting permissions to what Terraform requires is a best practice.


- Create an access key for programmatic access


- Example Terraform configuration
main.tf) in your working directory before running terraform plan:
By default the empty
provider "aws" {} block lets Terraform pick up credentials and the region from environment variables or the AWS shared credentials file. To set a region explicitly, add region = "us-east-1" inside the provider block (or configure required_providers if your Terraform workflow requires it).- Configure AWS credentials for Terraform
If you use the AWS CLI, run:
aws configure— then enter Access Key ID, Secret Access Key, default region, and output format when prompted.
- Verify Terraform and credentials
.tf files in the working directory, run Terraform commands:
terraform initto initialize providers.terraform planto see what Terraform intends to create.
terraform plan with no configuration files you will see the familiar message:
- Use the principle of least privilege when attaching IAM policies.
- Prefer short-lived credentials or managed profiles when possible.
- Rotate or delete access keys when they are no longer required.
After you finish using these credentials, delete the access key in the IAM console (or rotate it). Treat access keys like passwords and follow the principle of least privilege.
export on macOS/Linux, $Env: for Windows PowerShell, or the AWS CLI aws configure command for persistent credentials.