mirror of
https://github.com/Sea-Haven-Industries/seahaven-site.git
synced 2026-09-30 06:33:16 +00:00
Some checks are pending
Deploy / deploy (push) Waiting to run
* feat(infra): add HCP Terraform for prod static hosting Greenfield S3+CloudFront+ACM+OIDC content-deploy role under /tf-managed/, with OOB mgmt DNS helper for ACM validation and apex alias cutover. * chore(security): suppress pre-existing js-yaml npm audit * feat(ci): retarget content deploy to seahaven-prod origin Point OIDC, S3 sync, and CloudFront invalidation at the HCP-managed prod hosting stack so GHA remains the content publish path after cutover.
90 lines
1.8 KiB
HCL
90 lines
1.8 KiB
HCL
resource "aws_s3_bucket" "origin" {
|
|
bucket = local.bucket_name
|
|
}
|
|
|
|
resource "aws_s3_bucket_public_access_block" "origin" {
|
|
bucket = aws_s3_bucket.origin.id
|
|
|
|
block_public_acls = true
|
|
block_public_policy = true
|
|
ignore_public_acls = true
|
|
restrict_public_buckets = true
|
|
}
|
|
|
|
resource "aws_s3_bucket_ownership_controls" "origin" {
|
|
bucket = aws_s3_bucket.origin.id
|
|
|
|
rule {
|
|
object_ownership = "BucketOwnerEnforced"
|
|
}
|
|
}
|
|
|
|
resource "aws_s3_bucket_server_side_encryption_configuration" "origin" {
|
|
bucket = aws_s3_bucket.origin.id
|
|
|
|
rule {
|
|
apply_server_side_encryption_by_default {
|
|
sse_algorithm = "AES256"
|
|
}
|
|
}
|
|
}
|
|
|
|
resource "aws_s3_bucket_versioning" "origin" {
|
|
bucket = aws_s3_bucket.origin.id
|
|
|
|
versioning_configuration {
|
|
status = "Enabled"
|
|
}
|
|
}
|
|
|
|
data "aws_iam_policy_document" "origin_ssl_only" {
|
|
statement {
|
|
sid = "DenyInsecureTransport"
|
|
effect = "Deny"
|
|
|
|
principals {
|
|
type = "*"
|
|
identifiers = ["*"]
|
|
}
|
|
|
|
actions = ["s3:*"]
|
|
resources = [
|
|
aws_s3_bucket.origin.arn,
|
|
"${aws_s3_bucket.origin.arn}/*",
|
|
]
|
|
|
|
condition {
|
|
test = "Bool"
|
|
variable = "aws:SecureTransport"
|
|
values = ["false"]
|
|
}
|
|
}
|
|
|
|
statement {
|
|
sid = "AllowCloudFrontOacRead"
|
|
effect = "Allow"
|
|
|
|
principals {
|
|
type = "Service"
|
|
identifiers = ["cloudfront.amazonaws.com"]
|
|
}
|
|
|
|
actions = [
|
|
"s3:GetObject",
|
|
]
|
|
resources = [
|
|
"${aws_s3_bucket.origin.arn}/*",
|
|
]
|
|
|
|
condition {
|
|
test = "StringEquals"
|
|
variable = "AWS:SourceArn"
|
|
values = [aws_cloudfront_distribution.site.arn]
|
|
}
|
|
}
|
|
}
|
|
|
|
resource "aws_s3_bucket_policy" "origin" {
|
|
bucket = aws_s3_bucket.origin.id
|
|
policy = data.aws_iam_policy_document.origin_ssl_only.json
|
|
}
|