Added access/secret key variables and added Tag to instances, removed egress section since it comes by default

This commit is contained in:
Sathiya Shunmugasundaram 2015-05-09 16:50:11 -04:00
parent 2fb1bc931e
commit d93b7128d6
2 changed files with 25 additions and 8 deletions

View File

@ -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" { resource "aws_instance" "server" {
ami = "${lookup(var.ami, var.region)}" ami = "${lookup(var.ami, var.region)}"
instance_type = "${var.instance_type}" instance_type = "${var.instance_type}"
@ -34,6 +41,11 @@ resource "aws_instance" "server" {
"${path.module}/scripts/service.sh", "${path.module}/scripts/service.sh",
] ]
} }
#Instance tags
tags {
Name = "${var.tagName}-${count.index}"
}
} }
resource "aws_security_group" "consul" { resource "aws_security_group" "consul" {
@ -62,12 +74,4 @@ resource "aws_security_group" "consul" {
protocol = "tcp" protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"] 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"]
}
} }

View File

@ -1,3 +1,11 @@
variable "access_key" {
description = "AWS Access Key."
}
variable "secret_key" {
description = "AWS Secret Key"
}
variable "ami" { variable "ami" {
default = { default = {
us-east-1 = "ami-3acc7a52" us-east-1 = "ami-3acc7a52"
@ -26,4 +34,9 @@ variable "servers" {
variable "instance_type" { variable "instance_type" {
default = "m1.small" default = "m1.small"
description = "The instance type to launch." description = "The instance type to launch."
}
variable "tagName" {
default = "consul"
description = "TName tag for the servers"
} }