AWS provider InvalidClientTokenId: The security token included in the request is invalid

3,556 views
Skip to first unread message

devula...@gmail.com

unread,
May 10, 2018, 3:56:25 PM5/10/18
to Terraform
Hello ,
I'm using Terraform v0.11.7  and  provider.aws v1.17.0  . I'm beginner to terraform  and getting below error when I run terraform apply to get start creating AWS ELB.




$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.


------------------------------------------------------------------------

Error: Error running plan: 1 error(s) occurred:

* provider.aws: InvalidClientTokenId: The security token included in the request is invalid.
        status code: 403, request id: 65627ef4-5484-11e8-87e3-b587dd3eb36c





terraform {
required_version = ">=v0.11.7"
/*
backend "s3" {

}
*/
}

#aws provider & access details
provider "aws" {
version = "v1.17.0"
region = "${var.aws_region}"
access_key = "XXXX" //"${var.aws_access_key}"
secret_key = "XXXX" //"${var.aws_secret_key}"
profile = ""
}

// create load balancer
resource "aws_elb" "testt" {

name = "XX-test-elb"

security_groups = [
"sg-XX"]

subnets = [
"subnet-XXX",
"subnet-XX",
"subnet-XX"]

internal = true
cross_zone_load_balancing = false

listener {
instance_port = 80
instance_protocol = "http"
lb_port = 80
lb_protocol = "http"
}
tags {
Environment = "test"
Department = "XX"
}


Please do help me 

Thanks
Upendar

laxman Singh Rathore

unread,
May 10, 2018, 4:05:26 PM5/10/18
to terrafo...@googlegroups.com
Hi,

Are you using default profile with terraform apply. I noticed in your   main.tf profile parameter is empty. Substitute approriate profile name for aws profile.



--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/b63552cb-72e1-4f84-a5a8-e0d65b388b9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

upendar devu

unread,
May 10, 2018, 4:07:03 PM5/10/18
to terrafo...@googlegroups.com
could you please share an example for aws profile . Thanks

To unsubscribe from this group and stop receiving emails from it, send an email to terraform-tool+unsubscribe@googlegroups.com.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/CACDNCvbiNxTJANxCos4MvUfETRfEK5PbnPtkOXhFZK_iZErg%2Bw%40mail.gmail.com.

upendar devu

unread,
May 10, 2018, 4:49:36 PM5/10/18
to terrafo...@googlegroups.com
I'm getting same error even after I updated the profile with right value also tried removing profile completely. 

On Thu, May 10, 2018 at 4:05 PM, laxman Singh Rathore <laxman...@gmail.com> wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-tool+unsubscribe@googlegroups.com.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/CACDNCvbiNxTJANxCos4MvUfETRfEK5PbnPtkOXhFZK_iZErg%2Bw%40mail.gmail.com.

upendar devu

unread,
May 10, 2018, 5:13:42 PM5/10/18
to terrafo...@googlegroups.com
Issue resolved after adding token in terraform for aws session token 

token - (Optional) Use this to set an MFA token. It can also be sourced from the AWS_SESSION_TOKEN environment variable.

below are required for aws provider - thats all 
aws provider & access details
provider "aws" {
version = "v1.17.0"
region = "${var.aws_region}"
  access_key = "XXX" //"${var.aws_access_key}"
secret_key = "XX" //"${var.aws_secret_key}"
token = "XXX"
//profile = "arn:aws:iam::711618289438:instance-profile/instance-npp-infrastructure"
}



On Thu, May 10, 2018 at 4:05 PM, laxman Singh Rathore <laxman...@gmail.com> wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-tool+unsubscribe@googlegroups.com.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/CACDNCvbiNxTJANxCos4MvUfETRfEK5PbnPtkOXhFZK_iZErg%2Bw%40mail.gmail.com.

laxman Singh Rathore

unread,
May 10, 2018, 5:29:04 PM5/10/18
to terrafo...@googlegroups.com
provider “aws” {
region = “ap-southeast-2”
shared_credentials_file = “${pathexpand(“~/.aws/credentials”)}”
}

Hi configure your credential file with your provider.

To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/CACkLabjbd9sXFmF9Gk42gCNiavw5t9Qf2YJ9tRCboBfBAMPLgw%40mail.gmail.com.

Nicholas Seniura

unread,
Jul 25, 2018, 3:49:45 PM7/25/18
to Terraform
It might be a little late, but I found that when I had the same issue it was because I did not run the terraform apply command using sudo.
Once I su - the command functioned normally.  I believe it was that my normal user does not have read to the actual token, which I discovered while attempting to run aws configure to set my default region so I could see if I was able to describe the ec2 instances.

V/R

Nick
Reply all
Reply to author
Forward
0 new messages