-
Notifications
You must be signed in to change notification settings - Fork 1
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
multi-region: conditional bootstrap #6
Conversation
If this is not changed, terraform will report this errors below: Error: Error refreshing state: 7 error(s) occurred: * module.spoke-1.module.dcos-infrastructure.module.dcos-bootstrap-instance.output.public_ip: At column 44, line 1: list \"module.dcos-bootstrap-instance.public_ips\" does not have any elements so cannot determine type. in: ${module.dcos-bootstrap-instance.public_ips[0]} * module.vpc-peering.aws_route.this_routes_cross_region: aws_route.this_routes_cross_region: value of 'count' cannot be computed * module.vpc-peering.aws_route.peer_routes_region: aws_route.peer_routes_region: value of 'count' cannot be computed * module.vpc-peering.aws_route.this_routes_region: aws_route.this_routes_region: value of 'count' cannot be computed * module.spoke-1.module.dcos-infrastructure.module.dcos-bootstrap-instance.output.private_ip: At column 45, line 1: list \"module.dcos-bootstrap-instance.private_ips\" does not have any elements so cannot determine type. in: ${module.dcos-bootstrap-instance.private_ips[0]} * module.vpc-peering.aws_route.peer_routes_cross_region: aws_route.peer_routes_cross_region: value of 'count' cannot be computed * module.spoke-1.module.dcos-infrastructure.module.dcos-bootstrap-instance.output.instance: At column 43, line 1: list \"module.dcos-bootstrap-instance.instances\" does not have any elements so cannot determine type. in: ${module.dcos-bootstrap-instance.instances[0]} "
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 why is this needed for molti-region. To me this change will introduce multi AZ but not multi region
} | ||
|
||
output "private_ip" { | ||
description = "List of private ip addresses created by this module" | ||
value = "${module.dcos-bootstrap-instance.private_ips[0]}" | ||
value = "${element(concat(module.dcos-bootstrap-instance.private_ips, list("")), 0)}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I see the concat is meant to be used while destroying... do I get this right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when the bootstrap is conditionally created in the case of the multi-region environment where it pull the bootstrap from a remote region, having an empty object in an array throws an error. More info on this here: hashicorp/hil#50
The workaround in terraform is to always add a list("") and have it return that instead in the event an empty list exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this specific comment as well hashicorp/terraform#16580 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
This adds control to enable a bootstrap node on the remote region