-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
aws_default_internet_gateway is missing #2436
Comments
Yes, thought about this when adding |
Agreed, this would be very helpful |
We got around it by declaring a data source, but it would still be nice to have a resource for it.
|
The reason I haven't done this is that I couldn't see a way to definitively identify the auto-created IGW in the default VPC - The API doesn't indicate whether an IGW is "default" or not. |
@xgathos @Heiko-san @anthony2025 data "aws_vpc" "default" {
default = true
}
resource "aws_internet_gateway" "default" {
vpc_id = "${data.aws_vpc.default.id}"
} and then import the IGW (ID obtained from AWS Console or by other means): $ terraform import aws_internet_gateway.default igw-012345678
aws_internet_gateway.default: Importing from ID "igw-012345678"...
aws_internet_gateway.default: Import complete!
Imported aws_internet_gateway (ID: igw-012345678)
aws_internet_gateway.default: Refreshing state... (ID: igw-012345678)
Import successful!
The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.
$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
data.aws_vpc.default: Refreshing state...
aws_internet_gateway.default: Refreshing state... (ID: igw-012345678)
------------------------------------------------------------------------
No changes. Infrastructure is up-to-date.
|
Didn't even know that was possible, thank you for the response! |
As there can only be one internet gateway attached to a VPC (see VPC Limits), maybe instead of trying to create a new internet gateway and later attaching it to a VPC (which will create a new internet gateway just fine but fail on the attaching step), we could auto-import the existing gateway and reconfigure it according to the configuration (probably with a "reuse_existing" or similar flag to preserve the old behavior by default). My use case is currently to ensure that all elements of the "Default VPC" have a Name attribute associated with it. This works fine for aws_default_vpc and aws_default_subnet and with the data. aws_internet_gateway workaround it also works for aws_default_route_table and aws_route. But other than manually importing the aws_internet_gateway I could not find a way to achieve my goal. Unfortunately this leads to a non-default VPC after a terraform destroy, as the internet gateway will be deleted. |
Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you! |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
This issue was originally opened by @xgathos as hashicorp/terraform#16747. It was migrated here as a result of the provider split. The original body of the issue is below.
Hi
When trying to update the aws_default_route_table, terraform deletes all routes. Therefore we need to create a route for the default internet gateway again. But there is no aws_default_internet_gateway - this makes this task unnecessary complex.
The text was updated successfully, but these errors were encountered: