-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AWS: ECS Task Execution Role and ECR repository URL output (#25)
- Loading branch information
Showing
4 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
data "aws_iam_policy_document" "assume_role" { | ||
statement { | ||
actions = ["sts:AssumeRole"] | ||
|
||
principals { | ||
type = "Service" | ||
identifiers = ["ecs-tasks.amazonaws.com"] | ||
} | ||
} | ||
} | ||
|
||
resource "aws_iam_role" "main" { | ||
name = var.name | ||
assume_role_policy = data.aws_iam_policy_document.assume_role.json | ||
tags = var.tags | ||
} | ||
|
||
resource "aws_iam_role_policy_attachment" "main" { | ||
count = length(var.policies) | ||
|
||
role = aws_iam_role.main.name | ||
policy_arn = var.policies[count.index] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
output "role_arn" { | ||
value = aws_iam_role.main.arn | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
variable "name" { | ||
type = string | ||
description = "The name of the IAM Role to create" | ||
nullable = false | ||
} | ||
|
||
variable "policies" { | ||
type = list(string) | ||
description = "The ARNs of the IAM Policies to attach to the IAM role" | ||
default = [ | ||
"arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy" | ||
] | ||
} | ||
|
||
|
||
variable "tags" { | ||
type = map(string) | ||
description = "Tags of the IAM Role to create" | ||
default = {} | ||
} |