Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions management-team-account/billing/s3/backend.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
backend "s3" {
bucket = "cloudfence-management-state"
key = "billing/s3.tfstate"
region = "ap-northeast-2"
encrypt = true
dynamodb_table = "s3-management-lock"
}
}
28 changes: 28 additions & 0 deletions management-team-account/billing/s3/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

# billing을 담을 bucket 생성
resource "aws_s3_bucket" "billing" {
bucket = "billing-report-bucket"
lifecycle {
prevent_destroy = false
}

tags = {
Name = "Billing Bucket"
Environment = "management"
}
}

# billing에서 bucket에 putobject를 하는 것을 허용
resource "aws_s3_bucket_policy" "allow_billing_upload" {
bucket = aws_s3_bucket.billing.id

policy = jsonencode({
Version = "2012-10-17",
Statement = [{
Effect = "Allow",
Principal = { Service = "billingreports.amazonaws.com" },
Action = "s3:PutObject",
Resource = "${aws_s3_bucket.billing.arn}/*"
Comment on lines +24 to +25
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bucket policy is missing the GetBucketAcl and GetBucketPolicy actions that are typically required by AWS billing service. The policy should include these permissions for the billing service to function properly.

Suggested change
Action = "s3:PutObject",
Resource = "${aws_s3_bucket.billing.arn}/*"
Action = ["s3:PutObject", "s3:GetBucketAcl", "s3:GetBucketPolicy"],
Resource = "${aws_s3_bucket.billing.arn}/*"
},
{
Effect = "Allow",
Principal = { Service = "billingreports.amazonaws.com" },
Action = ["s3:GetBucketAcl", "s3:GetBucketPolicy"],
Resource = "${aws_s3_bucket.billing.arn}"

Copilot uses AI. Check for mistakes.
}]
})
}
7 changes: 7 additions & 0 deletions management-team-account/billing/s3/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
output "bucket_id" {
value = aws_s3_bucket.billing.id
}

output "bucket_arn" {
value = aws_s3_bucket.billing.arn
}
Loading