Skip to content

Commit e3a7c8c

Browse files
authored
fix: use is_serverless so that output is deterministic (#6)
1 parent 89d49c0 commit e3a7c8c

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ This module creates all the proper policies, roles and S3 buckets so that Fullst
2525
| <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 |
2626
| <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 |
2727
| <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 |
28+
| <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 |
2829
| <a name="input_port"></a> [port](#input\_port) | The port number where the Redshift cluster is listening. | `number` | `5439` | no |
2930
| <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 |
3031
| <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 |

main.tf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
locals {
22
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"])
33
fullstory_google_audience = var.fullstory_google_audience != "" ? var.fullstory_google_audience : (var.fullstory_data_center == "EU1" ? "107589159240321051166" : "116984388253902328461")
4-
is_serverless = var.workgroup_arn != ""
54
}
65

76
data "aws_vpc" "main" {
@@ -80,14 +79,14 @@ resource "aws_s3_bucket_policy" "main" {
8079
}
8180

8281
module "redshift_serverless" {
83-
count = local.is_serverless ? 1 : 0
82+
count = var.is_serverless ? 1 : 0
8483
source = "./modules/serverless"
8584
workgroup_arn = var.workgroup_arn
8685
role_name = aws_iam_role.main.name
8786
}
8887

8988
module "redshift_provisioned" {
90-
count = local.is_serverless ? 0 : 1
89+
count = var.is_serverless ? 0 : 1
9190
source = "./modules/provisioned"
9291
cluster_identifier = var.cluster_identifier
9392
database_arn = var.database_arn

main.tftest.hcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ run "valid_serverless_minimal_details" {
77
vpc_id = "my-vpc"
88
workgroup_arn = "workgroup_arn"
99
s3_bucket_name = "my-bucket"
10+
is_serverless = true
1011
}
1112

1213
assert {

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ variable "fullstory_data_center" {
3636
}
3737
}
3838

39+
variable "is_serverless" {
40+
type = bool
41+
description = "Whether the Redshift cluster is serverless or not. If true, workgroup_arn is required. If false, database_arn is required."
42+
}
43+
3944
variable "port" {
4045
type = number
4146
description = "The port number where the Redshift cluster is listening."

0 commit comments

Comments
 (0)