Skip to content

Commit

Permalink
fix: use is_serverless so that output is deterministic (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
huttotw authored Nov 18, 2024
1 parent 89d49c0 commit e3a7c8c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ This module creates all the proper policies, roles and S3 buckets so that Fullst
| <a name="input_fullstory_cidr_ipv4s"></a> [fullstory\_cidr\_ipv4s](#input\_fullstory\_cidr\_ipv4s) | The CIDR block that Fullstory will use to connect to the Redshift cluster. | `list(string)` | `[]` | no |
| <a name="input_fullstory_data_center"></a> [fullstory\_data\_center](#input\_fullstory\_data\_center) | The data center where your Fullstory account is hosted. Either 'NA1' or 'EU1'. See https://help.fullstory.com/hc/en-us/articles/8901113940375-Fullstory-Data-Residency for more information. | `string` | `"NA1"` | no |
| <a name="input_fullstory_google_audience"></a> [fullstory\_google\_audience](#input\_fullstory\_google\_audience) | The Google audience identifier that Fullstory will use to assume the role in order to call AWS APIs | `string` | `""` | no |
| <a name="input_is_serverless"></a> [is\_serverless](#input\_is\_serverless) | Whether the Redshift cluster is serverless or not. If true, workgroup\_arn is required. If false, database\_arn is required. | `bool` | n/a | yes |
| <a name="input_port"></a> [port](#input\_port) | The port number where the Redshift cluster is listening. | `number` | `5439` | no |
| <a name="input_s3_bucket_name"></a> [s3\_bucket\_name](#input\_s3\_bucket\_name) | The name of the S3 bucket where the Fullstory bundles are stored. | `string` | n/a | yes |
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The VPC ID where the Redshift cluster or Redshift Serverless workgroup is deployed. | `string` | n/a | yes |
Expand Down
5 changes: 2 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
locals {
fullstory_cidr_ipv4s = length(var.fullstory_cidr_ipv4s) > 0 ? var.fullstory_cidr_ipv4s : (var.fullstory_data_center == "EU1" ? ["34.89.210.80/29"] : ["8.35.195.0/29"])
fullstory_google_audience = var.fullstory_google_audience != "" ? var.fullstory_google_audience : (var.fullstory_data_center == "EU1" ? "107589159240321051166" : "116984388253902328461")
is_serverless = var.workgroup_arn != ""
}

data "aws_vpc" "main" {
Expand Down Expand Up @@ -80,14 +79,14 @@ resource "aws_s3_bucket_policy" "main" {
}

module "redshift_serverless" {
count = local.is_serverless ? 1 : 0
count = var.is_serverless ? 1 : 0
source = "./modules/serverless"
workgroup_arn = var.workgroup_arn
role_name = aws_iam_role.main.name
}

module "redshift_provisioned" {
count = local.is_serverless ? 0 : 1
count = var.is_serverless ? 0 : 1
source = "./modules/provisioned"
cluster_identifier = var.cluster_identifier
database_arn = var.database_arn
Expand Down
1 change: 1 addition & 0 deletions main.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ run "valid_serverless_minimal_details" {
vpc_id = "my-vpc"
workgroup_arn = "workgroup_arn"
s3_bucket_name = "my-bucket"
is_serverless = true
}

assert {
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ variable "fullstory_data_center" {
}
}

variable "is_serverless" {
type = bool
description = "Whether the Redshift cluster is serverless or not. If true, workgroup_arn is required. If false, database_arn is required."
}

variable "port" {
type = number
description = "The port number where the Redshift cluster is listening."
Expand Down

0 comments on commit e3a7c8c

Please sign in to comment.