-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathiam-ecrpush.tf
39 lines (29 loc) · 1.33 KB
/
iam-ecrpush.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
resource "aws_iam_role" "ecrpush" {
count = var.is_create_github_oidc && var.is_create_ecrpush_oicd_role ? 1 : 0
name = local.ecrpush_role_name
path = var.iam_role_path
max_session_duration = var.max_session_duration
description = "IAM Role to be assumed by github action"
force_detach_policies = var.force_detach_policies
permissions_boundary = var.iam_role_permissions_boundary
assume_role_policy = coalesce(
try(
data.aws_iam_policy_document.federated_assume_policy[0].json
)
)
tags = merge(
local.tags,
{ "Name" : local.ecrpush_role_name }
)
}
/* -------------------------------------------------------------------------- */
/* AWS_IAM_ROLE_POLICY */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* AWS_IAM_ROLE_POLICY_ATTACHMENT */
/* -------------------------------------------------------------------------- */
resource "aws_iam_role_policy_attachment" "ecr_poweruser" {
count = var.is_create_github_oidc && var.is_create_ecrpush_oicd_role ? 1 : 0
role = aws_iam_role.ecrpush[0].name
policy_arn = var.ecr_poweruser_policy_arn
}