From 885469243cd841139b5fce82371375736c5d1275 Mon Sep 17 00:00:00 2001 From: Adam Mckaig Date: Mon, 14 Dec 2015 22:56:15 -0500 Subject: [PATCH] Update examples I unfortunately had to remove the CloudStack example, because I don't have access to one of those. Moved the old example to an integration test, at least. --- fixtures/example.tf | 38 +++++++------- fixtures/example.tfstate | 89 ++++++++++++++++++++++----------- fixtures/playbook.yml | 1 - fixtures/secrets.tfvars.example | 3 -- parser_test.go | 6 ++- 5 files changed, 85 insertions(+), 52 deletions(-) diff --git a/fixtures/example.tf b/fixtures/example.tf index e4ffda7..c0a567f 100644 --- a/fixtures/example.tf +++ b/fixtures/example.tf @@ -2,9 +2,6 @@ variable "do_token" {} variable "aws_access_key" {} variable "aws_secret_key" {} variable "aws_subnet_id" {} -variable "cs_api_url" {} -variable "cs_api_key" {} -variable "cs_secret_key" {} provider "aws" { access_key = "${var.aws_access_key}" @@ -16,13 +13,6 @@ provider "digitalocean" { token = "${var.do_token}" } - -provider "cloudstack" { - api_url = "${var.cs_api_url}" - api_key = "${var.cs_api_key}" - secret_key = "${var.cs_secret_key}" -} - resource "aws_instance" "web-aws" { ami = "ami-96a818fe" instance_type = "t2.micro" @@ -30,9 +20,30 @@ resource "aws_instance" "web-aws" { associate_public_ip_address = true key_name = "terraform-inventory" count = 2 + root_block_device = { delete_on_termination = true } + + tags = { + Role = "Webserver" + } +} + +resource "aws_instance" "worker-aws" { + ami = "ami-96a818fe" + instance_type = "t2.micro" + subnet_id = "${var.aws_subnet_id}" + associate_public_ip_address = true + key_name = "terraform-inventory" + + root_block_device = { + delete_on_termination = true + } + + tags = { + Role = "Worker" + } } resource "digitalocean_droplet" "web-do" { @@ -42,10 +53,3 @@ resource "digitalocean_droplet" "web-do" { size = "512mb" ssh_keys = [862272] } - -resource "cloudstack_instance" "web-cs" { - name = "terraform-inventory-2" - service_offering = "small" - template = "centos-7-0-x64" - zone = "nyc2" -} diff --git a/fixtures/example.tfstate b/fixtures/example.tfstate index b14237e..3eddfe0 100644 --- a/fixtures/example.tfstate +++ b/fixtures/example.tfstate @@ -1,6 +1,6 @@ { "version": 1, - "serial": 13, + "serial": 15, "modules": [ { "path": [ @@ -11,7 +11,7 @@ "aws_instance.web-aws.0": { "type": "aws_instance", "primary": { - "id": "i-e8f3a238", + "id": "i-6db8dedb", "attributes": { "ami": "ami-96a818fe", "associate_public_ip_address": "true", @@ -19,13 +19,15 @@ "ebs_block_device.#": "0", "ebs_optimized": "false", "ephemeral_block_device.#": "0", - "id": "i-e8f3a238", + "iam_instance_profile": "", + "id": "i-6db8dedb", "instance_type": "t2.micro", "key_name": "terraform-inventory", - "private_dns": "ip-10-0-0-12.ec2.internal", - "private_ip": "10.0.0.12", + "monitoring": "false", + "private_dns": "ip-10-0-0-14.ec2.internal", + "private_ip": "10.0.0.14", "public_dns": "", - "public_ip": "52.7.58.202", + "public_ip": "52.90.155.162", "root_block_device.#": "1", "root_block_device.0.delete_on_termination": "true", "root_block_device.0.iops": "0", @@ -34,7 +36,8 @@ "security_groups.#": "0", "source_dest_check": "true", "subnet_id": "subnet-59f9b32e", - "tags.#": "0", + "tags.#": "1", + "tags.Role": "Webserver", "tenancy": "default", "vpc_security_group_ids.#": "1", "vpc_security_group_ids.2076429742": "sg-b42329d0" @@ -47,7 +50,7 @@ "aws_instance.web-aws.1": { "type": "aws_instance", "primary": { - "id": "i-f747c141", + "id": "i-10b9dfa6", "attributes": { "ami": "ami-96a818fe", "associate_public_ip_address": "true", @@ -56,14 +59,14 @@ "ebs_optimized": "false", "ephemeral_block_device.#": "0", "iam_instance_profile": "", - "id": "i-f747c141", + "id": "i-10b9dfa6", "instance_type": "t2.micro", "key_name": "terraform-inventory", "monitoring": "false", - "private_dns": "ip-10-0-0-10.ec2.internal", - "private_ip": "10.0.0.10", + "private_dns": "ip-10-0-0-6.ec2.internal", + "private_ip": "10.0.0.6", "public_dns": "", - "public_ip": "52.91.51.56", + "public_ip": "54.174.82.24", "root_block_device.#": "1", "root_block_device.0.delete_on_termination": "true", "root_block_device.0.iops": "0", @@ -72,7 +75,47 @@ "security_groups.#": "0", "source_dest_check": "true", "subnet_id": "subnet-59f9b32e", - "tags.#": "0", + "tags.#": "1", + "tags.Role": "Webserver", + "tenancy": "default", + "vpc_security_group_ids.#": "1", + "vpc_security_group_ids.2076429742": "sg-b42329d0" + }, + "meta": { + "schema_version": "1" + } + } + }, + "aws_instance.worker-aws": { + "type": "aws_instance", + "primary": { + "id": "i-9e85e328", + "attributes": { + "ami": "ami-96a818fe", + "associate_public_ip_address": "true", + "availability_zone": "us-east-1d", + "ebs_block_device.#": "0", + "ebs_optimized": "false", + "ephemeral_block_device.#": "0", + "iam_instance_profile": "", + "id": "i-9e85e328", + "instance_type": "t2.micro", + "key_name": "terraform-inventory", + "monitoring": "false", + "private_dns": "ip-10-0-0-5.ec2.internal", + "private_ip": "10.0.0.5", + "public_dns": "", + "public_ip": "52.23.169.41", + "root_block_device.#": "1", + "root_block_device.0.delete_on_termination": "true", + "root_block_device.0.iops": "0", + "root_block_device.0.volume_size": "8", + "root_block_device.0.volume_type": "standard", + "security_groups.#": "0", + "source_dest_check": "true", + "subnet_id": "subnet-59f9b32e", + "tags.#": "1", + "tags.Role": "Worker", "tenancy": "default", "vpc_security_group_ids.#": "1", "vpc_security_group_ids.2076429742": "sg-b42329d0" @@ -85,11 +128,11 @@ "digitalocean_droplet.web-do": { "type": "digitalocean_droplet", "primary": { - "id": "5579362", + "id": "9410811", "attributes": { - "id": "5579362", + "id": "9410811", "image": "centos-7-0-x64", - "ipv4_address": "192.241.136.44", + "ipv4_address": "192.241.149.172", "locked": "false", "name": "terraform-inventory-1", "region": "nyc1", @@ -99,20 +142,6 @@ "status": "active" } } - }, - "cloudstack_instance.web-cs": { - "type": "cloudstack_instance", - "primary": { - "id": "500fb40e-8796-a724-8bcd-211bd1866bc0", - "attributes": { - "id": "500fb40e-8796-a724-8bcd-211bd1866bc0", - "ipaddress": "10.2.1.5", - "name": "terraform-inventory-2", - "service_offering": "small", - "template": "centos-7-0-x64", - "zone": "nyc2" - } - } } } } diff --git a/fixtures/playbook.yml b/fixtures/playbook.yml index 54097e1..a4d802a 100644 --- a/fixtures/playbook.yml +++ b/fixtures/playbook.yml @@ -1,6 +1,5 @@ - hosts: - web-aws - web-do - - web-cs tasks: - command: "echo Hello, world!" diff --git a/fixtures/secrets.tfvars.example b/fixtures/secrets.tfvars.example index c5d9bd3..a61bade 100644 --- a/fixtures/secrets.tfvars.example +++ b/fixtures/secrets.tfvars.example @@ -2,6 +2,3 @@ do_token = "" aws_access_key = "" aws_secret_key = "" aws_subnet_id = "" -cs_api_url = "" -cs_api_key = "" -cs_secret_key = "" diff --git a/parser_test.go b/parser_test.go index 28e868f..f9b7302 100644 --- a/parser_test.go +++ b/parser_test.go @@ -77,7 +77,11 @@ const exampleStateFile = ` "id": "aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "attributes": { "id": "aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", - "ipaddress": "10.2.1.5" + "ipaddress": "10.2.1.5", + "name": "terraform-inventory-4", + "service_offering": "small", + "template": "centos-7-0-x64", + "zone": "nyc2" } } },