Skip to content

Commit 1d14f02

Browse files
committed
fixes
1 parent 892c6c3 commit 1d14f02

File tree

1 file changed

+26
-34
lines changed
  • ecs-fargate-wordpress-rds-terraform

1 file changed

+26
-34
lines changed
Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
resource "aws_ecs_cluster" "default" {
2-
name = "${var.ecs_cluster_name}"
2+
name = var.ecs_cluster_name
33
}
44

55
resource "aws_cloudwatch_log_group" "ecs_log_group" {
6-
name = "/ecs/wp-ecs-tf"
6+
name = "/ecs/wp-ecs-tf"
77
retention_in_days = 7
88

99
tags = {
@@ -12,14 +12,8 @@ resource "aws_cloudwatch_log_group" "ecs_log_group" {
1212
}
1313
}
1414

15-
data "aws_iam_role" "existing_ecs_task_execution_role" {
16-
name = "ecsTaskExecutionRole"
17-
}
18-
1915
resource "aws_iam_role" "ecs_task_execution_role" {
20-
count = length(data.aws_iam_role.existing_ecs_task_execution_role.arn) == 0 ? 1 : 0
21-
22-
name = "ecsTaskExecutionRole"
16+
name = "ecsTaskExecutionRole-tf"
2317

2418
assume_role_policy = jsonencode({
2519
Version = "2012-10-17"
@@ -36,21 +30,19 @@ resource "aws_iam_role" "ecs_task_execution_role" {
3630
}
3731

3832
resource "aws_iam_role_policy_attachment" "ecs_task_execution_role_policy" {
39-
count = length(data.aws_iam_role.existing_ecs_task_execution_role.arn) == 0 ? 1 : 0
40-
41-
role = aws_iam_role.ecs_task_execution_role[count.index].name
33+
role = aws_iam_role.ecs_task_execution_role.name
4234
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"
4335
}
4436

4537
resource "aws_ecs_task_definition" "wordpress" {
46-
family = "wp-ecs-task-tf"
47-
container_definitions = data.template_file.wp-container.rendered
38+
family = "wp-ecs-task-tf"
39+
container_definitions = data.template_file.wp-container.rendered
4840
requires_compatibilities = ["FARGATE"]
49-
network_mode = "awsvpc"
50-
cpu = 512
51-
memory = 1024
41+
network_mode = "awsvpc"
42+
cpu = 512
43+
memory = 1024
5244

53-
execution_role_arn = length(data.aws_iam_role.existing_ecs_task_execution_role.arn) == 0 ? aws_iam_role.ecs_task_execution_role[0].arn : data.aws_iam_role.existing_ecs_task_execution_role.arn
45+
execution_role_arn = aws_iam_role.ecs_task_execution_role.arn
5446

5547
runtime_platform {
5648
operating_system_family = "LINUX"
@@ -59,21 +51,21 @@ resource "aws_ecs_task_definition" "wordpress" {
5951
}
6052

6153
resource "aws_ecs_service" "wp-ecs-svc" {
62-
name = "wp-ecs-svc-tf"
63-
cluster = "${aws_ecs_cluster.default.id}"
64-
task_definition = "${aws_ecs_task_definition.wordpress.arn}"
65-
desired_count = 1
66-
launch_type = "FARGATE"
67-
68-
load_balancer {
69-
target_group_arn = "${aws_lb_target_group.default.arn}"
70-
container_name = "wordpress"
71-
container_port = 80
72-
}
54+
name = "wp-ecs-svc-tf"
55+
cluster = aws_ecs_cluster.default.id
56+
task_definition = aws_ecs_task_definition.wordpress.arn
57+
desired_count = 1
58+
launch_type = "FARGATE"
7359

74-
network_configuration {
75-
subnets = ["${aws_subnet.wp-public-a-tf.id}", "${aws_subnet.wp-public-b-tf.id}", "${aws_subnet.wp-public-c-tf.id}"]
76-
security_groups = ["${aws_security_group.wp-alb-tf.id}"]
77-
assign_public_ip = true
78-
}
60+
load_balancer {
61+
target_group_arn = aws_lb_target_group.default.arn
62+
container_name = "wordpress"
63+
container_port = 80
64+
}
65+
66+
network_configuration {
67+
subnets = [aws_subnet.wp-public-a-tf.id, aws_subnet.wp-public-b-tf.id, aws_subnet.wp-public-c-tf.id]
68+
security_groups = [aws_security_group.wp-alb-tf.id]
69+
assign_public_ip = true
70+
}
7971
}

0 commit comments

Comments
 (0)