Skip to content

Commit 734b155

Browse files
authored
chore: Terraform Example Code Optimized (#421)
1 parent 791c996 commit 734b155

File tree

18 files changed

+33
-29
lines changed

18 files changed

+33
-29
lines changed

cra-config.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ CRA_TARGETS:
44
- CRA_TARGET: "examples/multizone-rule" # Target directory for CRA scan. If not provided, the CRA Scan will not be run.
55
CRA_IGNORE_RULES_FILE: "cra-tf-validate-ignore-rules.json" # CRA Ignore file to use. If not provided, it checks the repo root directory for `cra-tf-validate-ignore-rules.json`
66
PROFILE_ID: "0e6e7b5a-817d-4344-ab6f-e5d7a9c49520" # SCC profile ID (currently set to the FSCloud 1.4.0 profile).
7-
# 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.
8-
# SCC_REGION: "" # The IBM Cloud region that the SCC instance is in. If not provided, a default global value will be used.
9-
# CRA_ENVIRONMENT_VARIABLES: # An optional map of environment variables for CRA, where the key is the variable name and value is the value. Useful for providing TF_VARs.
10-
# TF_VAR_sample: "sample value"
11-
# TF_VAR_other: "another value"
7+
CRA_ENVIRONMENT_VARIABLES: # An optional map of environment variables for CRA, where the key is the variable name and value is the value. Useful for providing TF_VARs.
8+
TF_VAR_region: "us-south"
9+
TF_VAR_prefix: "multizone-rule"

examples/fscloud/variables.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ variable "ibmcloud_api_key" {
77
variable "prefix" {
88
type = string
99
description = "Prefix to append to all vpc_zone_list, service_ref_zone_list and cbr_rule_description created by this submodule"
10-
default = "fs"
1110
}
1211

1312
variable "region" {
1413
description = "Name of the region to deploy into"
1514
type = string
16-
default = "us-south"
1715
}
1816

1917
variable "resource_group" {

examples/fscloud/version.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
terraform {
22
required_version = ">= 1.3.0, <1.7.0"
33
required_providers {
4-
# Pin to the lowest provider version of the range defined in the main module's version.tf to ensure lowest version still works
4+
# Ensure that there is always 1 example locked into the lowest provider version of the range defined in the main
5+
# module's version.tf (zone or multi zone rule), and 1 example that will always use the latest provider version (fscloud multi service profile and multi resource rule).
56
ibm = {
67
source = "IBM-Cloud/ibm"
7-
version = "1.62.0"
8+
version = ">= 1.62.0"
89
}
910
}
1011
}

examples/multi-resource-rule/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
module "resource_group" {
66
source = "terraform-ibm-modules/resource-group/ibm"
7-
version = "1.1.4"
7+
version = "1.1.5"
88
# if an existing resource group is not set (null) create a new one using prefix
99
resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null
1010
existing_resource_group_name = var.resource_group

examples/multi-resource-rule/variables.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ variable "ibmcloud_api_key" {
77
variable "prefix" {
88
type = string
99
description = "Prefix to append to all resources created by this example"
10-
default = "test-terraform-multirule"
1110
}
1211

1312
variable "region" {
1413
description = "Name of the Region to deploy into"
1514
type = string
16-
default = "us-south"
1715
}
1816

1917
variable "resource_group" {
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
terraform {
2-
required_version = ">= 1.3.0"
2+
required_version = ">= 1.3.0, <1.7.0"
33
required_providers {
4-
# Pin to the lowest provider version of the range defined in the main module's version.tf to ensure lowest version still works
4+
# Ensure that there is always 1 example locked into the lowest provider version of the range defined in the main
5+
# module's version.tf (zone or multi zone rule), and 1 example that will always use the latest provider version (fscloud multi service profile and multi resource rule).
56
ibm = {
67
source = "IBM-Cloud/ibm"
7-
version = "1.62.0"
8+
version = ">= 1.62.0"
89
}
910
}
1011
}

examples/multi-service-profile/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
module "resource_group" {
66
source = "terraform-ibm-modules/resource-group/ibm"
7-
version = "1.1.4"
7+
version = "1.1.5"
88
# if an existing resource group is not set (null) create a new one using prefix
99
resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null
1010
existing_resource_group_name = var.resource_group

examples/multi-service-profile/variables.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ variable "ibmcloud_api_key" {
77
variable "prefix" {
88
type = string
99
description = "Prefix to append to all resources created by this example"
10-
default = "test-terraform-multiservice"
1110
}
1211

1312
variable "region" {
1413
description = "Name of the Region to deploy into"
1514
type = string
16-
default = "us-south"
1715
}
1816

1917
variable "location" {
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
terraform {
22
required_version = ">= 1.3.0, <1.7.0"
33
required_providers {
4-
# Pin to the lowest provider version of the range defined in the main module's version.tf to ensure lowest version still works
4+
# Ensure that there is always 1 example locked into the lowest provider version of the range defined in the main
5+
# module's version.tf (zone or multi zone rule), and 1 example that will always use the latest provider version (fscloud multi service profile and multi resource rule).
56
ibm = {
67
source = "IBM-Cloud/ibm"
7-
version = "1.62.0"
8+
version = ">= 1.62.0"
89
}
910
}
1011
}

examples/multizone-rule/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22

33
An end-to-end example that uses the module's default variable values. This example uses the IBM Cloud Provider to automate the following infrastructure::
44

5+
- Creates a VPC
6+
- Creates a VPC Subnet
57
- Create two zones for context-based restrictions.
68
- Create a rule for context-based restrictions that uses the zone and attaches the service to it.

0 commit comments

Comments
 (0)