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

Issue in manipulation of resource output/reference with count #19549

Closed
farman022 opened this issue Dec 5, 2018 · 4 comments
Closed

Issue in manipulation of resource output/reference with count #19549

farman022 opened this issue Dec 5, 2018 · 4 comments

Comments

@farman022
Copy link

farman022 commented Dec 5, 2018

Hi,
I have two resources. one with count variable and taking the reference of one in other. It will give error if the count is zero in the first one.

i.e
I have one option group resource.

resource "aws_db_option_group" "rds_option_group" {
 count     = "${var.abc == "abc" ? 0 : 1}"
 name                 = "asdf-og"
 engine_name          = "sqlserver-se"
 major_engine_version = "xxxxx"

 option {
   option_name = "XXXXXXXX"

   option_settings {
     name  = "IAM_ROLE_ARN"
     value = "xxxxxx"
   }
 }
}

and in rds resource, I have written like that. Do not have count variable here in rds resource.

option_group_name  = "${var.bac == "abc" ? "some-value" : aws_db_option_group.rds_option_group.name}"

**Error i got if var.abc != "abc"

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

* module.test.module.rds.aws_db_instance.rds: 1 error(s) occurred:

* module.test.module.rds.aws_db_instance.rds: Resource 'aws_db_option_group.rds_option_group' not found for variable 'aws_db_option_group.rds_option_group.name'**

Can you please let me know if we have any method to manipulate this. or it is a bug.

@farman022
Copy link
Author

farman022 commented Dec 9, 2018

@apparentlymart can you look into it or Reply something?

@mildwonkey
Copy link
Contributor

Hi @farman022, sorry you have run across this.

I suspect you are running into a known limitation of the terraform's configuration language - both sides of a conditional are always evaluated, so you can get errors like this when a resource is not created, but referenced in a conditional.

Here is the main issue where we've been tracking this:
#15605

This is (unfortunately)expected behavior in current versions of terraform, fixed in the upcoming 0.12 release.

@mildwonkey
Copy link
Contributor

I am going to close this since it is fixed in 0.12. Please open a new issue if you have any other problems.

@ghost
Copy link

ghost commented Mar 30, 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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants