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/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 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 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/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 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 diff --git a/terraform/aws/new-igw/main.tf b/terraform/aws/new-igw/main.tf new file mode 100644 index 0000000..831d3bf --- /dev/null +++ b/terraform/aws/new-igw/main.tf @@ -0,0 +1,7 @@ +resource "aws_internet_gateway" "demo_igw" { + vpc_id = var.demo_vpc_id + + tags { + tool = "terraform" + } +} \ No newline at end of file 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-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 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 diff --git a/terraform/aws/new-natgw/main.tf b/terraform/aws/new-natgw/main.tf new file mode 100644 index 0000000..915a38c --- /dev/null +++ b/terraform/aws/new-natgw/main.tf @@ -0,0 +1,19 @@ +// 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" "demo_natgw" { + 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/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 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 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 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/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 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