Skip to content

Commit 7ab8b13

Browse files
committed
adding ec2
1 parent ad2c785 commit 7ab8b13

File tree

11 files changed

+64
-79
lines changed

11 files changed

+64
-79
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,12 @@ No resources.
146146

147147
## Outputs
148148

149-
No outputs.
149+
| Name | Description |
150+
|------|-------------|
151+
| <a name="output_ecs_cluster_name"></a> [ecs\_cluster\_name](#output\_ecs\_cluster\_name) | The name of the ECS cluster |
152+
| <a name="output_ecs_service_arn"></a> [ecs\_service\_arn](#output\_ecs\_service\_arn) | The ARN of the ECS service |
153+
| <a name="output_ecs_service_name"></a> [ecs\_service\_name](#output\_ecs\_service\_name) | The name of the ECS service |
154+
| <a name="output_ecs_task_definition_arn"></a> [ecs\_task\_definition\_arn](#output\_ecs\_task\_definition\_arn) | The ARN of the ECS task definition |
150155
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
151156

152157
## Development

examples/ecs-ec2/main.tf

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ module "tags" {
3030

3131
module "ecs_cluster" {
3232
source = "../../"
33-
# for_each = local.ecs_services
3433

3534
ecs_cluster = local.ecs_cluster
3635
capacity_provider = local.capacity_provider
@@ -40,24 +39,6 @@ module "ecs_cluster" {
4039
tags = module.tags.tags
4140
}
4241

43-
# module "ecs_cluster" {
44-
# source = "../../"
45-
# for_each = local.ecs_services
46-
47-
# ecs_cluster = local.ecs_cluster
48-
# capacity_provider = local.capacity_provider
49-
# launch_template = local.launch_template
50-
# asg = local.asg
51-
# ecs_service = each.value.ecs_service
52-
# task = each.value.task
53-
# lb_data = each.value.lb_data
54-
# vpc_id = data.aws_vpc.default.id
55-
# target_group_arn = module.alb.target_group_arn
56-
# environment = var.environment
57-
# tags = module.tags.tags
58-
# depends_on = [module.alb]
59-
# }
60-
6142
module "ecs_services" {
6243
for_each = local.ecs_services
6344

examples/ecs-ec2/outputs.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
output "ecs_cluster_name" {
2+
description = "The name of the ECS cluster"
3+
value = module.ecs_cluster.ecs_cluster_name
4+
}
5+
6+
output "ecs_service_name" {
7+
description = "The name of the ECS service"
8+
value = module.ecs_services.service_name
9+
}
10+
11+
output "ecs_service_arn" {
12+
description = "The ARN of the ECS service"
13+
value = module.ecs_services.ecs_service_arn
14+
}
15+
16+
output "ecs_task_definition_arn" {
17+
description = "The ARN of the ECS task definition"
18+
value = module.ecs_services.ecs_task_definition_arn
19+
}

examples/ecs-fargate/locals.tf

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ locals {
5959
container_definition = "container/container_definition.json.tftpl"
6060
}
6161

62-
lb = {
63-
name = "arc-load-balancer"
62+
lb_data = {
6463
listener_port = 80
6564
security_group_id = "sg-023e8f71ae18450ff"
6665
}
@@ -91,8 +90,7 @@ locals {
9190
container_definition = "container/container_definition.json.tftpl"
9291
}
9392

94-
lb = {
95-
name = "arc-load-balancer"
93+
lb_data = {
9694
listener_port = 80
9795
security_group_id = "sg-023e8f71ae18450ff"
9896
}

examples/ecs-fargate/main.tf

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,6 @@ module "tags" {
2828
}
2929
}
3030

31-
# module "ecs_cluster" {
32-
# source = "../../"
33-
34-
# ecs_cluster = local.ecs_cluster
35-
# capacity_provider = local.capacity_provider
36-
# environment = var.environment
37-
# ecs_service = local.ecs_service
38-
# task = local.task
39-
# lb = local.lb
40-
# vpc_id = data.aws_vpc.default.id
41-
# alb_name = local.load_balancer_config.name
42-
# target_group_arn = module.alb.target_group_arn
43-
# tags = module.tags.tags
44-
# depends_on = [module.alb]
45-
# }
46-
4731

4832
module "ecs_cluster" {
4933
source = "../../"
@@ -62,7 +46,7 @@ module "ecs_services" {
6246
ecs_cluster_name = local.ecs_cluster.name
6347
ecs_service = each.value.ecs_service
6448
task = each.value.task
65-
lb = each.value.lb
49+
lb_data = each.value.lb_data
6650
vpc_id = data.aws_vpc.default.id
6751
target_group_arn = module.alb.target_group_arn
6852
environment = var.environment

main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ module "ecs_service" {
3737
target_group_arn = var.target_group_arn
3838

3939
ecs_service = {
40-
# cluster_name = module.ecs_cluster[0].ecs_cluster.name
4140
cluster_name = var.ecs_cluster_name
4241
service_name = var.ecs_service.service_name
4342
repository_name = var.ecs_service.repository_name

modules/ecs-cluster/main.tf

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,6 @@ terraform {
1212
}
1313
}
1414

15-
########################################################################
16-
# CloudWatch Log Group
17-
########################################################################
18-
# resource "aws_cloudwatch_log_group" "this" {
19-
# count = var.ecs_cluster.create_cloudwatch_log_group ? 1 : 0
20-
21-
# name = var.ecs_cluster.configuration.execute_command_configuration.log_configuration.log_group_name != null ? var.ecs_cluster.configuration.execute_command_configuration.log_configuration.log_group_name : "/aws/ecs/${var.ecs_cluster.name}"
22-
23-
# retention_in_days = var.ecs_cluster.configuration.execute_command_configuration.log_configuration.log_group_retention_in_days
24-
# kms_key_id = var.ecs_cluster.configuration.execute_command_configuration.log_configuration.log_group_kms_key_id
25-
26-
# tags = merge(var.tags, var.ecs_cluster.configuration.execute_command_configuration.log_configuration.log_group_tags)
27-
# }
28-
29-
3015
########################################################################
3116
# ECS Cluster
3217
########################################################################

modules/ecs-cluster/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ output "ecs_cluster" {
44
id = aws_ecs_cluster.this.id
55
}
66
}
7+
8+
output "launch_template_id" {
9+
description = "The ID of the EC2 launch template"
10+
value = var.capacity_provider.use_fargate ? null : aws_launch_template.this[0].id
11+
}

modules/ecs-service/outputs.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,18 @@ output "service_name" {
22
description = "The name of the ECS service."
33
value = aws_ecs_service.this.name
44
}
5+
6+
output "ecs_task_definition_arn" {
7+
description = "The ARN of the ECS task definition"
8+
value = aws_ecs_task_definition.this.arn
9+
}
10+
11+
output "ecs_task_role_arn" {
12+
description = "The ARN of the IAM role assigned to the ECS task"
13+
value = aws_iam_role.task_role.arn
14+
}
15+
16+
output "ecs_service_arn" {
17+
description = "The ARN of the ECS service"
18+
value = aws_ecs_service.this.id
19+
}

outputs.tf

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# output "ecs_cluster_name" {
2-
# description = "The name of the ECS cluster."
3-
# value = module.ecs_cluster[0].ecs_cluster.name
4-
# }
1+
output "ecs_cluster_name" {
2+
description = "The name of the ECS cluster"
3+
value = module.ecs_cluster[0].ecs_cluster
4+
}
55

6-
# output "alb_name" {
7-
# description = "The names of the ALBs."
8-
# value = [for alb in module.alb : alb.alb.name]
9-
# }
6+
output "ecs_service_name" {
7+
description = "The name of the ECS service"
8+
value = module.ecs_service[0].service_name
9+
}
1010

11-
# output "ecs_service_name" {
12-
# description = "The service names of the ECS services."
13-
# value = module.ecs_service[*].service_name
14-
# }
11+
output "ecs_service_arn" {
12+
description = "The ARN of the ECS service"
13+
value = module.ecs_service[0].ecs_service_arn
14+
}
1515

16-
# output "ecs_task_definition_arn" {
17-
# description = "The ARNs of the ECS task definitions."
18-
# value = module.ecs_service[*].task_definition_arn
19-
# }
16+
output "ecs_task_definition_arn" {
17+
description = "The ARN of the ECS task definition"
18+
value = module.ecs_service[0].ecs_task_definition_arn
19+
}

0 commit comments

Comments
 (0)