Skip to content

Commit c4e5897

Browse files
committed
add paren
1 parent 566220e commit c4e5897

File tree

2 files changed

+48
-17
lines changed

2 files changed

+48
-17
lines changed

modules/s3_bucket/main.tf

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
2+
data "aws_iam_policy_document" "segment_policy_doc" {
3+
statement {
4+
sid = "cross_account"
5+
6+
actions = [
7+
"s3:GetBucketLocation",
8+
"s3:ListBucket",
9+
"s3:GetObject",
10+
"s3:PutObject",
11+
"s3:PutObjectAcl",
12+
"s3:GetObjectAcl",
13+
"s3:DeleteObject"
14+
]
15+
16+
principals {
17+
type = "AWS"
18+
identifiers = "arn:aws:iam::${var.data_account}:root"
19+
}
20+
21+
resources = [
22+
"arn:aws:s3:::${var.s3_bucket}",
23+
"arn:aws:s3:::${var.s3_bucket}/*"
24+
]
25+
26+
}
27+
28+
statement {
29+
sid = "AllowSegmentUser"
30+
effect = "Allow"
31+
principals {
32+
type = "AWS"
33+
identifiers = "arn:aws:iam::107630771604:user/s3-copy"
34+
}
35+
actions = ["S3:PutObject"]
36+
resources = ["arn:aws:s3:::${var.s3_bucket}/*"]
37+
}
38+
39+
}
40+
41+
142
module "s3_bucket" {
243
source = "https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/archive/v1.9.0.zip//terraform-aws-s3-bucket-1.9.0"
344

@@ -10,21 +51,6 @@ module "s3_bucket" {
1051

1152
tags = local.tags
1253

13-
policy = <<POLICY
14-
{
15-
"Version": "2008-10-17",
16-
"Id": "Policy1425281770533",
17-
"Statement": [
18-
{
19-
"Sid": "AllowSegmentUser",
20-
"Effect": "Allow",
21-
"Principal": {
22-
"AWS": "arn:aws:iam::107630771604:user/s3-copy"
23-
},
24-
"Action": "s3:PutObject",
25-
"Resource": "arn:aws:s3:::${var.s3_bucket}/*"
26-
}
27-
]
28-
}
29-
POLICY
54+
policy = data.aws_iam_policy_document.segment_policy_doc.json
55+
3056
}

modules/s3_bucket/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ variable "tags" {
99
default = {}
1010
}
1111

12+
variable "data_account" {
13+
description = "aws account id for data account"
14+
type = "string"
15+
}
16+
1217
locals {
1318
tags = "${merge(map("vendor", "segment"), var.tags)}"
1419
}

0 commit comments

Comments
 (0)