Skip to content

Commit c684740

Browse files
author
rohit-ng
committed
refactor: remove iam module
1 parent 6c10477 commit c684740

File tree

7 files changed

+23
-112
lines changed

7 files changed

+23
-112
lines changed

main.tf

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,27 @@ module "ecs_task_security_group" {
169169
# ECS Execution IAM Role
170170
################################################################################
171171

172-
module "ecs_exec_role" {
173-
source = "./modules/iam"
172+
data "aws_iam_policy_document" "assume_role_policy" {
173+
statement {
174+
actions = ["sts:AssumeRole"]
175+
effect = "Allow"
176+
177+
principals {
178+
type = local.ecs.iam.principal_type
179+
identifiers = local.ecs.iam.principal_identifiers
180+
}
181+
}
182+
}
174183

175-
name_prefix = local.ecs.iam.name_prefix
176-
principal_type = local.ecs.iam.principal_type
177-
principal_identifiers = local.ecs.iam.principal_identifiers
178-
policy_arns = local.ecs.iam.ecs_exec_policy_arn
184+
resource "aws_iam_role" "ecs_exec" {
185+
name_prefix = local.ecs.iam.name_prefix
186+
assume_role_policy = data.aws_iam_policy_document.assume_role_policy.json
187+
}
188+
189+
resource "aws_iam_role_policy_attachment" "ecs_exec" {
190+
count = length(local.ecs.iam.ecs_exec_policy_arn)
191+
role = aws_iam_role.ecs_exec.name
192+
policy_arn = element(local.ecs.iam.ecs_exec_policy_arn, count.index)
179193
}
180194

181195
################################################################################
@@ -222,9 +236,9 @@ module "ecs_kong" {
222236
network_mode = local.kong.network_mode
223237
cpu = var.cpu_for_kong_task
224238
memory = var.memory_for_kong_task
225-
task_role_arn = module.ecs_exec_role.role_arn
226-
execution_role_arn = module.ecs_exec_role.role_arn
227-
239+
task_role_arn = aws_iam_role.ecs_exec.arn
240+
execution_role_arn = aws_iam_role.ecs_exec.arn
241+
228242
container_definitions = [
229243
{
230244
name = local.kong.name

modules/iam/.header.md

Whitespace-only changes.

modules/iam/README.md

Lines changed: 0 additions & 42 deletions
This file was deleted.

modules/iam/main.tf

Lines changed: 0 additions & 22 deletions
This file was deleted.

modules/iam/outputs.tf

Lines changed: 0 additions & 9 deletions
This file was deleted.

modules/iam/variables.tf

Lines changed: 0 additions & 20 deletions
This file was deleted.

modules/iam/versions.tf

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)