Skip to content

Commit 8e67552

Browse files
authored
chore: Terraform Example Code Optimized (#504)
1 parent 4c7b258 commit 8e67552

File tree

6 files changed

+11
-14
lines changed

6 files changed

+11
-14
lines changed

cra-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ CRA_TARGETS:
44
- CRA_TARGET: "examples/default" # 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+
CRA_ENVIRONMENT_VARIABLES:
8+
TF_VAR_region: "us-south"
9+
TF_VAR_prefix: "vpe"
710
# 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.
811
# SCC_REGION: "" # The IBM Cloud region that the SCC instance is in. If not provided, a default global value will be used.
912
# 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.

examples/default/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module "vpc" {
2121
resource_group_id = module.resource_group.resource_group_id
2222
region = var.region
2323
prefix = var.prefix
24-
name = var.vpc_name
24+
name = "vpc-instance"
2525
tags = var.resource_tags
2626
}
2727

@@ -79,7 +79,7 @@ module "vpes" {
7979
source = "../../"
8080
region = var.region
8181
prefix = var.prefix
82-
vpc_name = var.vpc_name
82+
vpc_name = "vpc-instance"
8383
vpc_id = var.vpc_id != null ? var.vpc_id : module.vpc[0].vpc_id
8484
subnet_zone_list = var.vpc_id != null ? var.subnet_zone_list : module.vpc[0].subnet_zone_list
8585
resource_group_id = module.resource_group.resource_group_id

examples/default/variables.tf

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ variable "ibmcloud_api_key" {
77
variable "region" {
88
description = "The region where VPC and services are deployed"
99
type = string
10-
default = "us-south"
1110
}
1211

1312
variable "prefix" {
1413
description = "The prefix that you would like to append to your resources"
1514
type = string
16-
default = "vpe"
1715
}
1816

1917
variable "resource_group" {
@@ -26,12 +24,6 @@ variable "resource_group" {
2624
# VPC Variables
2725
##############################################################################
2826

29-
variable "vpc_name" {
30-
description = "Name of the VPC where the Endpoint Gateways will be created. This value is used to dynamically generate VPE names. It is also used to create a VPC when the vpc_id input is set to null."
31-
type = string
32-
default = "vpc-instance"
33-
}
34-
3527
variable "vpc_id" {
3628
description = "ID of the VPC where the Endpoint Gateways will be created. Creates a VPC if set to null."
3729
type = string

examples/default/versions.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
terraform {
66
required_version = ">= 1.3.0, <1.7.0"
7+
# Ensure that there is always 1 example locked into the lowest provider version of the range defined in the main
8+
# module's version.tf (basic or default), and 1 example that will always use the latest provider version.
79
required_providers {
810
ibm = {
911
source = "IBM-Cloud/ibm"
1012
# pin above lowest vesion, required for postgresql and IAM auth policy
11-
version = ">=1.61.0, <2.0.0"
13+
version = "1.61.0"
1214
}
1315
time = {
1416
source = "hashicorp/time"

examples/every-mt-vpe/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 "region" {
88
description = "The region where VPC and services are deployed"
99
type = string
10-
default = "us-south"
1110
}
1211

1312
variable "prefix" {
1413
description = "The prefix that you would like to append to your resources"
1514
type = string
16-
default = "vpe"
1715
}
1816

1917
variable "resource_group" {

examples/every-mt-vpe/versions.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
terraform {
66
required_version = ">= 1.3.0, <1.7.0"
7+
# Ensure that there is always 1 example locked into the lowest provider version of the range defined in the main
8+
# module's version.tf (basic or default), and 1 example that will always use the latest provider version.
79
required_providers {
810
ibm = {
911
source = "IBM-Cloud/ibm"
1012
# pin above lowest vesion, required for postgresql and IAM auth policy
11-
version = ">=1.61.0, <2.0.0"
13+
version = ">=1.61.0"
1214
}
1315
}
1416
}

0 commit comments

Comments
 (0)