terraform-aws-modules / terraform-aws-ec2-instance

Terraform module to create AWS EC2 instance(s) resources 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/ec2-instance/aws
Apache License 2.0
758 stars 1.88k forks source link

Assign an Elastic IP #259

Closed Alexander-Giaquinto closed 2 years ago

Alexander-Giaquinto commented 2 years ago

Hello, would just like to see if there is a possibility to be able to call the aws_eip resource within this module. It seems that it can only be done via the aws_instance resource. Could this be possible?

antonbabenko commented 2 years ago

Hi @Alexander-Giaquinto !

You need to create aws_eip resource outside of this module and assign it to an instance ID returned from the module:

module "ec2_instance" {
  source  = "terraform-aws-modules/ec2-instance/aws"
  version = "~> 3.0"

  # ... omitted
}

resource "aws_eip" "this" {
  vpc = true

  instance = module.ec2_instance.id
}

It is unlikely that we implement EIP support as a part of this module.

Alexander-Giaquinto commented 2 years ago

Hey @antonbabenko ! Yes! I figured this out yesterday just moments after submitting the issue. But thank you for the reassurance!!! Appreciate the help! Makes sense, no need to import EIP within the module directly!

github-actions[bot] commented 2 years ago

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.