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

feat: Add instance private IP to the outputs #241

Closed mustafa89 closed 3 years ago

mustafa89 commented 3 years ago

Description

Added an output for the private_ip of the aws instance(s), similar to the public_ip.

Motivation and Context

I need the private IP as an output for referencing,

Breaking Changes

None

How Has This Been Tested?

I tested against the volume-attachment example.

Also,

After discovering the module doesn't have a private_ip output. I cloned my fork, changed the source of the module in my original project to point to my local clone, and then re-ran terraform. The private_ip of the instance was then outputed.

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # aws_ebs_volume.volume["eu-central-1a"] will be updated in-place
  ~ resource "aws_ebs_volume" "volume" {
        id                   = "<redacted>"
      ~ tags                 = {
          + "purpose" = "<redacted>"
            # (1 unchanged element hidden)
        }
        # (9 unchanged attributes hidden)
    }

  # aws_ebs_volume.volume["eu-central-1b"] will be updated in-place
  ~ resource "aws_ebs_volume" "volume" {
        id                   = "<redacted>"
      ~ tags                 = {
          + "purpose" = "<redacted>"
            # (1 unchanged element hidden)
        }
        # (9 unchanged attributes hidden)
    }

Plan: 0 to add, 2 to change, 0 to destroy.

Changes to Outputs:
  + ec2 = "10.64.0.221"

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: no

Apply cancelled.
❯ terraform --version
Terraform v1.0.0
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v3.51.0
+ provider registry.terraform.io/hashicorp/local v2.1.0
+ provider registry.terraform.io/hashicorp/tls v3.1.0

Your version of Terraform is out of date! The latest version
is 1.0.8. You can update by downloading from https://www.terraform.io/downloads.html
❯ terragrunt --version
antonbabenko commented 3 years ago

There were similar requests like this - #240

@bryantbiggs How about making an exception for private_ip and merge this PR?

antonbabenko commented 3 years ago

@mustafa89 Thank you for the addition.

v3.2.0 has been just released.

mustafa89 commented 3 years ago

Thanks for the merge and for all your great work.

github-actions[bot] commented 2 years ago

I'm going to lock this pull request 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 related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.