- Create a user
terraform
by navigating Login to AWS -> IAM -> Users -> Add User
- Create a group
terraform-administrators
- Review screen
-
Download the
credentials.csv
containingAccess key ID
andSecret access key
-
These values can be used in the following ways
-
Export the values of
Access key ID
andSecret access key
as showing below in your current shell.export AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY_ID export AWS_SECRET_ACCESS_KEY=YOUR_SECRET_ACCESS_KEY
- Now you can run the
terrform
commands in the same shell session.
- Now you can run the
-
Add these values to the file
terraform.tfvars
in project directory DEFINATELY ADD IT TO.gitignore
file. NEVER NEVER NEVER committerraform.tfvars
this file to git repository (as it contains you access key id and secret access key)$ cat terraform.tfvars AWS_ACCESS_KEY = "YOUR_ACCESS_KEY_ID" AWS_SECRET_KEY = "YOUR_SECRET_ACCESS_KEY"
- Now while running
terraform
commands you will have to pass this file as argument at the end like shown below
$ terraform apply -var-file=../../terraform.tfvars
- Now while running
-
$ aws configure
AWS Access Key ID [None]: **********************
AWS Secret Access Key [None]: ************************
Default region name [None]: us-east-1
Default output format [None]: