-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathartifacts.tf
48 lines (41 loc) · 1.17 KB
/
artifacts.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
/*
* == Artifact Storage
*
* Any artifacts being deployed will be stored here.
* This also triggers the pipelines.
*/
resource "aws_s3_bucket" "artifacts" {
bucket = "${var.account_id}-${var.name_prefix}-delivery-pipeline-artifacts"
}
resource "aws_s3_bucket_versioning" "artifacts" {
bucket = aws_s3_bucket.artifacts.id
versioning_configuration {
status = "Enabled"
}
}
data "aws_iam_policy_document" "allow_account_access" {
statement {
principals {
type = "AWS"
identifiers = concat(
var.deployment_accounts.dev != null ? [var.deployment_accounts.dev] : [],
var.deployment_accounts.test != null ? [var.deployment_accounts.test] : [],
var.deployment_accounts.stage != null ? [var.deployment_accounts.stage] : [],
[
var.deployment_accounts.prod,
])
}
actions = [
"s3:ListBucket",
"s3:GetObject*",
]
resources = [
aws_s3_bucket.artifacts.arn,
"${aws_s3_bucket.artifacts.arn}/*",
]
}
}
resource "aws_s3_bucket_policy" "allow_account_access" {
bucket = aws_s3_bucket.artifacts.id
policy = data.aws_iam_policy_document.allow_account_access.json
}