Skip to content

Commit 3b130d6

Browse files
committed
refactor(examples/complete)!: use latest module and sub-module changes
1 parent 92a5d35 commit 3b130d6

File tree

7 files changed

+101
-127
lines changed

7 files changed

+101
-127
lines changed

examples/complete/.header.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# ECS EC2 Complete
2+
3+
Configuration in this directory creates:
4+
5+
- ECS Cluster using self-managed EC2
6+
- ECS Service configured for running Tasks on self-managed EC2
7+
8+
## Usage
9+
10+
To run this example, you will need to execute the commands:
11+
12+
```bash
13+
terraform init
14+
terraform plan
15+
terraform apply
16+
```
17+
18+
Please note that this example may create resources that can incur monetary charges on your AWS bill. You can run `terraform destroy` when you no longer need the resources.

examples/complete/README.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
1-
# ECS EC2 Complete
2-
3-
Configuration in this directory creates:
4-
5-
- ECS Cluster using self-managed EC2
6-
- ECS Service configured for running Tasks on self-managed EC2
7-
8-
## Usage
9-
10-
To run this example, you will need to execute the commands:
11-
12-
```bash
13-
terraform init
14-
terraform plan
15-
terraform apply
16-
```
17-
18-
Please note that this example may create resources that can incur monetary charges on your AWS bill. You can run `terraform destroy` when you no longer need the resources.
191

202
<!-- BEGIN_TF_DOCS -->
213
## Requirements

examples/complete/locals.tf

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
locals {
2+
region = "ap-south-1"
3+
4+
cluster_name = "my-ecs-cluster"
5+
cluster_setting = [
6+
{
7+
name = "containerInsights"
8+
value = "enabled"
9+
}
10+
]
11+
cluster_tags = {
12+
Project = "my-ecs-project"
13+
}
14+
15+
# Autoscaling Group Variables
16+
asg_name = "my-asg"
17+
asg_vpc_zone_identifier = ["subnet-0bf8855a50aa576c7", "subnet-0b7455cf8b3dd6e00"]
18+
asg_desired_capacity = 2
19+
asg_min_size = 1
20+
asg_max_size = 3
21+
asg_instances_tags = {
22+
Name = "my-asg-instance"
23+
}
24+
asg_tags = {
25+
Project = "my-ecs-project"
26+
}
27+
28+
# Launch Template Variables
29+
asg_create_launch_template = true
30+
asg_launch_template = {
31+
image_id = "ami-068e0f1a600cd311c"
32+
instance_type = "t2.micro"
33+
key_name = "test-atlantis"
34+
security_group_ids = []
35+
}
36+
37+
# IAM Role Variables
38+
asg_iam_role_name = "my-asg-role"
39+
asg_iam_role_tags = {
40+
Project = "my-ecs-project"
41+
}
42+
43+
# IAM Instance Profile Variables
44+
asg_iam_instance_profile_name = "my-asg-instance-profile"
45+
asg_iam_instance_profile_tags = {
46+
Project = "my-ecs-project"
47+
}
48+
}

examples/complete/main.tf

Lines changed: 24 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,28 @@
1-
provider "aws" {
2-
region = local.region
3-
4-
default_tags {
5-
tags = local.default_tags
6-
}
7-
}
8-
9-
locals {
10-
region = "ap-south-1"
11-
name_prefix = "ex-"
12-
13-
# VPC
14-
vpc_cidr = "10.0.0.0/16"
15-
vpc_azs = ["ap-south-1a", "ap-south-1b"]
16-
vpc_private_subnets = ["10.0.1.0/24", "10.0.2.0/24"]
17-
vpc_public_subnets = ["10.0.11.0/24", "10.0.12.0/24"]
18-
19-
# ECS Cluster
20-
cluster_name = "${local.name_prefix}my-cluster"
21-
22-
default_tags = {
23-
Environment = "Dev"
24-
ManagedBy = "Terraform"
25-
}
26-
}
27-
28-
################################################################################
29-
# ECS Module
30-
################################################################################
31-
321
module "ecs" {
332
source = "../../"
343

35-
cluster_name = local.cluster_name
36-
37-
setting = [
38-
{
39-
name = "containerInsights"
40-
value = "enabled"
41-
}
42-
]
43-
}
44-
45-
################################################################################
46-
# Supporting Resources
47-
################################################################################
48-
49-
module "vpc" {
50-
source = "terraform-aws-modules/vpc/aws"
51-
version = "~> 5.9.0"
52-
53-
name = "${local.name_prefix}my-vpc"
54-
cidr = local.vpc_cidr
55-
56-
azs = local.vpc_azs
57-
private_subnets = local.vpc_private_subnets
58-
public_subnets = local.vpc_public_subnets
59-
60-
enable_nat_gateway = true
61-
enable_vpn_gateway = false
4+
cluster_name = local.cluster_name
5+
cluster_setting = local.cluster_setting
6+
cluster_tags = local.cluster_tags
7+
8+
# ASG Variables
9+
asg_name = local.asg_name
10+
asg_vpc_zone_identifier = local.asg_vpc_zone_identifier
11+
asg_desired_capacity = local.asg_desired_capacity
12+
asg_min_size = local.asg_min_size
13+
asg_max_size = local.asg_max_size
14+
asg_instances_tags = local.asg_instances_tags
15+
asg_tags = local.asg_tags
16+
17+
# Launch Template
18+
asg_create_launch_template = local.asg_create_launch_template
19+
asg_launch_template = local.asg_launch_template
20+
21+
# IAM Role
22+
asg_iam_role_name = local.asg_iam_role_name
23+
asg_iam_role_tags = local.asg_iam_role_tags
24+
25+
# IAM Instance Profile
26+
asg_iam_instance_profile_name = local.asg_iam_instance_profile_name
27+
asg_iam_instance_profile_tags = local.asg_iam_instance_profile_tags
6228
}

examples/complete/outputs.tf

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,9 @@
1-
################################################################################
2-
# VPC
3-
################################################################################
4-
5-
output "vpc_id" {
6-
description = "Identifier of the VPC"
7-
value = module.vpc.vpc_id
8-
}
9-
10-
output "vpc_cidr_block" {
11-
description = "CIDR Block of the VPC"
12-
value = module.vpc.vpc_cidr_block
13-
}
14-
15-
output "private_subnets" {
16-
description = "Identifiers of the Private Subnets"
17-
value = module.vpc.private_subnets
18-
}
19-
20-
output "private_subnets_arns" {
21-
description = "ARNs of the Private Subnets"
22-
value = module.vpc.private_subnet_arns
23-
}
24-
25-
output "private_subnets_cidr_blocks" {
26-
description = "CIDR Blocks of the Private Subnets"
27-
value = module.vpc.private_subnets_cidr_blocks
28-
}
29-
30-
output "public_subnets" {
31-
description = "Identifiers of the Public Subnets"
32-
value = module.vpc.public_subnets
33-
}
34-
35-
output "public_subnets_arns" {
36-
description = "ARNs of the Public Subnets"
37-
value = module.vpc.public_subnet_arns
38-
}
39-
40-
output "public_subnets_cidr_blocks" {
41-
description = "CIDR Blocks of the Public Subnets"
42-
value = module.vpc.public_subnets_cidr_blocks
1+
output "cluster_arn" {
2+
description = "ARN that identifies the cluster."
3+
value = module.ecs.cluster_arn
434
}
445

45-
################################################################################
46-
# ECS EC2 Module
47-
################################################################################
48-
49-
output "ecs_cluster_arn" {
50-
description = "ARN of the ECS Cluster"
51-
value = module.ecs.cluster_arn
6+
output "cluster_name" {
7+
description = "Name of the ECS Cluster"
8+
value = module.ecs.cluster_name
529
}

examples/complete/provider.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
provider "aws" {
2+
region = local.region
3+
}

examples/complete/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
terraform {
2-
required_version = ">= 1.6.0"
2+
required_version = ">= 1.8.4"
33

44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 5.57.0"
7+
version = ">= 5.51.0"
88
}
99
}
1010
}

0 commit comments

Comments
 (0)