Skip to content

Commit ffe5198

Browse files
authored
feat: Support has been removed from the DA for creating a new resource group<br>- existing_resource_group and resource_group_name inputs have been replaced by new input existing_resource_group_name (with a default value of Default) (#177)
BREAKING CHANGE: If you are upgrading from a previous release and creating a new resource group as part of the DA, resources will be recreated if you are not using the Default resource group
1 parent d4f74a7 commit ffe5198

File tree

9 files changed

+55
-56
lines changed

9 files changed

+55
-56
lines changed

cra-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ CRA_TARGETS:
66
PROFILE_ID: "fe96bd4d-9b37-40f2-b39f-a62760e326a3" # SCC profile ID (currently set to 'IBM Cloud Framework for Financial Services' '1.7.0' profile).
77
CRA_ENVIRONMENT_VARIABLES:
88
TF_VAR_provider_visibility: "public"
9-
TF_VAR_resource_group_name: "resource_group_name_temp"
9+
TF_VAR_existing_resource_group_name: "geretain-test-resources"
1010
TF_VAR_app_name: "app-name"
1111
TF_VAR_image_reference: "icr.io/codeengine/helloworld"
1212
TF_VAR_project_name: "project-name"
@@ -16,7 +16,7 @@ CRA_TARGETS:
1616
PROFILE_ID: "fe96bd4d-9b37-40f2-b39f-a62760e326a3" # SCC profile ID (currently set to 'IBM Cloud Framework for Financial Services' '1.7.0' profile).
1717
CRA_ENVIRONMENT_VARIABLES:
1818
TF_VAR_provider_visibility: "public"
19-
TF_VAR_resource_group_name: "resource_group_name_temp"
19+
TF_VAR_existing_resource_group_name: "geretain-test-resources"
2020
TF_VAR_project_name: "project-name"
2121
TF_VAR_prefix: "test"
2222
# SCC_INSTANCE_ID: "" # The SCC instance ID to use to download profile for CRA scan. If not provided, a default global value will be used.

ibm_catalog.json

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,16 @@
145145
"required": true
146146
},
147147
{
148-
"key": "existing_resource_group"
149-
},
150-
{
151-
"key": "resource_group_name"
148+
"key": "existing_resource_group_name",
149+
"required": true,
150+
"custom_config": {
151+
"type": "resource_group",
152+
"grouping": "deployment",
153+
"original_grouping": "deployment",
154+
"config_constraints": {
155+
"identifier": "rg_name"
156+
}
157+
}
152158
},
153159
{
154160
"key": "region",
@@ -314,10 +320,16 @@
314320
"required": true
315321
},
316322
{
317-
"key": "existing_resource_group"
318-
},
319-
{
320-
"key": "resource_group_name"
323+
"key": "existing_resource_group_name",
324+
"required": true,
325+
"custom_config": {
326+
"type": "resource_group",
327+
"grouping": "deployment",
328+
"original_grouping": "deployment",
329+
"config_constraints": {
330+
"identifier": "rg_name"
331+
}
332+
}
321333
},
322334
{
323335
"key": "region",

solutions/apps/catalogValidationValues.json.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"ibmcloud_api_key": $VALIDATION_APIKEY,
3-
"resource_group_name": $PREFIX,
3+
"existing_resource_group_name": "geretain-test-resources",
44
"project_name": $PREFIX,
55
"app_name": $PREFIX,
66
"image_reference": "icr.io/codeengine/helloworld"

solutions/apps/main.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
module "resource_group" {
66
source = "terraform-ibm-modules/resource-group/ibm"
77
version = "1.2.0"
8-
resource_group_name = var.existing_resource_group == false ? var.resource_group_name : null
9-
existing_resource_group_name = var.existing_resource_group == true ? var.resource_group_name : null
8+
existing_resource_group_name = var.existing_resource_group_name
109
}
1110

1211
locals {

solutions/apps/variables.tf

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,10 @@ variable "prefix" {
3131
nullable = true
3232
}
3333

34-
variable "existing_resource_group" {
35-
type = bool
36-
description = "Whether to use an existing resource group."
37-
default = false
38-
}
39-
40-
variable "resource_group_name" {
34+
variable "existing_resource_group_name" {
4135
type = string
42-
description = "The name of a new or an existing resource group to provision the IBM Cloud Code Engine resources to."
36+
description = "The name of an existing resource group to provision the resources."
37+
default = "Default"
4338
}
4439

4540
variable "project_name" {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"ibmcloud_api_key": $VALIDATION_APIKEY,
3-
"resource_group_name": $PREFIX,
3+
"existing_resource_group_name": "geretain-test-resources",
44
"prefix": $PREFIX,
55
"project_name": "project1"
66
}

solutions/project/main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
module "resource_group" {
66
source = "terraform-ibm-modules/resource-group/ibm"
77
version = "1.2.0"
8-
resource_group_name = var.existing_resource_group == false ? var.resource_group_name : null
9-
existing_resource_group_name = var.existing_resource_group == true ? var.resource_group_name : null
8+
existing_resource_group_name = var.existing_resource_group_name
109
}
10+
1111
locals {
1212
prefix = var.prefix != null ? trimspace(var.prefix) != "" ? "${var.prefix}-" : "" : ""
1313
}
14+
1415
########################################################################################################################
1516
# Code Engine Project
1617
########################################################################################################################

solutions/project/variables.tf

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,10 @@ variable "region" {
2929
default = "us-south"
3030
}
3131

32-
variable "existing_resource_group" {
33-
type = bool
34-
description = "Whether to use an existing resource group."
35-
default = false
36-
}
37-
38-
variable "resource_group_name" {
32+
variable "existing_resource_group_name" {
3933
type = string
40-
description = "The name of a new or an existing resource group to provision the IBM Cloud Code Engine resources to."
34+
description = "The name of an existing resource group to provision the resources."
35+
default = "Default"
4136
}
4237

4338
variable "project_name" {

tests/pr_test.go

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const resourceGroup = "geretain-test-resources"
1717
const appsExampleDir = "examples/apps"
1818
const jobsExampleDir = "examples/jobs"
1919
const appsSolutionsDir = "solutions/apps"
20+
const projectSolutionsDir = "solutions/project"
2021

2122
// Define a struct with fields that match the structure of the YAML data
2223
const yamlLocation = "../common-dev-assets/common-go-assets/common-permanent-resources.yaml"
@@ -132,8 +133,7 @@ func TestRunAppSolutionInSchematics(t *testing.T) {
132133

133134
options.TerraformVars = []testschematic.TestSchematicTerraformVar{
134135
{Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true},
135-
{Name: "resource_group_name", Value: options.ResourceGroup, DataType: "string"},
136-
{Name: "existing_resource_group", Value: true, DataType: "bool"},
136+
{Name: "existing_resource_group_name", Value: options.ResourceGroup, DataType: "string"},
137137
{Name: "prefix", Value: options.Prefix, DataType: "string"},
138138
{Name: "app_name", Value: options.Prefix + "-app", DataType: "string"},
139139
{Name: "image_reference", Value: "icr.io/codeengine/helloworld", DataType: "string"},
@@ -163,16 +163,15 @@ func TestRunUpgradeAppSolution(t *testing.T) {
163163
},
164164
}
165165
options.TerraformVars = map[string]interface{}{
166-
"ibmcloud_api_key": options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"],
167-
"resource_group_name": resourceGroup,
168-
"existing_resource_group": true,
169-
"app_name": options.Prefix + "-app",
170-
"image_reference": "icr.io/codeengine/helloworld",
171-
"provider_visibility": "public",
172-
"prefix": options.Prefix,
173-
"secrets": "{" + options.Prefix + "-secret:{format:\"generic\", data:{ key_1 : \"value_1\" }}}", // pragma: allowlist secret
174-
"config_maps": "{" + options.Prefix + "-cm:{data:{ key_1 : \"value_1\" }}}",
175-
"project_name": options.Prefix + "-pro",
166+
"ibmcloud_api_key": options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"],
167+
"existing_resource_group_name": resourceGroup,
168+
"app_name": options.Prefix + "-app",
169+
"image_reference": "icr.io/codeengine/helloworld",
170+
"provider_visibility": "public",
171+
"prefix": options.Prefix,
172+
"secrets": "{" + options.Prefix + "-secret:{format:\"generic\", data:{ key_1 : \"value_1\" }}}", // pragma: allowlist secret
173+
"config_maps": "{" + options.Prefix + "-cm:{data:{ key_1 : \"value_1\" }}}",
174+
"project_name": options.Prefix + "-pro",
176175
}
177176

178177
output, err := options.RunTestUpgrade()
@@ -187,16 +186,15 @@ func TestUpgradeCEProjectDA(t *testing.T) {
187186

188187
options := testhelper.TestOptionsDefault(&testhelper.TestOptions{
189188
Testing: t,
190-
TerraformDir: "solutions/project",
189+
TerraformDir: projectSolutionsDir,
191190
Prefix: "ce-da",
192191
})
193192

194193
options.TerraformVars = map[string]interface{}{
195-
"resource_group_name": resourceGroup,
196-
"existing_resource_group": true,
197-
"provider_visibility": "public",
198-
"prefix": options.Prefix,
199-
"project_name": "test-1",
194+
"existing_resource_group_name": resourceGroup,
195+
"provider_visibility": "public",
196+
"prefix": options.Prefix,
197+
"project_name": "test-1",
200198
}
201199

202200
output, err := options.RunTestUpgrade()
@@ -212,16 +210,15 @@ func TestDeployCEProjectDA(t *testing.T) {
212210

213211
options := testhelper.TestOptionsDefault(&testhelper.TestOptions{
214212
Testing: t,
215-
TerraformDir: "solutions/project",
213+
TerraformDir: projectSolutionsDir,
216214
Prefix: "ce-da",
217215
})
218216

219217
options.TerraformVars = map[string]interface{}{
220-
"resource_group_name": resourceGroup,
221-
"existing_resource_group": true,
222-
"prefix": options.Prefix,
223-
"provider_visibility": "public",
224-
"project_name": "test-1",
218+
"existing_resource_group_name": resourceGroup,
219+
"prefix": options.Prefix,
220+
"provider_visibility": "public",
221+
"project_name": "test-1",
225222
}
226223

227224
output, err := options.RunTestConsistency()

0 commit comments

Comments
 (0)