Added tags for EC2 instances
This commit is contained in:
parent
87a583492d
commit
f052b7c3df
|
@ -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" {
|
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}"
|
||||||
|
@ -17,6 +10,11 @@ resource "aws_instance" "server" {
|
||||||
key_file = "${var.key_path}"
|
key_file = "${var.key_path}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#Instance tags
|
||||||
|
tags {
|
||||||
|
Name = "${var.tagName}-${count.index}"
|
||||||
|
}
|
||||||
|
|
||||||
provisioner "file" {
|
provisioner "file" {
|
||||||
source = "${path.module}/scripts/upstart.conf"
|
source = "${path.module}/scripts/upstart.conf"
|
||||||
destination = "/tmp/upstart.conf"
|
destination = "/tmp/upstart.conf"
|
||||||
|
@ -41,11 +39,6 @@ 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" {
|
||||||
|
@ -74,4 +67,12 @@ 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"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,3 @@
|
||||||
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"
|
||||||
|
@ -35,8 +27,7 @@ variable "instance_type" {
|
||||||
default = "m1.small"
|
default = "m1.small"
|
||||||
description = "The instance type to launch."
|
description = "The instance type to launch."
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "tagName" {
|
variable "tagName" {
|
||||||
default = "consul"
|
default = "consul"
|
||||||
description = "Name tag for the servers"
|
description = "Name tag for the servers"
|
||||||
}
|
}
|
Loading…
Reference in a new issue