UPD: canned s3 bucket policy

This commit is contained in:
xpk 2022-08-17 16:01:26 +08:00
parent 89a45a747e
commit e272c6471a
Signed by: xpk
GPG Key ID: CD4FF6793F09AB86
2 changed files with 23 additions and 3 deletions

View File

@ -75,7 +75,28 @@ resource "aws_s3_bucket_acl" "bucket-acl" {
resource "aws_s3_bucket_policy" "bucket-policy" {
bucket = aws_s3_bucket.s3bucket.bucket
policy = var.bucket-policy-json
policy = <<EOT
{
"Id": "policy01",
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowFullAccessFromBastion",
"Action": "s3:*",
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::${var.resource-prefix}-tfstate/*",
"arn:aws:s3:::${var.resource-prefix}-tfstate"
],
"Principal": {
"AWS": [
"arn:aws:iam::${data.aws_caller_identity.this.account_id}:root"
]
}
}
]
}
EOT
}
resource "aws_dynamodb_table" "tfstate-lock-table" {

View File

@ -12,9 +12,8 @@ variable "bucket-enable-lifecycle" {
variable "bucket-acl" {
default = "private"
}
variable "bucket-policy-json" {}
variable "enable-bucket-versioning" {
default = true
}
variable "bucket-name" {}
variable "bucket-name" {}