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

[Bug]: Don't associate public ip when eip is assigned to instance #37318

Open
schiaro98 opened this issue May 7, 2024 · 2 comments
Open

[Bug]: Don't associate public ip when eip is assigned to instance #37318

schiaro98 opened this issue May 7, 2024 · 2 comments
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@schiaro98
Copy link

schiaro98 commented May 7, 2024

Terraform Core Version

1.7.5

AWS Provider Version

4.25

Affected Resource(s)

aws_eip, aws_instance

Expected Behavior

After applying the next plan (an aws_instance with eip) in this manner:

resource "aws_eip" "eip1" {
  instance = aws_instance.foo.id
  domain   = "vpc"
}

and instance

resource "aws_instance" "foo" {
  ami           = "ami-5189a661"
  instance_type = "t2.micro"
  ....
associate_public_ip_address = false
}

All goes like estimate, istance has correctly the eip1 public eip, but if a plan is executed after this, the associate_public_ip_address directive force the replacemente of the instance, and the only way to correct this is to comment out or put associate_public_ip_address to true.

Is this behavior correct or a bug? I can't figure how this can be correct, but not having strong experience, preferring to ask to the community

Actual Behavior

The instance is correctly created, but every next plan, requires the istance to be replaced.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 4.16"
    }
  }

  required_version = ">= 1.2.0"
}

provider "aws" {
  region  = "***"
  profile = "***"
}

resource "aws_eip" "eip1" {
  instance = aws_instance.example_server.id
  domain   = "vpc"
}
resource "aws_instance" "example_server" {
  ami           = "ami-04e914639d0cca79a"
  instance_type = "t2.micro"

}

Steps to Reproduce

  • create aws instance from terraform with eip and associate_public_ip_address = false
  • plan, it will ask to replace the instance

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@schiaro98 schiaro98 added the bug Addresses a defect in current functionality. label May 7, 2024
Copy link

github-actions bot commented May 7, 2024

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this 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.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the service/ec2 Issues and PRs that pertain to the ec2 service. label May 7, 2024
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label May 7, 2024
@justinretzolk
Copy link
Member

Related #37238

@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label May 8, 2024
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/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

No branches or pull requests

2 participants