File tree Expand file tree Collapse file tree 4 files changed +25
-1
lines changed Expand file tree Collapse file tree 4 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,23 @@ module "ecr" {
5555}
5656```
5757
58+ ### Use an external ECS Task definition
59+
60+ ``` hcl
61+ module "ecr" {
62+ source = "tbobm/ecs/aws"
63+ # version = "" use latest version
64+
65+ ecs_values = {
66+ ecs_task_arn = "arn:aws:ecs:<region>:<aws_account_id>:task-definition/<task_family>:1"
67+ }
68+ networking = {
69+ vpc_id = "vpc-xxxxxxxx"
70+ subnet_ids = ["subnet-xxxxxxxx"]
71+ }
72+ }
73+ ```
74+
5875## Doc generation
5976
6077Code formatting and documentation for variables and outputs is generated using
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ resource "aws_ecs_cluster" "this" {
99}
1010
1111resource "aws_ecs_task_definition" "this" {
12+ count = lookup (local. ecs , " ecs_task_arn" , " " ) != " " ? 0 : 1
13+
1214 family = " service"
1315 requires_compatibilities = [
1416 " FARGATE" ,
@@ -36,7 +38,7 @@ resource "aws_ecs_task_definition" "this" {
3638resource "aws_ecs_service" "this" {
3739 name = local. ecs . service_name
3840 cluster = aws_ecs_cluster. this . id
39- task_definition = aws_ecs_task_definition. this . arn
41+ task_definition = lookup (local . ecs , " ecs_task_arn " , " " ) != " " ? local . ecs . ecs_task_arn : aws_ecs_task_definition. this . 0 . arn
4042 desired_count = 1
4143
4244 network_configuration {
Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ module "ecs" {
1010 subnet_ids = data.aws_subnet_ids.this.ids
1111 }
1212
13+ ecs_values = {
14+ ecs_task_arn = " "
15+ }
16+
1317 addons = {
1418 loadbalancer = {
1519 enable = true
Original file line number Diff line number Diff line change 88 ecs_defaults = {
99 cluster_name = " ecs-cluster"
1010 service_name = " ecs-service"
11+ ecs_task_arn = null
1112 }
1213 ecs = merge (local. ecs_defaults , var. ecs_values )
1314
You can’t perform that action at this time.
0 commit comments