Skip to content

Commit ee192f3

Browse files
author
ignacioli
authored
feat: support loki bucket for aws BYOC poolmebers (#167)
<!-- ~ Copyright 2023 StreamNative, Inc. ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. --> <!-- ### Contribution Checklist - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review. - Each pull request should address only one issue, not mix up code from multiple issues. - Each commit in the pull request has a meaningful commit message - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below. **(The sections below can be removed for hotfixes of typos)** --> *(If this PR fixes a github issue, please add `Fixes #<xyz>`.)* Fixes #<xyz> *(or if this PR is one task of a github issue, please add `Master Issue: #<xyz>` to link to the master issue.)* Master Issue: #<xyz> ### Motivation *Explain here the context, and why you're making that change. What is the problem you're trying to solve.* ### Modifications *Describe the modifications you've done.* ### Verifying this change - [ ] Make sure that the change passes the CI checks. *(Please pick either of the following options)* This change is a trivial rework / code cleanup without any test coverage. *(or)* This change is already covered by existing tests, such as *(please describe tests)*. *(or)* This change added tests and can be verified as follows: *(example:)* - *Added integration tests for end-to-end deployment with large payloads (10MB)* - *Extended integration test for recovery after broker failure* ### Documentation Check the box below. Need to update docs? - [ ] `doc-required` (If you need help on updating docs, create a doc issue) - [ ] `no-need-doc` (Please explain why) - [ ] `doc` (If this PR contains doc changes)
1 parent 5211726 commit ee192f3

File tree

4 files changed

+32
-14
lines changed

4 files changed

+32
-14
lines changed

modules/dns-bucket/README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ A basic module used to create Route53 Zone and S3 Buckets.
2828

2929
| Name | Version |
3030
|------|---------|
31-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.76.0 |
32-
| <a name="provider_aws.source"></a> [aws.source](#provider\_aws.source) | 5.76.0 |
33-
| <a name="provider_aws.target"></a> [aws.target](#provider\_aws.target) | 5.76.0 |
31+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.75.0 |
32+
| <a name="provider_aws.source"></a> [aws.source](#provider\_aws.source) | 5.75.0 |
33+
| <a name="provider_aws.target"></a> [aws.target](#provider\_aws.target) | 5.75.0 |
3434

3535
## Modules
3636

@@ -42,6 +42,7 @@ No modules.
4242
|------|------|
4343
| [aws_route53_record.delegate](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource |
4444
| [aws_route53_zone.zone](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_zone) | resource |
45+
| [aws_s3_bucket.loki](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |
4546
| [aws_s3_bucket.tiered_storage](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |
4647
| [aws_s3_bucket.velero](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |
4748
| [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 |
@@ -52,11 +53,14 @@ No modules.
5253

5354
| Name | Description | Type | Default | Required |
5455
|------|-------------|------|---------|:--------:|
56+
| <a name="input_bucket_location"></a> [bucket\_location](#input\_bucket\_location) | The location of the bucket | `string` | n/a | yes |
5557
| <a name="input_custom_dns_zone_id"></a> [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 |
5658
| <a name="input_custom_dns_zone_name"></a> [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 |
59+
| <a name="input_enable_loki"></a> [enable\_loki](#input\_enable\_loki) | Enable loki storage bucket creation | `bool` | `false` | no |
5760
| <a name="input_extra_aws_tags"></a> [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 |
5861
| <a name="input_parent_zone_name"></a> [parent\_zone\_name](#input\_parent\_zone\_name) | The parent zone in which we create the delegation records | `string` | n/a | yes |
5962
| <a name="input_pm_name"></a> [pm\_name](#input\_pm\_name) | The name of the poolmember, for new clusters, this should be like `pm-<xxxxx>` | `string` | n/a | yes |
63+
| <a name="input_pm_namespace"></a> [pm\_namespace](#input\_pm\_namespace) | The namespace of the poolmember | `string` | n/a | yes |
6064
| <a name="input_s3_encryption_kms_key_arn"></a> [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 |
6165

6266
## Outputs
@@ -65,6 +69,7 @@ No modules.
6569
|------|-------------|
6670
| <a name="output_backup_bucket"></a> [backup\_bucket](#output\_backup\_bucket) | n/a |
6771
| <a name="output_backup_bucket_kms_key_id"></a> [backup\_bucket\_kms\_key\_id](#output\_backup\_bucket\_kms\_key\_id) | n/a |
72+
| <a name="output_loki_bucket"></a> [loki\_bucket](#output\_loki\_bucket) | n/a |
6873
| <a name="output_tiered_storage_bucket"></a> [tiered\_storage\_bucket](#output\_tiered\_storage\_bucket) | n/a |
6974
| <a name="output_zone_id"></a> [zone\_id](#output\_zone\_id) | n/a |
7075
| <a name="output_zone_name"></a> [zone\_name](#output\_zone\_name) | n/a |

modules/dns-bucket/bucket.tf

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,25 @@
1313
# limitations under the License.
1414

1515
resource "aws_s3_bucket" "velero" {
16+
provider = aws.target
1617
bucket = format("%s-cluster-backup-snc", var.pm_name)
1718
tags = merge({ "Attributes" = "backup", "Name" = "velero-backups" }, local.tags)
1819
force_destroy = true
19-
20-
lifecycle {
21-
ignore_changes = [
22-
bucket,
23-
]
24-
}
2520
}
2621

2722
resource "aws_s3_bucket" "tiered_storage" {
23+
provider = aws.target
2824
bucket = format("%s-tiered-storage-snc", var.pm_name)
2925
tags = merge({ "Attributes" = "tiered-storage" }, local.tags)
3026
force_destroy = true
27+
}
3128

32-
lifecycle {
33-
ignore_changes = [
34-
bucket,
35-
]
36-
}
29+
resource "aws_s3_bucket" "loki" {
30+
count = var.enable_loki ? 1 : 0
31+
provider = aws.source
32+
bucket = format("loki-%s-%s", var.pm_namespace, var.pm_name)
33+
tags = merge({ "Attributes" = "loki", "Name" = "logs-byoc" }, local.tags)
34+
force_destroy = true
3735
}
3836

3937
data "aws_kms_key" "s3_default" {

modules/dns-bucket/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,8 @@ output "backup_bucket_kms_key_id" {
3030

3131
output "tiered_storage_bucket" {
3232
value = aws_s3_bucket.tiered_storage.bucket
33+
}
34+
35+
output "loki_bucket" {
36+
value = var.enable_loki ? aws_s3_bucket.loki[0].bucket : ""
3337
}

modules/dns-bucket/variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
variable "pm_namespace" {
16+
type = string
17+
description = "The namespace of the poolmember"
18+
}
19+
1520
variable "pm_name" {
1621
description = "The name of the poolmember, for new clusters, this should be like `pm-<xxxxx>`"
1722
type = string
@@ -51,3 +56,9 @@ locals {
5156
"Vendor" = "StreamNative"
5257
}, var.extra_aws_tags)
5358
}
59+
60+
variable "enable_loki" {
61+
type = bool
62+
default = false
63+
description = "Enable loki storage bucket creation"
64+
}

0 commit comments

Comments
 (0)