-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
terraform lists - depends_on doesn't work #17156
Comments
The What I'm not sure about is what you're trying to do with the |
Hi @jbardin,
the main problem is, that if I run so the config is kind of working, but I can't make it work in single |
I think I see what you want, it's just that the interpolation you've supplied isn't going to work. It's not that terraform is trying to create We're undergoing a revamp of the configuration language right now, in which we will be able to make improvements to the interpolation language as well. Until then, it often helps to break up the interpolation into intermediate values. For example, I think the following portion of the config will get you the values you're looking for:
|
@jbardin thanks for your help, now it is working as expected, creating domain and record set successfully. When going through scenario, where I create 2 domain zones, and then add third one to the list - It's also tries to update previously created record sets, but as long as they are not changed, I think it's ok.
|
Is the issue that the aws_route53_zone resource doesn't support depends_on at all? I took your code example (#17156 (comment)) and used it to declare a txt record that depends on the things I want to ensure that our route53 zones are created correctly but it seems like a terrible hack:
|
Hi all! Sorry for the long silence here. I just tried the following configuration with the v0.12.0-alpha1 prerelease build: provider "aws" {
region = "us-west-2"
}
variable "aws_domains" {
default = [
"exampl.com",
"exampl.net",
"exampl.org",
]
}
resource "aws_route53_zone" "domains" {
name = "${element(var.aws_domains, count.index)}"
count = "${length(var.aws_domains)}"
}
resource "aws_route53_record" "base-nss" {
name = "${element(var.aws_domains, count.index)}"
count = "${length(var.aws_domains)}"
type = "NS"
zone_id = "blahblahplaceholder"
ttl = 30
records = [
"${aws_route53_zone.domains.*.name_servers.0[count.index]}",
"${aws_route53_zone.domains.*.name_servers.1[count.index]}",
"${aws_route53_zone.domains.*.name_servers.2[count.index]}",
"${aws_route53_zone.domains.*.name_servers.3[count.index]}",
]
} I adapted this from the one in the initial comment on this issue. It isn't possible for it to be fully created since I don't have a real zone for those After the first apply I created the three zones and got the errors I expected about
This confirms that the expression is now being resolved as expected. However, the new configuration language implementation also allows this to be written in a more readable way: resource "aws_route53_record" "base-nss" {
name = var.aws_domains[count.index]
count = length(var.aws_domains)
type = "NS"
zone_id = "blahblahplaceholder"
ttl = 30
records = aws_route53_zone.domains[count.index].name_servers
} This produces the same plan:
This fix is in the master branch ready to be included in the forthcoming v0.12.0 final release, so I'm going to close this out. Thanks for reporting this, and thanks for your patience while we got all of this fixed up. |
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. |
Terraform Version
Terraform Configuration Files
tfvars file, I have add zone to be created
Expected Behavior
I am trying to create list of domains zones by reading terraform variable, which contains list of expected domains. Terraform should create domain zone and add NS records set to another domain zone.
Actual Behavior
Seems it's trying to set up
base-nss
first, even though I have setdepends_on = ["aws_route53_zone.domains"]
Steps to Reproduce
Additional Context
References
The text was updated successfully, but these errors were encountered: