Skip to content

Instantly share code, notes, and snippets.

@jrnt30
Created May 18, 2016 14:38
Show Gist options
  • Save jrnt30/72c872e05750f4f72ee8675cd3fc1fe5 to your computer and use it in GitHub Desktop.
Save jrnt30/72c872e05750f4f72ee8675cd3fc1fe5 to your computer and use it in GitHub Desktop.
GH 5396 tests
09:35 $ terraform --version
Terraform v0.6.16
✔ ~/Development/go/src/github.com/hashicorp/issues/5396
09:35 $ cat main.tf
variable "aws_region" { default = "us-east-1" }
variable "cidrs" { default = "10.1.0.0/16,10.2.0.0/16,10.3.0.0/16" }
provider "aws" {
region = "${var.aws_region}"
}
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
}
resource "aws_security_group" "group" {
vpc_id = "${aws_vpc.main.id}"
}
resource "aws_security_group_rule" "ingress_ssh" {
type = "ingress"
from_port = 22
to_port = 22
protocol = "TCP"
cidr_blocks = ["${split(",", var.cidrs)}"]
security_group_id = "${aws_security_group.group.id}"
}
✔ ~/Development/go/src/github.com/hashicorp/issues/5396
09:35 $ terraform plan
Refreshing Terraform state prior to plan...
The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
will be created (or destroyed and then created if an existing resource
exists), yellow resources are being changed in-place, and red resources
will be destroyed.
Note: You didn't specify an "-out" parameter to save this plan, so when
"apply" is called, Terraform can't guarantee this is what will execute.
+ aws_security_group.group
description: "" => "Managed by Terraform"
egress.#: "" => "<computed>"
ingress.#: "" => "<computed>"
name: "" => "<computed>"
owner_id: "" => "<computed>"
vpc_id: "" => "${aws_vpc.main.id}"
+ aws_security_group_rule.ingress_ssh
cidr_blocks.#: "" => "3"
cidr_blocks.0: "" => "10.1.0.0/16"
cidr_blocks.1: "" => "10.2.0.0/16"
cidr_blocks.2: "" => "10.3.0.0/16"
from_port: "" => "22"
protocol: "" => "tcp"
security_group_id: "" => "${aws_security_group.group.id}"
self: "" => "false"
source_security_group_id: "" => "<computed>"
to_port: "" => "22"
type: "" => "ingress"
+ aws_vpc.main
cidr_block: "" => "10.0.0.0/16"
default_network_acl_id: "" => "<computed>"
default_security_group_id: "" => "<computed>"
dhcp_options_id: "" => "<computed>"
enable_classiclink: "" => "<computed>"
enable_dns_hostnames: "" => "<computed>"
enable_dns_support: "" => "<computed>"
instance_tenancy: "" => "<computed>"
main_route_table_id: "" => "<computed>"
Plan: 3 to add, 0 to change, 0 to destroy.
✔ ~/Development/go/src/github.com/hashicorp/issues/5396
09:35 $ terraform apply
aws_vpc.main: Creating...
cidr_block: "" => "10.0.0.0/16"
default_network_acl_id: "" => "<computed>"
default_security_group_id: "" => "<computed>"
dhcp_options_id: "" => "<computed>"
enable_classiclink: "" => "<computed>"
enable_dns_hostnames: "" => "<computed>"
enable_dns_support: "" => "<computed>"
instance_tenancy: "" => "<computed>"
main_route_table_id: "" => "<computed>"
aws_vpc.main: Creation complete
aws_security_group.group: Creating...
description: "" => "Managed by Terraform"
egress.#: "" => "<computed>"
ingress.#: "" => "<computed>"
name: "" => "<computed>"
owner_id: "" => "<computed>"
vpc_id: "" => "vpc-0628ea61"
aws_security_group.group: Creation complete
aws_security_group_rule.ingress_ssh: Creating...
cidr_blocks.#: "" => "3"
cidr_blocks.0: "" => "10.1.0.0/16"
cidr_blocks.1: "" => "10.2.0.0/16"
cidr_blocks.2: "" => "10.3.0.0/16"
from_port: "" => "22"
protocol: "" => "tcp"
security_group_id: "" => "sg-2abf6351"
self: "" => "false"
source_security_group_id: "" => "<computed>"
to_port: "" => "22"
type: "" => "ingress"
aws_security_group_rule.ingress_ssh: 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
✔ ~/Development/go/src/github.com/hashicorp/issues/5396
09:35 $ terraform plan -var cidr="10.1.0.0/16,10.2.0.0/16,10.3.0.0/16,10.4.0.0/16"
Refreshing Terraform state prior to plan...
aws_vpc.main: Refreshing state... (ID: vpc-0628ea61)
aws_security_group.group: Refreshing state... (ID: sg-2abf6351)
aws_security_group_rule.ingress_ssh: Refreshing state... (ID: sgrule-3007042449)
No changes. Infrastructure is up-to-date. This means that Terraform
could not detect any differences between your configuration and
the real physical resources that exist. As a result, Terraform
doesn't need to do anything.
✔ ~/Development/go/src/github.com/hashicorp/issues/5396
09:35 $ terraform plan -var cidrs="10.1.0.0/16,10.2.0.0/16,10.3.0.0/16,10.4.0.0/16"
Refreshing Terraform state prior to plan...
aws_vpc.main: Refreshing state... (ID: vpc-0628ea61)
aws_security_group.group: Refreshing state... (ID: sg-2abf6351)
aws_security_group_rule.ingress_ssh: Refreshing state... (ID: sgrule-3007042449)
The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
will be created (or destroyed and then created if an existing resource
exists), yellow resources are being changed in-place, and red resources
will be destroyed.
Note: You didn't specify an "-out" parameter to save this plan, so when
"apply" is called, Terraform can't guarantee this is what will execute.
-/+ aws_security_group_rule.ingress_ssh
cidr_blocks.#: "3" => "4" (forces new resource)
cidr_blocks.0: "10.1.0.0/16" => "10.1.0.0/16"
cidr_blocks.1: "10.2.0.0/16" => "10.2.0.0/16"
cidr_blocks.2: "10.3.0.0/16" => "10.3.0.0/16"
cidr_blocks.3: "" => "10.4.0.0/16" (forces new resource)
from_port: "22" => "22"
protocol: "tcp" => "tcp"
security_group_id: "sg-2abf6351" => "sg-2abf6351"
self: "false" => "false"
source_security_group_id: "" => "<computed>"
to_port: "22" => "22"
type: "ingress" => "ingress"
Plan: 1 to add, 0 to change, 1 to destroy.
✔ ~/Development/go/src/github.com/hashicorp/issues/5396
09:36 $ terraform apply -var cidrs="10.1.0.0/16,10.2.0.0/16,10.3.0.0/16,10.4.0.0/16"
aws_vpc.main: Refreshing state... (ID: vpc-0628ea61)
aws_security_group.group: Refreshing state... (ID: sg-2abf6351)
aws_security_group_rule.ingress_ssh: Refreshing state... (ID: sgrule-3007042449)
aws_security_group_rule.ingress_ssh: Destroying...
aws_security_group_rule.ingress_ssh: Destruction complete
aws_security_group_rule.ingress_ssh: Creating...
cidr_blocks.#: "" => "4"
cidr_blocks.0: "" => "10.1.0.0/16"
cidr_blocks.1: "" => "10.2.0.0/16"
cidr_blocks.2: "" => "10.3.0.0/16"
cidr_blocks.3: "" => "10.4.0.0/16"
from_port: "" => "22"
protocol: "" => "tcp"
security_group_id: "" => "sg-2abf6351"
self: "" => "false"
source_security_group_id: "" => "<computed>"
to_port: "" => "22"
type: "" => "ingress"
aws_security_group_rule.ingress_ssh: Creation complete
Apply complete! Resources: 1 added, 0 changed, 1 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
✔ ~/Development/go/src/github.com/hashicorp/issues/5396
09:36 $ terraform apply -var cidrs="10.1.0.0/16,10.2.0.0/16,10.3.0.0/16,10.4.0.0/16"
aws_vpc.main: Refreshing state... (ID: vpc-0628ea61)
aws_security_group.group: Refreshing state... (ID: sg-2abf6351)
aws_security_group_rule.ingress_ssh: Refreshing state... (ID: sgrule-3076809922)
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
✔ ~/Development/go/src/github.com/hashicorp/issues/5396
09:36 $ terraform apply -var cidrs="10.1.0.0/16,10.2.0.0/16,10.3.0.0/16,10.0.0.0/16"
aws_vpc.main: Refreshing state... (ID: vpc-0628ea61)
aws_security_group.group: Refreshing state... (ID: sg-2abf6351)
aws_security_group_rule.ingress_ssh: Refreshing state... (ID: sgrule-3076809922)
aws_security_group_rule.ingress_ssh: Destroying...
aws_security_group_rule.ingress_ssh: Destruction complete
aws_security_group_rule.ingress_ssh: Creating...
cidr_blocks.#: "" => "4"
cidr_blocks.0: "" => "10.1.0.0/16"
cidr_blocks.1: "" => "10.2.0.0/16"
cidr_blocks.2: "" => "10.3.0.0/16"
cidr_blocks.3: "" => "10.0.0.0/16"
from_port: "" => "22"
protocol: "" => "tcp"
security_group_id: "" => "sg-2abf6351"
self: "" => "false"
source_security_group_id: "" => "<computed>"
to_port: "" => "22"
type: "" => "ingress"
aws_security_group_rule.ingress_ssh: Creation complete
Apply complete! Resources: 1 added, 0 changed, 1 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
✔ ~/Development/go/src/github.com/hashicorp/issues/5396
09:36 $ terraform apply -var cidrs="10.1.0.0/16,10.2.0.0/16,10.3.0.0/16,10.0.0.0/16"
aws_vpc.main: Refreshing state... (ID: vpc-0628ea61)
aws_security_group.group: Refreshing state... (ID: sg-2abf6351)
aws_security_group_rule.ingress_ssh: Refreshing state... (ID: sgrule-3026064332)
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
✔ ~/Development/go/src/github.com/hashicorp/issues/5396
09:36 $
variable "aws_region" { default = "us-east-1" }
variable "cidrs" { default = "10.1.0.0/16,10.2.0.0/16,10.3.0.0/16" }
provider "aws" {
region = "${var.aws_region}"
}
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
}
resource "aws_security_group" "group" {
vpc_id = "${aws_vpc.main.id}"
}
resource "aws_security_group_rule" "ingress_ssh" {
type = "ingress"
from_port = 22
to_port = 22
protocol = "TCP"
cidr_blocks = ["${split(",", var.cidrs)}"]
security_group_id = "${aws_security_group.group.id}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment