-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocals.tf
70 lines (64 loc) · 2.09 KB
/
locals.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#This solution, non-production-ready template describes AWS Codepipeline based CICD Pipeline for terraform code deployment.
#© 2023 Amazon Web Services, Inc. or its affiliates. All Rights Reserved.
#This AWS Content is provided subject to the terms of the AWS Customer Agreement available at
#http://aws.amazon.com/agreement or other written agreement between Customer and either
#Amazon Web Services, Inc. or Amazon Web Services EMEA SARL or both.
locals {
account_id = data.aws_caller_identity.current.account_id
region = data.aws_region.current.name
buckets = distinct([
module.s3_artifacts_bucket.bucket,
var.assets_bucket_name,
var.packer_bucket.name,
var.ansible_bucket.name,
var.goss_bucket.name,
var.state.bucket
])
}
data "aws_iam_policy_document" "build_user_default" {
statement {
effect = "Allow"
actions = [
"ssm:*"
]
resources = [
"arn:${data.aws_partition.current.partition}:ssm:${data.aws_region.current.id}:${data.aws_caller_identity.current.account_id}:*"
]
}
statement {
effect = "Allow"
actions = [
"kms:*"
]
resources = [
"arn:${data.aws_partition.current.partition}:kms:${data.aws_region.current.id}:${data.aws_caller_identity.current.account_id}:*"
]
}
statement {
effect = "Allow"
actions = [
"secretsmanager:*"
]
resources = concat([
"arn:${data.aws_partition.current.partition}:secretsmanager:${data.aws_region.current.id}:${data.aws_caller_identity.current.account_id}:secret:/image-pipeline/${var.project_name}/*"
],
var.secret_arns == null ? [] : var.secret_arns)
}
statement {
effect = "Allow"
actions = [
"s3:*"
]
resources = concat(
[
for bucket in local.buckets : "arn:${data.aws_partition.current.partition}:s3:::${bucket}"
],
[
for bucket in local.buckets : "arn:${data.aws_partition.current.partition}:s3:::${bucket}/*"
]
)
}
}
locals {
build_user_iam_policy = var.build_user_iam_policy == null ? data.aws_iam_policy_document.build_user_default.json : var.build_user_iam_policy
}