Skip to content

Instantly share code, notes, and snippets.

@clstokes
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clstokes/4e8c7456f19a04ecf45d to your computer and use it in GitHub Desktop.
Save clstokes/4e8c7456f19a04ecf45d to your computer and use it in GitHub Desktop.
main.tf
provider "aws" {
access_key = "ASDF"
secret_key = "ASDF"
region = "us-east-1"
}
resource "aws_security_group" "no_modifications_single_ingress" {
name = "no_modifications_single_ingress"
description = "this security group causes NO modifications each run"
vpc_id = "vpc-abc123"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["10.0.0.1/32","10.0.0.2/32"]
}
}
resource "aws_security_group" "causes_modifications_multiple_ingress_same_ports" {
name = "causes_modifications_multiple_ingress_same_ports"
description = "this security group CAUSES modifications each run"
vpc_id = "vpc-abc123"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["10.0.0.1/32"]
}
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["10.0.0.2/32"]
}
}
resource "aws_security_group" "no_modifications_multiple_ingress_different_ports" {
name = "no_modifications_multiple_ingress_different_ports"
description = "this security group causes NO modifications each run"
vpc_id = "vpc-abc123"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["10.0.0.1/32"]
}
ingress {
from_port = 23
to_port = 23
protocol = "tcp"
cidr_blocks = ["10.0.0.2/32"]
}
}
$ terraform version
Terraform v0.5.3
$ terraform apply
aws_security_group.no_modifications_single_ingress: Creating...
description: "" => "this security group causes NO modifications each run"
egress.#: "" => "<computed>"
ingress.#: "" => "1"
ingress.3090059975.cidr_blocks.#: "" => "2"
ingress.3090059975.cidr_blocks.0: "" => "10.0.0.1/32"
ingress.3090059975.cidr_blocks.1: "" => "10.0.0.2/32"
ingress.3090059975.from_port: "" => "22"
ingress.3090059975.protocol: "" => "tcp"
ingress.3090059975.security_groups.#: "" => "0"
ingress.3090059975.self: "" => "0"
ingress.3090059975.to_port: "" => "22"
name: "" => "no_modifications_single_ingress"
owner_id: "" => "<computed>"
vpc_id: "" => "vpc-ABC123"
aws_security_group.causes_modifications_multiple_ingress_same_ports: Creating...
description: "" => "this security group CAUSES modifications each run"
egress.#: "" => "<computed>"
ingress.#: "" => "2"
ingress.1829659312.cidr_blocks.#: "" => "1"
ingress.1829659312.cidr_blocks.0: "" => "10.0.0.1/32"
ingress.1829659312.from_port: "" => "22"
ingress.1829659312.protocol: "" => "tcp"
ingress.1829659312.security_groups.#: "" => "0"
ingress.1829659312.self: "" => "0"
ingress.1829659312.to_port: "" => "22"
ingress.716052576.cidr_blocks.#: "" => "1"
ingress.716052576.cidr_blocks.0: "" => "10.0.0.2/32"
ingress.716052576.from_port: "" => "22"
ingress.716052576.protocol: "" => "tcp"
ingress.716052576.security_groups.#: "" => "0"
ingress.716052576.self: "" => "0"
ingress.716052576.to_port: "" => "22"
name: "" => "causes_modifications_multiple_ingress_same_ports"
owner_id: "" => "<computed>"
vpc_id: "" => "vpc-ABC123"
aws_security_group.no_modifications_multiple_ingress_different_ports: Creating...
description: "" => "this security group causes NO modifications each run"
egress.#: "" => "<computed>"
ingress.#: "" => "2"
ingress.1829659312.cidr_blocks.#: "" => "1"
ingress.1829659312.cidr_blocks.0: "" => "10.0.0.1/32"
ingress.1829659312.from_port: "" => "22"
ingress.1829659312.protocol: "" => "tcp"
ingress.1829659312.security_groups.#: "" => "0"
ingress.1829659312.self: "" => "0"
ingress.1829659312.to_port: "" => "22"
ingress.3305596422.cidr_blocks.#: "" => "1"
ingress.3305596422.cidr_blocks.0: "" => "10.0.0.2/32"
ingress.3305596422.from_port: "" => "23"
ingress.3305596422.protocol: "" => "tcp"
ingress.3305596422.security_groups.#: "" => "0"
ingress.3305596422.self: "" => "0"
ingress.3305596422.to_port: "" => "23"
name: "" => "no_modifications_multiple_ingress_different_ports"
owner_id: "" => "<computed>"
vpc_id: "" => "vpc-ABC123"
aws_security_group.no_modifications_multiple_ingress_different_ports: Creation complete
aws_security_group.no_modifications_single_ingress: Creation complete
aws_security_group.causes_modifications_multiple_ingress_same_ports: Creation complete
Apply complete! Resources: 3 added, 0 changed, 0 destroyed.
The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.
State path: terraform.tfstate
$ terraform apply
aws_security_group.no_modifications_multiple_ingress_different_ports: Refreshing state... (ID: sg-20f11847)
aws_security_group.causes_modifications_multiple_ingress_same_ports: Refreshing state... (ID: sg-2ef11849)
aws_security_group.no_modifications_single_ingress: Refreshing state... (ID: sg-2ff11848)
aws_security_group.causes_modifications_multiple_ingress_same_ports: Modifying...
ingress.#: "1" => "2"
ingress.1829659312.cidr_blocks.#: "0" => "1"
ingress.1829659312.cidr_blocks.0: "" => "10.0.0.1/32"
ingress.1829659312.from_port: "" => "22"
ingress.1829659312.protocol: "" => "tcp"
ingress.1829659312.security_groups.#: "0" => "0"
ingress.1829659312.self: "" => "0"
ingress.1829659312.to_port: "" => "22"
ingress.716052576.cidr_blocks.#: "0" => "1"
ingress.716052576.cidr_blocks.0: "" => "10.0.0.2/32"
ingress.716052576.from_port: "" => "22"
ingress.716052576.protocol: "" => "tcp"
ingress.716052576.security_groups.#: "0" => "0"
ingress.716052576.self: "" => "0"
ingress.716052576.to_port: "" => "22"
aws_security_group.causes_modifications_multiple_ingress_same_ports: Modifications complete
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.
State path: terraform.tfstate
$ terraform apply
aws_security_group.no_modifications_single_ingress: Refreshing state... (ID: sg-2ff11848)
aws_security_group.causes_modifications_multiple_ingress_same_ports: Refreshing state... (ID: sg-2ef11849)
aws_security_group.no_modifications_multiple_ingress_different_ports: Refreshing state... (ID: sg-20f11847)
aws_security_group.causes_modifications_multiple_ingress_same_ports: Modifying...
ingress.#: "1" => "2"
ingress.1829659312.cidr_blocks.#: "0" => "1"
ingress.1829659312.cidr_blocks.0: "" => "10.0.0.1/32"
ingress.1829659312.from_port: "" => "22"
ingress.1829659312.protocol: "" => "tcp"
ingress.1829659312.security_groups.#: "0" => "0"
ingress.1829659312.self: "" => "0"
ingress.1829659312.to_port: "" => "22"
ingress.716052576.cidr_blocks.#: "0" => "1"
ingress.716052576.cidr_blocks.0: "" => "10.0.0.2/32"
ingress.716052576.from_port: "" => "22"
ingress.716052576.protocol: "" => "tcp"
ingress.716052576.security_groups.#: "0" => "0"
ingress.716052576.self: "" => "0"
ingress.716052576.to_port: "" => "22"
aws_security_group.causes_modifications_multiple_ingress_same_ports: Modifications complete
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.
State path: terraform.tfstate
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment