Output aws_iam_access_key not working

1,647 views
Skip to first unread message

jwr

unread,
May 12, 2017, 5:26:27 PM5/12/17
to Terraform
I deployed (via terraform) an IAM user and associated access key, but my attempt at getting the secret key to output is giving me "The state file either has no outputs defined, or all the defined
outputs are empty." The deploy was successful and I can see my keys in the AWS console. What am I doing wrong with the secret key output?

resource "aws_iam_user" "jwr" {
  name = "jwr"
}

resource "aws_iam_access_key" "jwr" {
  user = "${aws_iam_user.jwr.name}"
}

output "secret" {
  value = "${aws_iam_access_key.jwr.encrypted_secret}"
}


$ terraform output

The state file either has no outputs defined, or all the defined
outputs are empty. Please define an output in your configuration
with the `output` keyword and run `terraform refresh` for it to
become available. If you are using interpolation, please verify
the interpolated value is not empty. You can use the 
`terraform console` command to assist.

$ terraform -v
Terraform v0.9.5

Andrew Langhorn

unread,
May 13, 2017, 8:16:49 AM5/13/17
to terrafo...@googlegroups.com
Have you tried passing a value for pgp_key? Encrypting the secret key occurs using PGP, and Terraform needs either a key in-lined or a Keybase username, to work out the key to use.

This might be it's way of failing hard because there is no available key. It should probably fail more gracefully, if so, but worth a check of this theory first.

Ken E

unread,
Jun 1, 2018, 2:18:47 PM6/1/18
to Terraform
I am actually having this same issue.

Can anyone shed more light in this topic? 

Sean Johnson

unread,
Jun 1, 2018, 3:56:33 PM6/1/18
to terrafo...@googlegroups.com
You need to use the aws_iam_user_login_profile ( https://www.terraform.io/docs/providers/aws/r/iam_user_login_profile.html ) resource to generate the encrypted password. 

I’ve used this successfully using the “keybase:user” syntax. 
-- 
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/14aee756-9b61-41b9-aef1-27db384d6f93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

signature.asc

Henry Franco

unread,
Nov 13, 2018, 4:46:35 PM11/13/18
to Terraform
Sean, I think they're discussing retrieving the secret key and not the user password.
Reply all
Reply to author
Forward
0 new messages