Terraform 0.12 (#20)

* Terraform 0.12
This commit is contained in:
Edward Viaene
2019-10-06 13:46:10 +02:00
committed by GitHub
parent 9e31795a58
commit 5d9eeb6c4c
201 changed files with 2528 additions and 2006 deletions
+17 -14
View File
@@ -1,14 +1,16 @@
variable "ENV" {}
variable "ENV" {
}
variable "INSTANCE_TYPE" {
default = "t2.micro"
}
variable "PUBLIC_SUBNETS" {
type = "list"
type = list
}
variable "VPC_ID" {}
variable "VPC_ID" {
}
variable "PATH_TO_PUBLIC_KEY" {
default = "mykey.pub"
@@ -31,26 +33,26 @@ data "aws_ami" "ubuntu" {
}
resource "aws_instance" "instance" {
ami = "${data.aws_ami.ubuntu.id}"
instance_type = "${var.INSTANCE_TYPE}"
ami = data.aws_ami.ubuntu.id
instance_type = var.INSTANCE_TYPE
# the VPC subnet
subnet_id = "${var.PUBLIC_SUBNETS[0]}"
subnet_id = element(var.PUBLIC_SUBNETS, 0)
# the security group
vpc_security_group_ids = ["${aws_security_group.allow-ssh.id}"]
vpc_security_group_ids = [aws_security_group.allow-ssh.id]
# the public SSH key
key_name = "${aws_key_pair.mykeypair.key_name}"
key_name = aws_key_pair.mykeypair.key_name
tags {
tags = {
Name = "instance-${var.ENV}"
Environmnent = "${var.ENV}"
Environmnent = var.ENV
}
}
resource "aws_security_group" "allow-ssh" {
vpc_id = "${var.VPC_ID}"
vpc_id = var.VPC_ID
name = "allow-ssh-${var.ENV}"
description = "security group that allows ssh and all egress traffic"
@@ -68,13 +70,14 @@ resource "aws_security_group" "allow-ssh" {
cidr_blocks = ["0.0.0.0/0"]
}
tags {
tags = {
Name = "allow-ssh"
Environmnent = "${var.ENV}"
Environmnent = var.ENV
}
}
resource "aws_key_pair" "mykeypair" {
key_name = "mykeypair-${var.ENV}"
public_key = "${file("${path.root}/${var.PATH_TO_PUBLIC_KEY}")}"
public_key = file("${path.root}/${var.PATH_TO_PUBLIC_KEY}")
}
+4
View File
@@ -0,0 +1,4 @@
terraform {
required_version = ">= 0.12"
}
+4
View File
@@ -0,0 +1,4 @@
terraform {
required_version = ">= 0.12"
}
+10 -6
View File
@@ -1,5 +1,8 @@
variable "ENV" {}
variable "AWS_REGION" {}
variable "ENV" {
}
variable "AWS_REGION" {
}
module "main-vpc" {
source = "terraform-aws-modules/vpc/aws"
@@ -16,21 +19,22 @@ module "main-vpc" {
tags = {
Terraform = "true"
Environment = "${var.ENV}"
Environment = var.ENV
}
}
output "vpc_id" {
description = "The ID of the VPC"
value = "${module.main-vpc.vpc_id}"
value = module.main-vpc.vpc_id
}
output "private_subnets" {
description = "List of IDs of private subnets"
value = ["${module.main-vpc.private_subnets}"]
value = module.main-vpc.private_subnets
}
output "public_subnets" {
description = "List of IDs of public subnets"
value = ["${module.main-vpc.public_subnets}"]
value = module.main-vpc.public_subnets
}