Skip to content

Commit 88dfdde

Browse files
author
Abdul Wahid
authored
Refactor examples to work with provider 4.0.0+ (#53)
1 parent 466529d commit 88dfdde

File tree

8 files changed

+65
-45
lines changed

8 files changed

+65
-45
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.0.1
3+
rev: v4.1.0
44
hooks:
55
- id: check-added-large-files
66
args: ['--maxkb=500']
@@ -18,7 +18,7 @@ repos:
1818
args: ['--allow-missing-credentials']
1919
- id: trailing-whitespace
2020
- repo: git://github.com/antonbabenko/pre-commit-terraform
21-
rev: v1.61.0
21+
rev: v1.64.0
2222
hooks:
2323
- id: terraform_fmt
2424
- id: terraform_docs

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
<a name="unreleased"></a>
66
## [Unreleased]
77

8-
- fix: setting task_health_command to null
8+
- fix: setting `task_health_command` to null ([#49](https://github.com/umotif-public/terraform-aws-ecs-fargate/issues/49))
99

1010

1111
<a name="6.4.1"></a>

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<!-- markdownlint-disable MD041 -->
2-
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/umotif-public/terraform-aws-ecs-fargate?style=social)](https://github.com/umotif-public/terraform-aws-ecs-fargate/releases/latest)
1+
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/umotif-public/terraform-aws-ecs-fargate)](https://github.com/umotif-public/terraform-aws-ecs-fargate/releases/latest)
32

43
# Terraform AWS ECS Fargate
54

@@ -17,16 +16,20 @@ Terraform 0.13. Pin module version to `~> v6.0`. Submit pull-requests to `master
1716
resource "aws_ecs_cluster" "cluster" {
1817
name = "example-ecs-cluster"
1918
19+
setting {
20+
name = "containerInsights"
21+
value = "disabled"
22+
}
23+
}
24+
25+
resource "aws_ecs_cluster_capacity_providers" "cluster" {
26+
cluster_name = aws_ecs_cluster.cluster.name
27+
2028
capacity_providers = ["FARGATE_SPOT", "FARGATE"]
2129
2230
default_capacity_provider_strategy {
2331
capacity_provider = "FARGATE_SPOT"
2432
}
25-
26-
setting {
27-
name = "containerInsights"
28-
value = "disabled"
29-
}
3033
}
3134
3235
module "ecs-fargate" {
@@ -81,7 +84,7 @@ Module managed by [Marcin Cuber](https://github.com/marcincuber) [LinkedIn](http
8184

8285
| Name | Version |
8386
|------|---------|
84-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
87+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.7 |
8588
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.34 |
8689

8790
## Providers

examples/core/main.tf

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ data "aws_vpc" "default" {
99
default = true
1010
}
1111

12-
data "aws_subnet_ids" "all" {
13-
vpc_id = data.aws_vpc.default.id
12+
data "aws_subnets" "all" {
13+
filter {
14+
name = "vpc-id"
15+
values = [data.aws_vpc.default.id]
16+
}
1417
}
1518

1619
#####
@@ -24,7 +27,7 @@ module "alb" {
2427
load_balancer_type = "application"
2528
internal = false
2629
vpc_id = data.aws_vpc.default.id
27-
subnets = data.aws_subnet_ids.all.ids
30+
subnets = data.aws_subnets.all.ids
2831
}
2932

3033
resource "aws_lb_listener" "alb_80" {
@@ -87,7 +90,7 @@ module "fargate" {
8790
# sg_name_prefix = "my-security-group-name" # uncomment if you want to name security group with specific name
8891

8992
vpc_id = data.aws_vpc.default.id
90-
private_subnet_ids = data.aws_subnet_ids.all.ids
93+
private_subnet_ids = data.aws_subnets.all.ids
9194
cluster_id = aws_ecs_cluster.cluster.id
9295

9396
wait_for_steady_state = true
@@ -108,10 +111,6 @@ module "fargate" {
108111
}
109112
]
110113

111-
task_health_check = {
112-
timeout = 60
113-
}
114-
115114
health_check = {
116115
port = "traffic-port"
117116
path = "/"

examples/fargate-efs/main.tf

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ data "aws_vpc" "default" {
99
default = true
1010
}
1111

12-
data "aws_subnet_ids" "all" {
13-
vpc_id = data.aws_vpc.default.id
12+
data "aws_subnets" "all" {
13+
filter {
14+
name = "vpc-id"
15+
values = [data.aws_vpc.default.id]
16+
}
1417
}
1518

1619
#####
@@ -24,7 +27,7 @@ module "alb" {
2427
load_balancer_type = "application"
2528
internal = false
2629
vpc_id = data.aws_vpc.default.id
27-
subnets = data.aws_subnet_ids.all.ids
30+
subnets = data.aws_subnets.all.ids
2831
}
2932

3033
resource "aws_lb_listener" "alb_80" {
@@ -75,25 +78,29 @@ resource "aws_efs_file_system" "efs" {
7578
# ECS cluster and fargate
7679
#####
7780
resource "aws_ecs_cluster" "cluster" {
78-
name = "ecs-spot-test"
81+
name = "ecs-spot-test"
82+
setting {
83+
name = "containerInsights"
84+
value = "disabled"
85+
}
86+
}
87+
88+
resource "aws_ecs_cluster_capacity_providers" "cluster" {
89+
cluster_name = aws_ecs_cluster.cluster.name
90+
7991
capacity_providers = ["FARGATE_SPOT", "FARGATE"]
8092

8193
default_capacity_provider_strategy {
8294
capacity_provider = "FARGATE_SPOT"
8395
}
84-
85-
setting {
86-
name = "containerInsights"
87-
value = "disabled"
88-
}
8996
}
9097

9198
module "fargate" {
9299
source = "../../"
93100

94101
name_prefix = "ecs-fargate-example"
95102
vpc_id = data.aws_vpc.default.id
96-
private_subnet_ids = data.aws_subnet_ids.all.ids
103+
private_subnet_ids = data.aws_subnets.all.ids
97104
cluster_id = aws_ecs_cluster.cluster.id
98105

99106
platform_version = "1.4.0"

examples/fargate-spot/main.tf

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ data "aws_vpc" "default" {
99
default = true
1010
}
1111

12-
data "aws_subnet_ids" "all" {
13-
vpc_id = data.aws_vpc.default.id
12+
data "aws_subnets" "all" {
13+
filter {
14+
name = "vpc-id"
15+
values = [data.aws_vpc.default.id]
16+
}
1417
}
1518

1619
#####
@@ -24,7 +27,7 @@ module "alb" {
2427
load_balancer_type = "application"
2528
internal = false
2629
vpc_id = data.aws_vpc.default.id
27-
subnets = data.aws_subnet_ids.all.ids
30+
subnets = data.aws_subnets.all.ids
2831
}
2932

3033
resource "aws_lb_listener" "alb_80" {
@@ -64,25 +67,30 @@ resource "aws_security_group_rule" "task_ingress_80" {
6467
# ECS cluster and fargate
6568
#####
6669
resource "aws_ecs_cluster" "cluster" {
67-
name = "ecs-spot-test"
68-
capacity_providers = ["FARGATE_SPOT", "FARGATE"]
69-
70-
default_capacity_provider_strategy {
71-
capacity_provider = "FARGATE_SPOT"
72-
}
70+
name = "ecs-spot-test"
7371

7472
setting {
7573
name = "containerInsights"
7674
value = "disabled"
7775
}
7876
}
7977

78+
resource "aws_ecs_cluster_capacity_providers" "cluster" {
79+
cluster_name = aws_ecs_cluster.cluster.name
80+
81+
capacity_providers = ["FARGATE_SPOT", "FARGATE"]
82+
83+
default_capacity_provider_strategy {
84+
capacity_provider = "FARGATE_SPOT"
85+
}
86+
}
87+
8088
module "fargate" {
8189
source = "../../"
8290

8391
name_prefix = "ecs-fargate-example"
8492
vpc_id = data.aws_vpc.default.id
85-
private_subnet_ids = data.aws_subnet_ids.all.ids
93+
private_subnet_ids = data.aws_subnets.all.ids
8694

8795
cluster_id = aws_ecs_cluster.cluster.id
8896

examples/multiple-target-groups/main.tf

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ data "aws_vpc" "default" {
99
default = true
1010
}
1111

12-
data "aws_subnet_ids" "all" {
13-
vpc_id = data.aws_vpc.default.id
12+
data "aws_subnets" "all" {
13+
filter {
14+
name = "vpc-id"
15+
values = [data.aws_vpc.default.id]
16+
}
1417
}
1518

1619
#####
@@ -24,7 +27,7 @@ module "external-alb" {
2427
load_balancer_type = "application"
2528
internal = false
2629
vpc_id = data.aws_vpc.default.id
27-
subnets = data.aws_subnet_ids.all.ids
30+
subnets = data.aws_subnets.all.ids
2831
}
2932

3033
resource "aws_lb_listener" "external_alb_80" {
@@ -46,7 +49,7 @@ module "internal-alb" {
4649
load_balancer_type = "application"
4750
internal = false
4851
vpc_id = data.aws_vpc.default.id
49-
subnets = data.aws_subnet_ids.all.ids
52+
subnets = data.aws_subnets.all.ids
5053
}
5154

5255
resource "aws_lb_listener" "internal_alb_80" {
@@ -128,7 +131,7 @@ module "fargate" {
128131
# sg_name_prefix = "my-security-group-name" # uncomment if you want to name security group with specific name
129132

130133
vpc_id = data.aws_vpc.default.id
131-
private_subnet_ids = data.aws_subnet_ids.all.ids
134+
private_subnet_ids = data.aws_subnets.all.ids
132135
cluster_id = aws_ecs_cluster.cluster.id
133136
target_groups = [
134137
{

versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
terraform {
2-
required_version = ">= 0.13.0"
2+
required_version = ">= 0.13.7"
33

44
required_providers {
55
aws = ">= 3.34"

0 commit comments

Comments
 (0)