From f3d07dd170e5c55bcf9613e18987138b192cad3d Mon Sep 17 00:00:00 2001 From: UdhavPawar Date: Wed, 15 Sep 2021 16:04:43 -0700 Subject: [PATCH 01/12] config new IGW resource --- terraform/aws/new-igw/main.tf | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 terraform/aws/new-igw/main.tf diff --git a/terraform/aws/new-igw/main.tf b/terraform/aws/new-igw/main.tf new file mode 100644 index 0000000..60b93b3 --- /dev/null +++ b/terraform/aws/new-igw/main.tf @@ -0,0 +1,7 @@ +resource "aws_internet_gateway" "gw" { + vpc_id = aws_vpc.main.id + + tags = { + Name = "main" + } +} \ No newline at end of file From 8d7cf1304b20e5fc010743224a605d88f1d64bb2 Mon Sep 17 00:00:00 2001 From: UdhavPawar Date: Wed, 15 Sep 2021 16:11:54 -0700 Subject: [PATCH 02/12] added VPC ID var for IGW --- terraform/aws/new-igw/main.tf | 8 ++++---- terraform/aws/new-igw/variables.tf | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 terraform/aws/new-igw/variables.tf diff --git a/terraform/aws/new-igw/main.tf b/terraform/aws/new-igw/main.tf index 60b93b3..824d884 100644 --- a/terraform/aws/new-igw/main.tf +++ b/terraform/aws/new-igw/main.tf @@ -1,7 +1,7 @@ -resource "aws_internet_gateway" "gw" { - vpc_id = aws_vpc.main.id +resource "aws_internet_gateway" "demo_gw" { + vpc_id = var.demo_vpc_id - tags = { - Name = "main" + tags { + tool = "terraform" } } \ No newline at end of file diff --git a/terraform/aws/new-igw/variables.tf b/terraform/aws/new-igw/variables.tf new file mode 100644 index 0000000..9daee0c --- /dev/null +++ b/terraform/aws/new-igw/variables.tf @@ -0,0 +1,6 @@ +// note: this variable will be fed with coreos_vpc VPC ID which can be found at terraform/aws/new-vpc/main.tf +variable "demo_vpc_id" { + type = "string" + default = "" + description = "AWS coreos_vpc VPC ID" +} \ No newline at end of file From b6e221fe77b1c4ebc51230bd2785c3dbefcf55b6 Mon Sep 17 00:00:00 2001 From: UdhavPawar Date: Thu, 16 Sep 2021 14:09:12 -0700 Subject: [PATCH 03/12] added NAT GW resource --- terraform/aws/new-natgw/main.tf | 20 ++++++++++++++++++++ terraform/aws/new-natgw/variables.tf | 6 ++++++ 2 files changed, 26 insertions(+) create mode 100644 terraform/aws/new-natgw/main.tf create mode 100644 terraform/aws/new-natgw/variables.tf diff --git a/terraform/aws/new-natgw/main.tf b/terraform/aws/new-natgw/main.tf new file mode 100644 index 0000000..3a39273 --- /dev/null +++ b/terraform/aws/new-natgw/main.tf @@ -0,0 +1,20 @@ +// Create a Elastic IP for NAT GW +resource "aws_eip" "demo_gw_eip" { + vpc = true + tags = { + tool = "terraform" + } +} + +// Create a NAT GW in public1 and public2 subnets +resource "aws_nat_gateway" "ease_prod_vpc_nat_gws" { + count = length(var.ease_prod_vpc_public_subnets) + allocation_id = aws_eip.demo_gw_eip.id + # feed coreos_subnet public subnet ID + subnet_id = var.coreos_subnet_id + + tags = { + tool = "terraform" + } + depends_on = [aws_eip.demo_gw_eip] +} \ No newline at end of file diff --git a/terraform/aws/new-natgw/variables.tf b/terraform/aws/new-natgw/variables.tf new file mode 100644 index 0000000..0ed2833 --- /dev/null +++ b/terraform/aws/new-natgw/variables.tf @@ -0,0 +1,6 @@ +// note: this variable will be fed with coreos_subnet subnet ID which can be found at terraform/aws/new-vpc/main.tf +variable "coreos_subnet_id" { + type = "string" + default = "" + description = "AWS coreos_vpc subnet ID" +} \ No newline at end of file From 6e6942507e69b5bf03b5da135632b9accdfae05d Mon Sep 17 00:00:00 2001 From: UdhavPawar Date: Thu, 16 Sep 2021 14:15:05 -0700 Subject: [PATCH 04/12] added outputs vars --- terraform/aws/new-igw/main.tf | 2 +- terraform/aws/new-igw/output.tf | 3 +++ terraform/aws/new-natgw/main.tf | 3 +-- terraform/aws/new-natgw/output.tf | 3 +++ 4 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 terraform/aws/new-igw/output.tf create mode 100644 terraform/aws/new-natgw/output.tf diff --git a/terraform/aws/new-igw/main.tf b/terraform/aws/new-igw/main.tf index 824d884..831d3bf 100644 --- a/terraform/aws/new-igw/main.tf +++ b/terraform/aws/new-igw/main.tf @@ -1,4 +1,4 @@ -resource "aws_internet_gateway" "demo_gw" { +resource "aws_internet_gateway" "demo_igw" { vpc_id = var.demo_vpc_id tags { diff --git a/terraform/aws/new-igw/output.tf b/terraform/aws/new-igw/output.tf new file mode 100644 index 0000000..3af9e30 --- /dev/null +++ b/terraform/aws/new-igw/output.tf @@ -0,0 +1,3 @@ +output "demo_igw_id" { + value = "${aws_internet_gateway.demo_igw.id}" +} \ No newline at end of file diff --git a/terraform/aws/new-natgw/main.tf b/terraform/aws/new-natgw/main.tf index 3a39273..915a38c 100644 --- a/terraform/aws/new-natgw/main.tf +++ b/terraform/aws/new-natgw/main.tf @@ -7,8 +7,7 @@ resource "aws_eip" "demo_gw_eip" { } // Create a NAT GW in public1 and public2 subnets -resource "aws_nat_gateway" "ease_prod_vpc_nat_gws" { - count = length(var.ease_prod_vpc_public_subnets) +resource "aws_nat_gateway" "demo_natgw" { allocation_id = aws_eip.demo_gw_eip.id # feed coreos_subnet public subnet ID subnet_id = var.coreos_subnet_id diff --git a/terraform/aws/new-natgw/output.tf b/terraform/aws/new-natgw/output.tf new file mode 100644 index 0000000..5d2587f --- /dev/null +++ b/terraform/aws/new-natgw/output.tf @@ -0,0 +1,3 @@ +output "demo_natgw_id" { + value = "${aws_nat_gateway.demo_natgw.id}" +} \ No newline at end of file From 12868566c1d1042eaac3ed6ebedd4f7d7ce2915c Mon Sep 17 00:00:00 2001 From: UdhavPawar Date: Thu, 16 Sep 2021 14:20:12 -0700 Subject: [PATCH 05/12] added S3 resource --- terraform/aws/new-s3/main.tf | 15 +++++++++++++++ terraform/aws/new-s3/output.tf | 3 +++ terraform/aws/new-s3/variables.tf | 5 +++++ 3 files changed, 23 insertions(+) create mode 100644 terraform/aws/new-s3/main.tf create mode 100644 terraform/aws/new-s3/output.tf create mode 100644 terraform/aws/new-s3/variables.tf diff --git a/terraform/aws/new-s3/main.tf b/terraform/aws/new-s3/main.tf new file mode 100644 index 0000000..6e9fa76 --- /dev/null +++ b/terraform/aws/new-s3/main.tf @@ -0,0 +1,15 @@ +// Create a demo S3 bucket +resource "aws_s3_bucket" "demo_s3" { + bucket = var.demo_s3_name + acl = "private" + + # enable versioning on bucket + versioning { + enabled = true + } + + tags = { + Name = "learning-tools" + tools = "terraform" + } +} \ No newline at end of file diff --git a/terraform/aws/new-s3/output.tf b/terraform/aws/new-s3/output.tf new file mode 100644 index 0000000..5b812c3 --- /dev/null +++ b/terraform/aws/new-s3/output.tf @@ -0,0 +1,3 @@ +output "demo_s3_id" { + value = "${aws_s3_bucket.demo_s3.id}" +} \ No newline at end of file diff --git a/terraform/aws/new-s3/variables.tf b/terraform/aws/new-s3/variables.tf new file mode 100644 index 0000000..2db1d36 --- /dev/null +++ b/terraform/aws/new-s3/variables.tf @@ -0,0 +1,5 @@ +variable "demo_s3_name" { + type = "string" + default = "learning-tools-demo-s3" + description = "demo S3 bucket for terraform in learning-tools" +} \ No newline at end of file From 2b6ecf412a5ed5508af586ea37ff668188fdf347 Mon Sep 17 00:00:00 2001 From: UdhavPawar Date: Thu, 16 Sep 2021 14:30:58 -0700 Subject: [PATCH 06/12] added elasticache resource --- terraform/aws/new-elasticache/main.tf | 22 ++++++++++++++++++++++ terraform/aws/new-elasticache/output.tf | 7 +++++++ terraform/aws/new-elasticache/variables.tf | 11 +++++++++++ 3 files changed, 40 insertions(+) create mode 100644 terraform/aws/new-elasticache/main.tf create mode 100644 terraform/aws/new-elasticache/output.tf create mode 100644 terraform/aws/new-elasticache/variables.tf diff --git a/terraform/aws/new-elasticache/main.tf b/terraform/aws/new-elasticache/main.tf new file mode 100644 index 0000000..61d2b84 --- /dev/null +++ b/terraform/aws/new-elasticache/main.tf @@ -0,0 +1,22 @@ +// Create a demo memcached cluster +resource "aws_elasticache_cluster" "demo_elasticache_memcached_cluster" { + cluster_id = var.demo_elasticache_memcached_cluster_name + engine = "memcached" + // Using smallest node type. Refer AWS docs for all supported node types : https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/CacheNodes.SupportedTypes.html + node_type = "cache.t3.micro" + num_cache_nodes = 2 + parameter_group_name = "default.memcached1.4" + port = 11211 +} + +// Create a demo redis cluster +resource "aws_elasticache_cluster" "demo_elasticache_redis_cluster" { + cluster_id = var.demo_elasticache_redis_cluster_name + engine = "redis" + // Using smallest node type. Refer AWS docs for all supported node types : https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/CacheNodes.SupportedTypes.html + node_type = "cache.t3.micro" + num_cache_nodes = 1 + parameter_group_name = "default.redis3.2" + engine_version = "3.2.10" + port = 6379 +} \ No newline at end of file diff --git a/terraform/aws/new-elasticache/output.tf b/terraform/aws/new-elasticache/output.tf new file mode 100644 index 0000000..30299a8 --- /dev/null +++ b/terraform/aws/new-elasticache/output.tf @@ -0,0 +1,7 @@ +output "demo_elasticache_memcached_cluster_name" { + value = "${aws_elasticache_cluster.demo_elasticache_memcached_cluster.cluster_id}" +} + +output "demo_elasticache_redis_cluster_name" { + value = "${aws_elasticache_cluster.demo_elasticache_redis_cluster.cluster_id}" +} \ No newline at end of file diff --git a/terraform/aws/new-elasticache/variables.tf b/terraform/aws/new-elasticache/variables.tf new file mode 100644 index 0000000..2a9f044 --- /dev/null +++ b/terraform/aws/new-elasticache/variables.tf @@ -0,0 +1,11 @@ +variable "demo_elasticache_memcached_cluster_name" { + type = "string" + default = "" + description = "AWS memcached elasticache cluster name" +} + +variable "demo_elasticache_redis_cluster_name" { + type = "string" + default = "" + description = "AWS redis elasticache cluster name" +} \ No newline at end of file From d7e2eea8be020156299c69901e03a55bdc4e5252 Mon Sep 17 00:00:00 2001 From: UdhavPawar Date: Thu, 16 Sep 2021 14:39:34 -0700 Subject: [PATCH 07/12] added beanstalk resource --- terraform/aws/new-beanstalk/main.tf | 11 +++++++++++ terraform/aws/new-beanstalk/outputs.tf | 7 +++++++ terraform/aws/new-beanstalk/variables.tf | 25 ++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 terraform/aws/new-beanstalk/main.tf create mode 100644 terraform/aws/new-beanstalk/outputs.tf create mode 100644 terraform/aws/new-beanstalk/variables.tf diff --git a/terraform/aws/new-beanstalk/main.tf b/terraform/aws/new-beanstalk/main.tf new file mode 100644 index 0000000..1a55091 --- /dev/null +++ b/terraform/aws/new-beanstalk/main.tf @@ -0,0 +1,11 @@ +resource "aws_elastic_beanstalk_application" "demo_beanstalk_application" { + name = var.demo_beanstalk_application_name + description = var.demo_beanstalk_application_description +} + +resource "aws_elastic_beanstalk_environment" "demo_beanstalk_environment" { + name = var.demo_beanstalk_environment_name + application = aws_elastic_beanstalk_application.demo_beanstalk_application.name + // For all supported AWS BeanStalk Platforms / Stacks refer : https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/concepts.platforms.html + solution_stack_name = var.demo_beanstalk_environment_platform +} \ No newline at end of file diff --git a/terraform/aws/new-beanstalk/outputs.tf b/terraform/aws/new-beanstalk/outputs.tf new file mode 100644 index 0000000..2aef4a1 --- /dev/null +++ b/terraform/aws/new-beanstalk/outputs.tf @@ -0,0 +1,7 @@ +output "demo_beanstalk_application_name" { + value = "${aws_elastic_beanstalk_application.demo_beanstalk_application.name}" +} + +output "demo_beanstalk_environment_name" { + value = "${aws_elastic_beanstalk_environment.demo_beanstalk_environment.name}" +} \ No newline at end of file diff --git a/terraform/aws/new-beanstalk/variables.tf b/terraform/aws/new-beanstalk/variables.tf new file mode 100644 index 0000000..c975a3f --- /dev/null +++ b/terraform/aws/new-beanstalk/variables.tf @@ -0,0 +1,25 @@ +// Define application variables +variable "demo_beanstalk_application_name" { + type = "string" + default = "" + description = "AWS beanstalk application name" +} + +variable "demo_beanstalk_application_description" { + type = "string" + default = "" + description = "AWS beanstalk application description" +} + +// Define environment variables +variable "demo_beanstalk_environment_name" { + type = "string" + default = "" + description = "AWS beanstalk environment name" +} + +variable "demo_beanstalk_environment_platform" { + type = "string" + default = "64bit Amazon Linux 2015.03 v2.0.3 running Go 1.4" + description = "AWS beanstalk environment platform" +} \ No newline at end of file From a3f423ce17ce1a3a6395439e34ff2e3db0396367 Mon Sep 17 00:00:00 2001 From: UdhavPawar Date: Mon, 20 Sep 2021 18:01:02 -0700 Subject: [PATCH 08/12] added IGW documentation --- terraform/aws/new-igw/readme.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 terraform/aws/new-igw/readme.md diff --git a/terraform/aws/new-igw/readme.md b/terraform/aws/new-igw/readme.md new file mode 100644 index 0000000..38da0b3 --- /dev/null +++ b/terraform/aws/new-igw/readme.md @@ -0,0 +1,23 @@ +## AWS IGW + +| Provider | Description | +|------|---------| +| aws | This code will create an AWS Internet Gateway | + +## Resources + +| Name | Type | +|------|------| +| [aws_internet_gateway.demo_igw](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/internet_gateway) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| demo_vpc_id | AWS coreos\_vpc VPC ID | `string` | `""` | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| output_demo_igw_id | output IGW resource ID | \ No newline at end of file From 9e549519dc71e8230eb703c97999033ba888b1f2 Mon Sep 17 00:00:00 2001 From: UdhavPawar Date: Mon, 20 Sep 2021 18:05:25 -0700 Subject: [PATCH 09/12] added NAT GW documentation --- terraform/aws/new-natgw/readme.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 terraform/aws/new-natgw/readme.md diff --git a/terraform/aws/new-natgw/readme.md b/terraform/aws/new-natgw/readme.md new file mode 100644 index 0000000..34582ea --- /dev/null +++ b/terraform/aws/new-natgw/readme.md @@ -0,0 +1,24 @@ +## AWS NAT GW + +| Provider | Description | +|------|---------| +| aws | This code will create an AWS NAT Gateway | + +## Resources + +| Name | Type | +|------|------| +| [aws_eip.demo_gw_eip](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eip) | resource | +| [aws_nat_gateway.demo_natgw](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/nat_gateway) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| coreos_subnet_id | AWS coreos\_vpc subnet ID | `string` | `""` | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| output_demo_natgw_id | output NAT GW resource ID | \ No newline at end of file From 0aca60789d9d9021576b00f8a2f271c6c7293b52 Mon Sep 17 00:00:00 2001 From: UdhavPawar Date: Mon, 20 Sep 2021 18:08:48 -0700 Subject: [PATCH 10/12] added S3 documentation --- terraform/aws/new-s3/readme.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 terraform/aws/new-s3/readme.md diff --git a/terraform/aws/new-s3/readme.md b/terraform/aws/new-s3/readme.md new file mode 100644 index 0000000..2df468b --- /dev/null +++ b/terraform/aws/new-s3/readme.md @@ -0,0 +1,23 @@ +## AWS S3 + +| Provider | Description | +|------|---------| +| aws | This code will create an AWS S3 bucket | + +## Resources + +| Name | Type | +|------|------| +| [aws_s3_bucket.demo_s3](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| demo_s3_name | demo S3 bucket for terraform in learning-tools | `string` | `"learning-tools-demo-s3"` | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| output_demo_s3_id | output S3 bucket resource ID | \ No newline at end of file From 22516a833717eed8a075195245118692a1d38375 Mon Sep 17 00:00:00 2001 From: UdhavPawar Date: Mon, 20 Sep 2021 18:12:42 -0700 Subject: [PATCH 11/12] added elasticache documentation --- terraform/aws/new-elasticache/readme.md | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 terraform/aws/new-elasticache/readme.md diff --git a/terraform/aws/new-elasticache/readme.md b/terraform/aws/new-elasticache/readme.md new file mode 100644 index 0000000..2573f9e --- /dev/null +++ b/terraform/aws/new-elasticache/readme.md @@ -0,0 +1,26 @@ +## AWS Elasticache + +| Provider | Description | +|------|---------| +| aws | This code will create AWS Elasticache memcached and redis clusters | + +## Resources + +| Name | Type | +|------|------| +| [aws_elasticache_cluster.demo_elasticache_memcached_cluster](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_cluster) | resource | +| [aws_elasticache_cluster.demo_elasticache_redis_cluster](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_cluster) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| demo_elasticache_memcached_cluster_name | AWS memcached elasticache cluster name | `string` | `""` | yes | +| demo_elasticache_redis_cluster_name | AWS redis elasticache cluster name | `string` | `""` | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| demo_elasticache_memcached_cluster_name | output memcached elasticache cluster name | +| demo_elasticache_redis_cluster_name | output redis elasticache cluster name | \ No newline at end of file From 2d511ab650176bc8fcca237f1452af1324ee9db8 Mon Sep 17 00:00:00 2001 From: UdhavPawar Date: Mon, 20 Sep 2021 18:17:13 -0700 Subject: [PATCH 12/12] added beanstalk documentation --- terraform/aws/new-beanstalk/readme.md | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 terraform/aws/new-beanstalk/readme.md diff --git a/terraform/aws/new-beanstalk/readme.md b/terraform/aws/new-beanstalk/readme.md new file mode 100644 index 0000000..1571ec3 --- /dev/null +++ b/terraform/aws/new-beanstalk/readme.md @@ -0,0 +1,28 @@ +## AWS BeanStalk + +| Provider | Description | +|------|---------| +| aws | This code will create AWS BeanStalk application and environment | + +## Resources + +| Name | Type | +|------|------| +| [aws_elastic_beanstalk_application.demo_beanstalk_application](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elastic_beanstalk_application) | resource | +| [aws_elastic_beanstalk_environment.demo_beanstalk_environment](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elastic_beanstalk_environment) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| demo_beanstalk_application_name | AWS beanstalk application name | `string` | `""` | yes | +| demo_beanstalk_application_description | AWS beanstalk application description | `string` | `""` | no | +| demo_beanstalk_environment_name | AWS beanstalk environment name | `string` | `""` | yes | +| demo_beanstalk_environment_platform | AWS beanstalk environment platform | `string` | `"64bit Amazon Linux 2015.03 v2.0.3 running Go 1.4"` | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| demo_beanstalk_application_name | output beanstalk application name | +| demo_beanstalk_environment_name | output beanstalk environment name | \ No newline at end of file