From 088eb9e8477b11060d360d16a629fcc53392ea79 Mon Sep 17 00:00:00 2001 From: Yisheng Cai Date: Mon, 17 Aug 2026 20:54:14 -0700 Subject: [PATCH 1/2] feat(dns-bucket): add optional sqlworkspace S3 bucket --- modules/dns-bucket/README.md | 4 ++++ modules/dns-bucket/bucket.tf | 8 ++++++++ modules/dns-bucket/outputs.tf | 6 +++++- modules/dns-bucket/variables.tf | 12 ++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/modules/dns-bucket/README.md b/modules/dns-bucket/README.md index 5e5aa59..2442ec3 100644 --- a/modules/dns-bucket/README.md +++ b/modules/dns-bucket/README.md @@ -43,6 +43,7 @@ No modules. | [aws_route53_record.delegate](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource | | [aws_route53_zone.zone](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_zone) | resource | | [aws_s3_bucket.loki](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource | +| [aws_s3_bucket.sqlworkspace](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource | | [aws_s3_bucket.tiered_storage](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource | | [aws_s3_bucket.velero](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource | | [aws_s3_bucket_server_side_encryption_configuration.velero](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_server_side_encryption_configuration) | resource | @@ -56,6 +57,7 @@ No modules. | [custom\_dns\_zone\_id](#input\_custom\_dns\_zone\_id) | if specified, then a streamnative zone will not be created, and this zone will be used instead. Otherwise, we will provision a new zone and delegate access | `string` | `""` | no | | [custom\_dns\_zone\_name](#input\_custom\_dns\_zone\_name) | must be passed if custom\_dns\_zone\_id is passed, this is the zone name to use | `string` | `""` | no | | [enable\_loki](#input\_enable\_loki) | Enable loki storage bucket creation | `bool` | `false` | no | +| [enable\_sqlworkspace](#input\_enable\_sqlworkspace) | Enable sqlworkspace storage bucket creation | `bool` | `false` | no | | [enable\_velero](#input\_enable\_velero) | Enable velero for backups. If set to false, no velero resources will be created. | `bool` | `false` | no | | [extra\_aws\_tags](#input\_extra\_aws\_tags) | Additional to apply to the resources. Note that this module sets the tags Name, Type, and Vendor by default. They can be overwritten, but it is not recommended. | `map(string)` | `{}` | no | | [loki\_bucket\_name](#input\_loki\_bucket\_name) | Override the generated name if specified | `string` | `""` | no | @@ -63,6 +65,7 @@ No modules. | [pm\_name](#input\_pm\_name) | The name of the poolmember, for new clusters, this should be like `pm-` | `string` | n/a | yes | | [pm\_namespace](#input\_pm\_namespace) | The namespace of the poolmember | `string` | n/a | yes | | [s3\_encryption\_kms\_key\_arn](#input\_s3\_encryption\_kms\_key\_arn) | KMS key ARN to use for S3 encryption. If not set, the default AWS S3 key will be used. | `string` | `""` | no | +| [sqlworkspace\_bucket\_name](#input\_sqlworkspace\_bucket\_name) | Override the generated name if specified | `string` | `""` | no | | [tiered\_storage\_bucket\_name](#input\_tiered\_storage\_bucket\_name) | Override the generated name if specified | `string` | `""` | no | | [velero\_bucket\_name](#input\_velero\_bucket\_name) | Override the generated name if specified | `string` | `""` | no | @@ -73,6 +76,7 @@ No modules. | [backup\_bucket](#output\_backup\_bucket) | n/a | | [backup\_bucket\_kms\_key\_id](#output\_backup\_bucket\_kms\_key\_id) | n/a | | [loki\_bucket](#output\_loki\_bucket) | n/a | +| [sqlworkspace\_bucket](#output\_sqlworkspace\_bucket) | n/a | | [tiered\_storage\_bucket](#output\_tiered\_storage\_bucket) | n/a | | [zone\_id](#output\_zone\_id) | n/a | | [zone\_name](#output\_zone\_name) | n/a | diff --git a/modules/dns-bucket/bucket.tf b/modules/dns-bucket/bucket.tf index 57e7179..b4aa555 100644 --- a/modules/dns-bucket/bucket.tf +++ b/modules/dns-bucket/bucket.tf @@ -35,6 +35,14 @@ resource "aws_s3_bucket" "loki" { force_destroy = true } +resource "aws_s3_bucket" "sqlworkspace" { + count = var.enable_sqlworkspace ? 1 : 0 + provider = aws.source + bucket = coalesce(var.sqlworkspace_bucket_name, format("sqlworkspace-%s-%s", var.pm_namespace, var.pm_name)) + tags = merge({ "Attributes" = "sqlworkspace" }, local.tags) + force_destroy = true +} + data "aws_kms_key" "s3_default" { key_id = "alias/aws/s3" } diff --git a/modules/dns-bucket/outputs.tf b/modules/dns-bucket/outputs.tf index e6d9bf6..bed51ec 100644 --- a/modules/dns-bucket/outputs.tf +++ b/modules/dns-bucket/outputs.tf @@ -34,4 +34,8 @@ output "tiered_storage_bucket" { output "loki_bucket" { value = var.enable_loki ? aws_s3_bucket.loki[0].bucket : "" -} \ No newline at end of file +} + +output "sqlworkspace_bucket" { + value = var.enable_sqlworkspace ? aws_s3_bucket.sqlworkspace[0].bucket : "" +} diff --git a/modules/dns-bucket/variables.tf b/modules/dns-bucket/variables.tf index 6d839dc..c977f6d 100644 --- a/modules/dns-bucket/variables.tf +++ b/modules/dns-bucket/variables.tf @@ -75,6 +75,12 @@ variable "enable_velero" { description = "Enable velero for backups. If set to false, no velero resources will be created." } +variable "enable_sqlworkspace" { + type = bool + default = false + description = "Enable sqlworkspace storage bucket creation" +} + variable "velero_bucket_name" { type = string default = "" @@ -92,3 +98,9 @@ variable "loki_bucket_name" { default = "" description = "Override the generated name if specified" } + +variable "sqlworkspace_bucket_name" { + type = string + default = "" + description = "Override the generated name if specified" +} From 49eeed5d3f5b8f0da14d69f839296b675448a74a Mon Sep 17 00:00:00 2001 From: Yisheng Cai Date: Thu, 20 Aug 2026 16:23:42 -0700 Subject: [PATCH 2/2] fix(dns-bucket): use target account and -snc bucket name --- modules/dns-bucket/bucket.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/dns-bucket/bucket.tf b/modules/dns-bucket/bucket.tf index b4aa555..9288764 100644 --- a/modules/dns-bucket/bucket.tf +++ b/modules/dns-bucket/bucket.tf @@ -37,8 +37,8 @@ resource "aws_s3_bucket" "loki" { resource "aws_s3_bucket" "sqlworkspace" { count = var.enable_sqlworkspace ? 1 : 0 - provider = aws.source - bucket = coalesce(var.sqlworkspace_bucket_name, format("sqlworkspace-%s-%s", var.pm_namespace, var.pm_name)) + provider = aws.target + bucket = coalesce(var.sqlworkspace_bucket_name, format("%s-sqlworkspace-snc", var.pm_name)) tags = merge({ "Attributes" = "sqlworkspace" }, local.tags) force_destroy = true }