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

multi-region: conditional bootstrap #6

Merged
merged 3 commits into from
Jan 15, 2019
Merged

Conversation

bernadinm
Copy link
Contributor

This adds control to enable a bootstrap node on the remote region

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]}
"
Copy link
Contributor

@fatz fatz left a 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)}"
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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)

Copy link
Contributor

@fatz fatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@bernadinm bernadinm merged commit f84a60d into master Jan 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants