Added tags for EC2 instances

This commit is contained in:
Sathiya Shunmugasundaram 2015-05-20 20:38:42 -04:00
parent 87a583492d
commit f052b7c3df
2 changed files with 14 additions and 22 deletions

View file

@ -1,10 +1,3 @@
# 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}"
@ -17,6 +10,11 @@ resource "aws_instance" "server" {
key_file = "${var.key_path}"
}
#Instance tags
tags {
Name = "${var.tagName}-${count.index}"
}
provisioner "file" {
source = "${path.module}/scripts/upstart.conf"
destination = "/tmp/upstart.conf"
@ -41,11 +39,6 @@ resource "aws_instance" "server" {
"${path.module}/scripts/service.sh",
]
}
#Instance tags
tags {
Name = "${var.tagName}-${count.index}"
}
}
resource "aws_security_group" "consul" {
@ -74,4 +67,12 @@ 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"]
}
}

View file

@ -1,11 +1,3 @@
variable "access_key" {
description = "AWS Access Key."
}
variable "secret_key" {
description = "AWS Secret Key"
}
variable "ami" {
default = {
us-east-1 = "ami-3acc7a52"
@ -35,7 +27,6 @@ variable "instance_type" {
default = "m1.small"
description = "The instance type to launch."
}
variable "tagName" {
default = "consul"
description = "Name tag for the servers"