Skip to content

Commit

Permalink
feat: add terraform storage config
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael.Taylor committed Jan 7, 2022
1 parent a5d695e commit e971ded
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions terraform/storage.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
resource "aws_s3_bucket" "storage-devops-bucket" {
# Bucket name must be unique across all AWS users!
bucket = "${var.default_storage_bucket}.dev"

tags = {
Name = "${var.aws_profile} Configuration Bucket"
Environment = "Dev"
}
}

resource "aws_s3_bucket" "storage-bucket" {
# Bucket name must be unique across all AWS users!
bucket = var.default_storage_bucket
acceleration_status = "Enabled"
policy = jsonencode({
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DistinctPublicFolder",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::${var.default_storage_bucket}/public/*"
}
]
})

cors_rule {
allowed_headers = ["*"]
allowed_methods = ["GET"]
allowed_origins = ["*"]
expose_headers = ["ETag"]
max_age_seconds = 3000
}

tags = {
Name = "${var.aws_profile} Storage Bucket"
Environment = "Prod"
}
}

resource "aws_s3_bucket_object" "public-folder" {
bucket = aws_s3_bucket.storage-bucket.id
acl = "public-read"
key = "public/"
source = "/dev/null"
}

output "bucket_id" { value = aws_s3_bucket.storage-bucket.id }
output "dev_bucket_id" { value = aws_s3_bucket.storage-devops-bucket.id }

0 comments on commit e971ded

Please sign in to comment.