From f1f18dc766f4078a8695cdc547552493b55894f5 Mon Sep 17 00:00:00 2001 From: Sathiya Shunmugasundaram Date: Sat, 9 May 2015 16:50:11 -0400 Subject: [PATCH] Added access/secret key variables and added Tag to instances, removed egress section since it comes by default --- terraform/aws/consul.tf | 20 ++++++++++++-------- terraform/aws/variables.tf | 13 +++++++++++++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/terraform/aws/consul.tf b/terraform/aws/consul.tf index 3ed0414c27..2bb8ca34b1 100644 --- a/terraform/aws/consul.tf +++ b/terraform/aws/consul.tf @@ -1,3 +1,10 @@ +# Specify the provider and access details +provider "aws" { + region = "${var.region}" + access_key = "${var.access_key}" + secret_key = "${var.secret_key}" +} + resource "aws_instance" "server" { ami = "${lookup(var.ami, var.region)}" instance_type = "${var.instance_type}" @@ -34,6 +41,11 @@ resource "aws_instance" "server" { "${path.module}/scripts/service.sh", ] } + + #Instance tags + tags { + Name = "${var.tagName}-${count.index}" + } } resource "aws_security_group" "consul" { @@ -62,12 +74,4 @@ resource "aws_security_group" "consul" { protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } - - // This is for outbound internet access - egress { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] - } } diff --git a/terraform/aws/variables.tf b/terraform/aws/variables.tf index 35d16d7ad6..24ab54a219 100644 --- a/terraform/aws/variables.tf +++ b/terraform/aws/variables.tf @@ -1,3 +1,11 @@ +variable "access_key" { + description = "AWS Access Key." +} + +variable "secret_key" { + description = "AWS Secret Key" +} + variable "ami" { default = { us-east-1 = "ami-3acc7a52" @@ -26,4 +34,9 @@ variable "servers" { variable "instance_type" { default = "m1.small" description = "The instance type to launch." +} + +variable "tagName" { + default = "consul" + description = "TName tag for the servers" } \ No newline at end of file