amazon web services - How do I configure AWS MFA for Terraform? -


i want perform mfa terraform it's expected ask 6-digit token virtual mfa device every terraform [command]. after reading documentation: cli-roles terraform mfa created role:

{   "version": "2012-10-17",   "statement": [     {       "effect": "allow",       "principal": {         "aws": "arn:aws:iam::[account_id]:user/testuser"       },       "action": "sts:assumerole",       "condition": {         "bool": {           "aws:multifactorauthpresent": "true"         }       }     }   ] } 

this user forced use mfa default , have configured virtual mfa device him.

~/.aws/credentials:

[default] ...  [terraform_role] role_arn = arn:aws:iam::[account_id]:role/terraform-test-role source_profile = default mfa_serial = arn:aws:iam::[account_id]:mfa/testuser 

in terraform environment placed following:

provider "aws" {   profile = "terraform_role" } 

but when run terraform plan throws me error:

error refreshing state: 1 error(s) occurred:  * provider.aws: no valid credential sources found aws provider.   please see https://terraform.io/docs/providers/aws/index.html more information on   providing credentials aws provider 

the solution specify assume_role statement:

provider "aws" {   profile = "default"   assume_role {     role_arn = "arn:aws:iam::[account_id]:role/terraform-test-role"   } } 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -