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
+5 -4
View File
@@ -15,15 +15,16 @@ data "aws_ami" "ubuntu" {
}
resource "aws_instance" "example" {
ami = "${data.aws_ami.ubuntu.id}"
ami = data.aws_ami.ubuntu.id
instance_type = "t2.micro"
# the VPC subnet
subnet_id = "${var.ENV == "prod" ? module.vpc-prod.public_subnets[0] : module.vpc-dev.public_subnets[0] }"
subnet_id = var.ENV == "prod" ? module.vpc-prod.public_subnets[0] : module.vpc-dev.public_subnets[0]
# the security group
vpc_security_group_ids = ["${var.ENV == "prod" ? aws_security_group.allow-ssh-prod.id : aws_security_group.allow-ssh-dev.id }"]
vpc_security_group_ids = [var.ENV == "prod" ? aws_security_group.allow-ssh-prod.id : aws_security_group.allow-ssh-dev.id]
# the public SSH key
key_name = "${aws_key_pair.mykeypair.key_name}"
key_name = aws_key_pair.mykeypair.key_name
}
+2 -1
View File
@@ -1,4 +1,5 @@
resource "aws_key_pair" "mykeypair" {
key_name = "mykeypair"
public_key = "${file("${var.PATH_TO_PUBLIC_KEY}")}"
public_key = file(var.PATH_TO_PUBLIC_KEY)
}
+2 -1
View File
@@ -1,3 +1,4 @@
provider "aws" {
region = "${var.AWS_REGION}"
region = var.AWS_REGION
}
+5 -4
View File
@@ -1,5 +1,5 @@
resource "aws_security_group" "allow-ssh-prod" {
vpc_id = "${module.vpc-prod.vpc_id}"
vpc_id = module.vpc-prod.vpc_id
name = "allow-ssh"
description = "security group that allows ssh and all egress traffic"
@@ -17,13 +17,13 @@ resource "aws_security_group" "allow-ssh-prod" {
cidr_blocks = ["0.0.0.0/0"]
}
tags {
tags = {
Name = "allow-ssh"
}
}
resource "aws_security_group" "allow-ssh-dev" {
vpc_id = "${module.vpc-dev.vpc_id}"
vpc_id = module.vpc-dev.vpc_id
name = "allow-ssh"
description = "security group that allows ssh and all egress traffic"
@@ -41,7 +41,8 @@ resource "aws_security_group" "allow-ssh-dev" {
cidr_blocks = ["0.0.0.0/0"]
}
tags {
tags = {
Name = "allow-ssh"
}
}
+1
View File
@@ -13,3 +13,4 @@ variable "PATH_TO_PUBLIC_KEY" {
variable "ENV" {
default = "prod"
}
+4
View File
@@ -0,0 +1,4 @@
terraform {
required_version = ">= 0.12"
}
+5 -2
View File
@@ -1,5 +1,6 @@
module "vpc-prod" {
source = "terraform-aws-modules/vpc/aws"
source = "terraform-aws-modules/vpc/aws"
version = "2.5.0"
name = "vpc-prod"
cidr = "10.0.0.0/16"
@@ -18,7 +19,8 @@ module "vpc-prod" {
}
module "vpc-dev" {
source = "terraform-aws-modules/vpc/aws"
source = "terraform-aws-modules/vpc/aws"
version = "2.5.0"
name = "vpc-dev"
cidr = "10.0.0.0/16"
@@ -35,3 +37,4 @@ module "vpc-dev" {
Environment = "dev"
}
}