forked from ohpensource/terraform-aws-ohp-ecr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam_push.tf
49 lines (39 loc) · 1.09 KB
/
iam_push.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
40
41
42
43
44
45
46
47
# Push User
resource "aws_iam_access_key" "push" {
count = local.create_push_user
user = aws_iam_user.push.*.name[count.index]
}
resource "aws_iam_user" "push" {
count = local.create_push_user
name = local.push_iam_user_name
tags = merge(
var.tags,
tomap(
{ "Name" = local.push_iam_user_name }
)
)
}
resource "aws_iam_user_policy" "push" {
count = local.create_push_user
name = "${local.push_iam_user_name}-ecr-policy"
user = aws_iam_user.push.*.name[count.index]
policy = data.aws_iam_policy_document.ecr_push_user_policy.*.json[count.index]
}
resource "aws_secretsmanager_secret" "push" {
count = local.create_push_user
name = local.push_iam_user_name
tags = merge(
var.tags,
tomap(
{ "Name" = local.push_iam_user_name }
)
)
}
resource "aws_secretsmanager_secret_version" "push" {
count = local.create_push_user
secret_id = aws_secretsmanager_secret.push.*.id[count.index]
secret_string = jsonencode({
AccessKey = aws_iam_access_key.push.*.id[count.index],
SecretKey = aws_iam_access_key.push.*.secret[count.index]
})
}