Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource 'aws_iam_access_key.k' not found for variable 'aws_iam_access_key.k.encrypted_secret' #2350

Closed
jamesgoodhouse opened this issue Nov 17, 2017 · 8 comments
Labels
bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement.

Comments

@jamesgoodhouse
Copy link

jamesgoodhouse commented Nov 17, 2017

Terraform Version

0.11.0

Affected Resource(s)

Please list the resources as a list, for example:

  • aws_iam_access_key

Terraform Configuration Files

variable "create_user" { }
variable "public_key" { }

resource "aws_iam_user" "u" {
  count = "${var.create_user}"
  name  = "user_name"
  path  = "/"
}

resource "aws_iam_access_key" "k" {
  count   = "${var.create_user}"
  user    = "${aws_iam_user.u.name}"
  pgp_key = "${var.public_key}"
}

output "okta_user_encrypted_secret" {
  value = "${aws_iam_access_key.k.encrypted_secret}"
}

Expected Behavior

terraform plan should not error, as it worked fine with 0.10.8.

Actual Behavior

The error output.okta_user_encrypted_secret: Resource 'aws_iam_access_key.k' not found for variable 'aws_iam_access_key.k.encrypted_secret' happens.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. upgrade to terraform 0.11.0
  2. terraform plan
@atsushi-ishibashi
Copy link
Contributor

You use count param so maybe need to refer with index like "${aws_iam_access_key.k.0.encrypted_secret}" ?

resource "aws_iam_access_key" "k" {
  count   = "${var.create_user}"

@jamesgoodhouse
Copy link
Author

Did something change in 0.11.0 with the count attribute, as all works fine with 0.10.8.

@atsushi-ishibashi
Copy link
Contributor

atsushi-ishibashi commented Nov 18, 2017

@jamesgoodhouse When 1 is set to var.create_user, your tf works well. In other cases, the below works well. Did you set the same value for var.create_user when you worked with 0.10.8?

variable "create_user" { }
variable "public_key" { }

resource "aws_iam_user" "u" {
  count = "${var.create_user}"
  name  = "user_name"
  path  = "/"
}

resource "aws_iam_access_key" "k" {
  count   = "${var.create_user}"
  user    = "${element(aws_iam_user.u.*.name, count.index)}"
  pgp_key = "${var.public_key}"
}

output "okta_user_encrypted_secret" {
  value = "${aws_iam_access_key.k.*.encrypted_secret}"
}

@kwach
Copy link

kwach commented Nov 18, 2017

This might be related: hashicorp/terraform#16688
Should this not be tracked here I'll create separate issue.

@jamesgoodhouse
Copy link
Author

@atsushi-ishibashi: yep, i'm using the same value as I did for 0.10.8. Literally nothing has changed on my end other than upgrading to 0.11.0.

@jamesgoodhouse
Copy link
Author

I was pointed to this as the culprit of my issues. I've yet to make changes to test it out, but looks promising.

https://www.terraform.io/upgrade-guides/0-11.html#error-checking-for-output-values

@paddycarver paddycarver added bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. waiting-response Maintainers are waiting on response from community or contributor. labels Nov 20, 2017
@radeksimko
Copy link
Member

Just confirmed (by trying to apply the attached config with latest build from current master) this is indeed a regression which was fixed in #2348 and will be part of the next release.

Sorry for any inconvenience.

@ghost
Copy link

ghost commented Apr 8, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 8, 2020
@breathingdust breathingdust removed the waiting-response Maintainers are waiting on response from community or contributor. label Sep 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement.
Projects
None yet
Development

No branches or pull requests

6 participants