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

Setting the nat_gateway_enabled=false results in Invalid index error #44

Closed
paulrob-100 opened this issue Apr 19, 2021 · 1 comment · Fixed by #50
Closed

Setting the nat_gateway_enabled=false results in Invalid index error #44

paulrob-100 opened this issue Apr 19, 2021 · 1 comment · Fixed by #50
Labels
bug 🐛 An issue with the system

Comments

@paulrob-100
Copy link
Contributor

paulrob-100 commented Apr 19, 2021

Describe the Bug

Setting the nat_gateway_enabled=false results in InvalidNatGatewayId.Malformed error on private subnets aws_route resource

Expected Behavior

Terraform apply should run without error and no routes to the nat gateways should exist in the private subnets

Steps to Reproduce

Steps to reproduce the behavior:

  1. Go to examples/complete/main.tf
  2. Edit nat_gateway_enabled = true to be nat_gateway_enabled = false
  3. Run terraform apply -var-file fixtures.us-east-2.tfvars
  4. See error InvalidNatGatewayId.Malformed: Invalid id: "0" (expecting "nat-...")

Screenshots

Not necessary

Environment (please complete the following information):

Anything that will help us triage the bug will help. Here are some ideas:

  • OS:Linux
  • TF Version 14.7

Additional Context

None

@paulrob-100
Copy link
Contributor Author

Reran the test from #45 and confirmed it's still an issue.

    apply.go:15: 
        	Error Trace:	apply.go:15
        	            				examples_complete_test.go:148
        	Error:      	Received unexpected error:
        	            	FatalError{Underlying: error while running command: exit status 1; 
        	            	Error: Invalid index
        	            	
        	            	  on ../../main.tf line 13, in locals:
        	            	  13:     ngw_id         = local.public_enabled ? aws_nat_gateway.public[az].id : null
        	            	    |----------------
        	            	    | aws_nat_gateway.public is object with no attributes
        	            	
        	            	The given key does not identify an element in this collection value.
        	            	
        	            	
        	            	Error: Invalid index
        	            	
        	            	  on ../../main.tf line 13, in locals:
        	            	  13:     ngw_id         = local.public_enabled ? aws_nat_gateway.public[az].id : null
        	            	    |----------------
        	            	    | aws_nat_gateway.public is object with no attributes
        	            	
        	            	The given key does not identify an element in this collection value.
        	            	
        	            	
        	            	Error: Invalid index
        	            	
        	            	  on ../../main.tf line 13, in locals:
        	            	  13:     ngw_id         = local.public_enabled ? aws_nat_gateway.public[az].id : null
        	            	    |----------------
        	            	    | aws_nat_gateway.public is object with no attributes
        	            	
        	            	The given key does not identify an element in this collection value.
        	            	}
        	Test:       	TestExamplesCompleteNoNatGateway

@paulrob-100 paulrob-100 changed the title Setting the nat_gateway_enabled=false results in InvalidNatGatewayId.Malformed error Setting the nat_gateway_enabled=false results in Invalid index error Apr 26, 2021
@Nuru Nuru closed this as completed in #50 May 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment