2021-01-26 21:40:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
data "aws_iam_policy_document" "cloudtrail_bucket_policy" {
|
|
|
|
statement {
|
|
|
|
sid = "AWSCloudTrailAclCheck"
|
|
|
|
|
|
|
|
principals {
|
|
|
|
type = "Service"
|
|
|
|
identifiers = ["cloudtrail.amazonaws.com"]
|
|
|
|
}
|
|
|
|
|
|
|
|
actions = [
|
|
|
|
"s3:GetBucketAcl",
|
|
|
|
]
|
|
|
|
|
|
|
|
resources = [
|
|
|
|
"arn:aws:s3:::${local.ct-bucket-name}",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
statement {
|
|
|
|
sid = "AWSCloudTrailWrite"
|
|
|
|
|
|
|
|
principals {
|
|
|
|
type = "Service"
|
|
|
|
identifiers = ["config.amazonaws.com", "cloudtrail.amazonaws.com"]
|
|
|
|
}
|
|
|
|
|
|
|
|
actions = [
|
2021-01-28 09:25:50 +08:00
|
|
|
"s3:PutObject"
|
2021-01-26 21:40:02 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
resources = [
|
2021-01-28 09:25:50 +08:00
|
|
|
"arn:aws:s3:::${local.ct-bucket-name}/*"
|
2021-01-26 21:40:02 +08:00
|
|
|
]
|
|
|
|
}
|
2021-01-28 09:25:50 +08:00
|
|
|
|
|
|
|
statement {
|
|
|
|
sid = "ReadAccessForAccountOwner"
|
|
|
|
|
|
|
|
principals {
|
|
|
|
type = "AWS"
|
|
|
|
identifiers = [data.aws_caller_identity.this.account_id]
|
|
|
|
}
|
|
|
|
|
|
|
|
actions = [
|
|
|
|
"s3:Get*"
|
|
|
|
]
|
|
|
|
|
|
|
|
resources = [
|
|
|
|
"arn:aws:s3:::${local.ct-bucket-name}",
|
|
|
|
"arn:aws:s3:::${local.ct-bucket-name}/*"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2021-01-26 21:40:02 +08:00
|
|
|
}
|
|
|
|
|
2022-09-05 13:52:21 +08:00
|
|
|
module ct-bucket {
|
|
|
|
source = "../../storage/infra-s3-bucket"
|
2021-01-26 21:40:02 +08:00
|
|
|
|
2022-09-05 13:52:21 +08:00
|
|
|
bucket-name = local.ct-bucket-name
|
|
|
|
bucket-policy-json = data.aws_iam_policy_document.cloudtrail_bucket_policy.json
|
|
|
|
default-tags = var.default-tags
|
2021-01-26 21:40:02 +08:00
|
|
|
}
|