Skip to content

Commit

Permalink
~ consul-cluster: refactored inputs, moved variables and outputs
Browse files Browse the repository at this point in the history
ref #70
  • Loading branch information
clstokes committed Oct 11, 2015
1 parent 75f6117 commit f58eeac
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ resource "template_file" "consul_update" {
vars {
region = "${var.region}"
atlas_token = "${var.atlas_token}"
atlas_organization = "${var.atlas_organization}"
atlas_organization = "${var.atlas_username}"
atlas_environment = "${var.atlas_environment}"
consul_bootstrap_expect = "${var.consul_bootstrap_expect}"
}
Expand Down
45 changes: 41 additions & 4 deletions consul-cluster/aws-beginner-consul-cluster/terraform/main.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,47 @@
//
// Providers & Modules
//
provider "aws" {
region = "${var.region}"
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
region = "${var.region}"
}

module "shared" {
source = "../../shared"
source = "../../shared"
key_name = "${var.key_name}"
}

//
// Variables
//
variable "atlas_token" {}
variable "atlas_username" {}
variable "atlas_environment" { default = "consul-cluster" }

variable "region" { default = "us-east-1" }
variable "source_ami" { default = "ami-9a562df2" }
variable "key_name" { default = "atlas-example" }
variable "instance_type" { default = "t2.micro" }

variable "vpc_cidr" { default = "172.31.0.0/16" }
variable "vpc_cidrs" { default = "172.31.0.0/20,172.31.16.0/20,172.31.32.0/20" }

variable "consul_bootstrap_expect" { default = "3" }

//
// Outputs
//
output "consul_client" {
value = "${aws_instance.consul_client.public_ip}"
}

output "consul_0" {
value = "${aws_instance.consul_0.public_ip}"
}

output "consul_1" {
value = "${aws_instance.consul_1.public_ip}"
}

output "consul_2" {
value = "${aws_instance.consul_2.public_ip}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,18 @@ resource "aws_main_route_table_association" "main" {

resource "aws_subnet" "subnet_a" {
vpc_id = "${aws_vpc.main.id}"
availability_zone = "${element(split(",",var.subnets),0)}"
cidr_block = "${element(split(",",var.vpc_cidrs),0)}"
map_public_ip_on_launch = true
}

resource "aws_subnet" "subnet_b" {
vpc_id = "${aws_vpc.main.id}"
availability_zone = "${element(split(",",var.subnets),1)}"
cidr_block = "${element(split(",",var.vpc_cidrs),1)}"
map_public_ip_on_launch = true
}

resource "aws_subnet" "subnet_c" {
vpc_id = "${aws_vpc.main.id}"
availability_zone = "${element(split(",",var.subnets),2)}"
cidr_block = "${element(split(",",var.vpc_cidrs),2)}"
map_public_ip_on_launch = true
}
15 changes: 0 additions & 15 deletions consul-cluster/aws-beginner-consul-cluster/terraform/outputs.tf

This file was deleted.

36 changes: 0 additions & 36 deletions consul-cluster/aws-beginner-consul-cluster/terraform/variables.tf

This file was deleted.

16 changes: 6 additions & 10 deletions consul-cluster/shared/packer/consul_client.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
{
"variables": {
"aws_access_key": "{{ env `AWS_ACCESS_KEY_ID` }}",
"aws_secret_key": "{{ env `AWS_SECRET_ACCESS_KEY` }}",
"region": "{{ env `AWS_REGION` }}",
"region_west": "{{ env `AWS_REGION_WEST` }}",
"source_ami": "{{ env `SOURCE_AMI` }}",
"atlas_organization": "{{ env `ATLAS_ORGANIZATION` }}",
"region": "us-east-1",
"region_west": "us-west-2",
"source_ami": "ami-9a562df2",
"atlas_username": "{{ env `TF_VAR_atlas_username` }}",
"atlas_name": "consul_client"
},
"builders": [
{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "{{user `region`}}",
"source_ami": "{{user `source_ami`}}",
"instance_type": "t2.micro",
Expand All @@ -38,7 +34,7 @@
}
],
"push": {
"name": "{{user `atlas_organization`}}/{{user `atlas_name`}}",
"name": "{{user `atlas_username`}}/{{user `atlas_name`}}",
"vcs": false,
"base_dir": "../../",
"include": [
Expand All @@ -51,7 +47,7 @@
[
{
"type": "atlas",
"artifact": "{{user `atlas_organization`}}/{{user `atlas_name`}}",
"artifact": "{{user `atlas_username`}}/{{user `atlas_name`}}",
"artifact_type": "amazon.image",
"metadata": {
"created_at": "{{timestamp}}"
Expand Down

0 comments on commit f58eeac

Please sign in to comment.