Skip to content

Commit

Permalink
fix: add extra validation since KMS encryption is only supported on e…
Browse files Browse the repository at this point in the history
…nterprise plan (#45)
  • Loading branch information
Aayush-Abhyarthi authored Jun 30, 2023
1 parent 837cded commit 1e77aef
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
2 changes: 2 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
locals {
# Validation (approach based on https://github.com/hashicorp/terraform/issues/25609#issuecomment-1057614400)
# tflint-ignore: terraform_unused_declarations
validate_kms_plan = var.kms_encryption_enabled != null && var.plan != "enterprise-3nodes-2tb" ? tobool("kms encryption is only supported for enterprise plan") : true
# tflint-ignore: terraform_unused_declarations
validate_kms_values = !var.kms_encryption_enabled && var.kms_key_crn != null ? tobool("When passing values for var.kms_key_crn, you must set var.kms_encryption_enabled to true. Otherwise unset them to use default encryption") : true
# tflint-ignore: terraform_unused_declarations
validate_kms_vars = var.kms_encryption_enabled && var.kms_key_crn == null ? tobool("When setting var.kms_encryption_enabled to true, a value must be passed for var.kms_key_crn and/or var.backup_encryption_key_crn") : true
Expand Down
10 changes: 5 additions & 5 deletions module-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@
},
"pos": {
"filename": "main.tf",
"line": 53
"line": 55
}
},
"ibm_event_streams_topic.es_topic": {
Expand All @@ -335,7 +335,7 @@
},
"pos": {
"filename": "main.tf",
"line": 64
"line": 66
}
},
"ibm_iam_authorization_policy.kms_policy": {
Expand All @@ -352,7 +352,7 @@
},
"pos": {
"filename": "main.tf",
"line": 78
"line": 80
}
},
"ibm_resource_instance.es_instance": {
Expand All @@ -372,7 +372,7 @@
},
"pos": {
"filename": "main.tf",
"line": 28
"line": 30
}
}
},
Expand Down Expand Up @@ -452,7 +452,7 @@
},
"pos": {
"filename": "main.tf",
"line": 91
"line": 93
}
}
}
Expand Down
14 changes: 10 additions & 4 deletions tests/pr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,16 @@ func TestRunFSCloudExample(t *testing.T) {
t.Parallel()

options := testhelper.TestOptionsDefaultWithVars(&testhelper.TestOptions{
Testing: t,
TerraformDir: fsCloudTerraformDir,
Prefix: "es-fscloud",
ResourceGroup: resourceGroup,
Testing: t,
TerraformDir: fsCloudTerraformDir,
Prefix: "es-fscloud",
/*
Comment out the 'ResourceGroup' input to force this tests to create a unique resource group to ensure tests do
not clash. This is due to the fact that an auth policy may already exist in this resource group since we are
re-using a permanent HPCS instance. By using a new resource group, the auth policy will not already exist
since this module scopes auth policies by resource group.
*/
//ResourceGroup: resourceGroup,
BestRegionYAMLPath: regionSelectionPath,
TerraformVars: map[string]interface{}{
"existing_kms_instance_guid": permanentResources["hpcs_south"],
Expand Down

0 comments on commit 1e77aef

Please sign in to comment.