Skip to content

Commit

Permalink
feat: remove eip
Browse files Browse the repository at this point in the history
public ip has changed after applied 🤷, sync with `tf refresh`
```sh
Note: Objects have changed outside of Terraform

Terraform detected the following changes made outside of Terraform since the last "terraform apply" which may have affected this plan:

  # aws_instance.hashicat has changed
  ~ resource "aws_instance" "hashicat" {
        id                                   = "i-xxxxxxxxxxxxxxxx"
      ~ public_dns                           = "ec2-x-xx-xxx-xxx.ap-northeast-2.compute.amazonaws.com" -> "ec2-y-yy-yyy-yyy.ap-northeast-2.compute.amazonaws.com"
      ~ public_ip                            = "x.xx.xxx.xxx" -> "y.yy.yyy.yyy"
        tags                                 = {
            "Name" = "dev-hashicat-instance"
        }
        # (30 unchanged attributes hidden)

        # (8 unchanged blocks hidden)
    }

Unless you have made equivalent changes to your configuration, or ignored the relevant attributes using ignore_changes, the following plan may include actions to undo or respond to these changes.

───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Changes to Outputs:
  ~ catapp_ip  = "http://x.xx.xxx.xxx" -> "http://y.yy.yyy.yyy"
  ~ catapp_url = "http://ec2-x-xx-xxx-xxx.ap-northeast-2.compute.amazonaws.com" -> "http://ec2-y-yy-yyy-yyy.ap-northeast-2.compute.amazonaws.com"

You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure.
```
  • Loading branch information
flavono123 committed Sep 24, 2023
1 parent 0e375cf commit 9291c66
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
16 changes: 3 additions & 13 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,6 @@ data "aws_ami" "ubuntu" {
owners = ["099720109477"] # Canonical
}

resource "aws_eip" "hashicat" {
instance = aws_instance.hashicat.id
vpc = true
}

resource "aws_eip_association" "hashicat" {
instance_id = aws_instance.hashicat.id
allocation_id = aws_eip.hashicat.id
}

resource "aws_instance" "hashicat" {
ami = data.aws_ami.ubuntu.id
instance_type = var.instance_type
Expand All @@ -144,7 +134,7 @@ resource "aws_instance" "hashicat" {
}

resource "null_resource" "configure-cat-app" {
depends_on = [aws_eip_association.hashicat]
depends_on = [aws_instance.hashicat]

// triggers = {
// build_number = timestamp()
Expand All @@ -158,7 +148,7 @@ resource "null_resource" "configure-cat-app" {
type = "ssh"
user = "ubuntu"
private_key = tls_private_key.hashicat.private_key_pem
host = aws_eip.hashicat.public_ip
host = aws_instance.hashicat.public_ip
}
}

Expand All @@ -180,7 +170,7 @@ resource "null_resource" "configure-cat-app" {
type = "ssh"
user = "ubuntu"
private_key = tls_private_key.hashicat.private_key_pem
host = aws_eip.hashicat.public_ip
host = aws_instance.hashicat.public_ip
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
output "catapp_url" {
value = "http://${aws_eip.hashicat.public_dns}"
value = "http://${aws_instance.hashicat.public_dns}"
}

output "catapp_ip" {
value = "http://${aws_eip.hashicat.public_ip}"
value = "http://${aws_instance.hashicat.public_ip}"
}

0 comments on commit 9291c66

Please sign in to comment.