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

Cant change subnet names. #13

Open
iveskins opened this issue May 21, 2019 · 4 comments
Open

Cant change subnet names. #13

iveskins opened this issue May 21, 2019 · 4 comments

Comments

@iveskins
Copy link

iveskins commented May 21, 2019

After creating subnets with the cloudposse terraform-aws-named-subnets module, There might be a need to re-name the subnets.
I would expect that simply changing the items in the 'subnet_names' list would let the subnets name tag be updated, or if needed, a subnet be recreated with the new name.
I get the following error if I change the subnet_name list item.
To work around this I had to destroy my project and re-create all resources again with the new name.
Even If I update the name in the AWS gui, I was not able to get around this.


Error: Error refreshing state: 2 error(s) occurred:

* module.private_subnets.output.named_subnet_ids: zipmap: count of keys (1) does not match count of values (0) in:

${zipmap(var.subnet_names, matchkeys(coalescelist(aws_subnet.private.*.id, aws_subnet.public.*.id), coalescelist(aws_subnet.private.*.tags.Named, aws_subnet.public.*.tags.Named), var.subnet_names))}
* module.public_subnets.output.named_subnet_ids: zipmap: count of keys (1) does not match count of values (0) in:

${zipmap(var.subnet_names, matchkeys(coalescelist(aws_subnet.private.*.id, aws_subnet.public.*.id), coalescelist(aws_subnet.private.*.tags.Named, aws_subnet.public.*.tags.Named), var.subnet_names))}
@aterreno
Copy link

aterreno commented Aug 5, 2019

Ended up in the same rabbit hole, but by manually deleting subnets on the AWS ui...

Really bad...

@aterreno
Copy link

aterreno commented Aug 5, 2019

So one option instead of destroying everything is to find where that code gets run, for example I use ag to search ag --hidden -Q "matchkeys(coalescelist(aws_subnet.private.*.id" and comment out in the downloaded modules, it's just an output, so it's safe, unless you are using it in your project.

Once done, remove the comment and all good.

@iveskins
Copy link
Author

iveskins commented Aug 6, 2019

Thanks for sharing about ag. I wasn't aware of it. very helpful.

@DownRangeDevOps
Copy link

Ran into a similar issue (ran into the zipmap error as well).

Since the subnet_names input is a list, the order becomes very important. Re-ordering the list causes subnets to be renamed which can be very problematic. While some of this is true regardless, and in general subnets should be considered immutable, naming doesn't really fall into that category.

On the surface, I think this can be resolved by supplying a map of subnet_identifier -> subnet_name.

Example:

Create subnets named: ec2-app, rds, elasticate
Add a new subnet, but change the order: ec2-app, ec2-mgmt, rds, elasticache.
Problem: the subnets are re-named and you now have RDS resources in a subnet called ec2-mgmt, and elasticache resources in rds.

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

No branches or pull requests

3 participants