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

FIX: aws_nat_gateway resource secondary_private_ip_address_count logic #36360

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

davidsonjon
Copy link

Description

Move logic for secondary_private_ip_address_count for forceNew to customizeDiff

Relations

Closes #33964

Output from Acceptance Testing

% make testacc TESTS=TestAccXXX PKG=ec2

...

I am unable to run the tests in my organization due to VPC limits, so some help would be appreciated but I was able to run the following tests

From the use case in #33964 adding secondary_allocation_ids to and existing configuration yields

# aws_nat_gateway.nat_gw_a will be updated in-place
  ~ resource "aws_nat_gateway" "nat_gw_a" {
        id                                 = "nat-0170c9d03350baaf0"
      ~ secondary_allocation_ids           = [
          + "eipalloc-08574d36e606017b4",
        ]
      ~ secondary_private_ip_address_count = 0 -> (known after apply)
        tags                               = {
            "Name" = "NAT GW AZ1"
        }
        # (9 unchanged attributes hidden)
    }

Removing secondary_allocation_ids

# aws_nat_gateway.nat_gw_a will be updated in-place
  ~ resource "aws_nat_gateway" "nat_gw_a" {
        id                                 = "nat-0261dc97eaf02d40c"
      ~ secondary_allocation_ids           = [
          - "eipalloc-0781fde3477527f3b",
        ]
      ~ secondary_private_ip_address_count = 1 -> (known after apply)
        tags                               = {
            "Name" = "NAT GW AZ1"
        }
        # (9 unchanged attributes hidden)
    }

Changing secondary_private_ip_address_count yields the following plan

 # aws_nat_gateway.nat_gw_a must be replaced
-/+ resource "aws_nat_gateway" "nat_gw_a" {
      + association_id                     = (known after apply)
      ~ id                                 = "nat-04b77581c7710320b" -> (known after apply)
      ~ network_interface_id               = "eni-082b81dfd210cd7c2" -> (known after apply)
      ~ private_ip                         = "10.5.247.41" -> (known after apply)
      + public_ip                          = (known after apply)
      - secondary_allocation_ids           = [] -> null
      ~ secondary_private_ip_address_count = 2 -> 1 # forces replacement
      ~ secondary_private_ip_addresses     = [
          - "10.5.247.40",
          - "10.5.247.61",
        ] -> (known after apply)
        tags                               = {
            "Name" = "NAT GW AZ1"
        }
        # (3 unchanged attributes hidden)
    }

Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added size/XS Managed by automation to categorize the size of a PR. service/vpc Issues and PRs that pertain to the vpc service. labels Mar 13, 2024
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Mar 13, 2024
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome @davidsonjon 👋

It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTOR guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.

Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.

Thanks again, and welcome to the community! 😃

@justinretzolk justinretzolk added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Mar 13, 2024
@anthony-scheller-sh
Copy link

Any update on when this can get merged?

@jeremyweber72
Copy link

Any update on when this can get merged?

Would also love to see this merged, I'd be happy to help in any way I could in order to expedite.

@flaviomoringa
Copy link

Hi,

can this be merged ASAP? I'm also happy to test if something is needed.

I have a really big cluster with githubrunners that needs seconmdary IP's and I'm totally blocked due to this because when enabling it it has downtime.

Thanks in advance to anyone who can make this go forward asap.

@flaviomoringa
Copy link

@justinretzolk Hi, could you take a look or ping someone to review and hopefully approve this PR?

This is really important, as right now natgw's get recreated everytime we run terraform with secondary IP's enabled (even when no changes happen) making it basically unusable in production systems as it causes downtime.

This fix is absolutely critical.

Thanks

@creatorKoo
Copy link

When will this be resolved? This is a bug that needs to be fixed immediately.

@dverzolla
Copy link

dverzolla commented Dec 16, 2024

I am having trouble with secondary_private_ip_address_count also, this PR is super important.
@ewbankkit @YakDriver @davidsonjon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/vpc Issues and PRs that pertain to the vpc service. size/XS Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: secondary_private_ip_address_count causes NAT Gateway replacement
7 participants