Added access/secret key variables and added Tag to instances, removed egress section since it comes by default
This commit is contained in:
parent
2fb1bc931e
commit
d93b7128d6
|
@ -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"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
Loading…
Reference in New Issue