From 90e4015ddf8fb8e5874f97cac81d70fdc96461a2 Mon Sep 17 00:00:00 2001 From: Jonathan Simon Date: Sun, 17 Nov 2019 22:21:02 -0800 Subject: [PATCH] init - adding some terraform for AWS --- terraform/aws/vpc/main.tf | 23 +++++++++++++++++++++++ terraform/aws/vpc/provider.tf | 17 +++++++++++++++++ terraform/aws/vpc/variables.tf | 20 ++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 terraform/aws/vpc/main.tf create mode 100644 terraform/aws/vpc/provider.tf create mode 100644 terraform/aws/vpc/variables.tf diff --git a/terraform/aws/vpc/main.tf b/terraform/aws/vpc/main.tf new file mode 100644 index 0000000..d6c8025 --- /dev/null +++ b/terraform/aws/vpc/main.tf @@ -0,0 +1,23 @@ +locals { + environment = "${terraform.workspace == "default" ? "dev" : terraform.workspace}" +} + +module "vpc" { + source = "terraform-aws-modules/vpc/aws" + + name = "${var.prefix}-${var.name}" + cidr = "10.0.0.0/16" + + azs = ["us-west-2a", "us-west-2b", "us-west-2c"] + private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"] + public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"] + + enable_nat_gateway = true + single_nat_gateway = true + + tags = { + Name = "${var.prefix}-${var.name}" + Terraform = "true" + Environment = "${local.environment}" + } +} diff --git a/terraform/aws/vpc/provider.tf b/terraform/aws/vpc/provider.tf new file mode 100644 index 0000000..b703bcf --- /dev/null +++ b/terraform/aws/vpc/provider.tf @@ -0,0 +1,17 @@ +provider "aws" { + version = "~> 2.0" + region = "us-west-2" + access_key = "${var.aws_access_key}" + secret_key = "${var.aws_secret_key}" +} + +terraform { + backend "remote" { + hostname = "app.terraform.io" + organization = "jibakurei" + + workspaces { + prefix = "kthw-" + } + } +} diff --git a/terraform/aws/vpc/variables.tf b/terraform/aws/vpc/variables.tf new file mode 100644 index 0000000..96cc388 --- /dev/null +++ b/terraform/aws/vpc/variables.tf @@ -0,0 +1,20 @@ +variable "aws_access_key" {} +variable "aws_secret_key" {} + +variable "name" { + type = string + description = "The name that will be tagged on all the AWS resources" + default = "tfcloud" +} + +variable "prefix" { + type = string + description = "The prefix to add the name" + default = "jibakurei" +} + +variable "prefix" { + type = string + description = "The prefix to add the name" + default = "jibakurei" +}