Closed thomassuedbroecker closed 2 years ago
@thomassuedbroecker the bom variables scoped at the module level should use the input names specified in the respective module.yaml
file - not the fully expanded values expected in the final variables.tf
file.
Try using something like:
kind: BillOfMaterial
metadata:
name: my-bom
spec:
modules:
# Virtual Private Cloud
- name: ibm-vpc
variables:
- name: name
value: "tsued-gitops-sample"
- name: ibm-vpc-subnets
variables:
- name: _count
value: 1
iascable
will build this out to this BOM:
kind: BillOfMaterial
metadata:
name: my-bom
spec:
modules:
- name: ibm-vpc
alias: ibm-vpc
version: v1.16.0
variables:
- name: name
value: tsued-gitops-sample
- name: ibm-vpc-subnets
alias: ibm-vpc-subnets
version: v1.13.2
variables:
- name: _count
value: 1
- name: ibm-resource-group
alias: resource_group
version: v3.2.16
variables:
- name: region
type: string
description: The IBM Cloud region where the cluster will be/has been installed.
- name: ibmcloud_api_key
type: string
- name: ibm-vpc-subnets__count
type: number
description: The number of subnets that should be provisioned
defaultValue: 1
- name: resource_group_name
type: string
description: The name of the resource group
And you would find that in the output/my-bom/terraform/variables.tf
this:
...
variable "ibm-vpc-subnets__count" {
type = number
description = "The number of subnets that should be provisioned"
default = 1
}
...
This is not an issue with the vpc subnets module. This is incorrectly structured BOM yaml. if you want to specify values in the BOM for a module instance, then you need to add those variables within the module scope, and do not prefix the variables with the module name/alias. The variables block at the bottom can be used to set global-scope variables.
See an example here: https://github.com/IBM/automation-ibmcloud-infra-zos-dev/blob/main/110-ibm-zdev-network-vpc/bom.yaml#L157
You want something more like this:
apiVersion: cloud.ibm.com/v1alpha1
kind: BillOfMaterial
metadata:
name: my-bom
spec:
modules:
- name: ibm-vpc
alias: ibm-vpc
version: v1.16.0
variables:
- name: name
value: tsued-gitops-sample
- name: ibm-vpc-subnets
alias: ibm-vpc-subnets
version: v1.13.2
variables:
- name: _count
value: 1
- name: ibm-resource-group
alias: resource_group
version: v3.2.16
variables:
- name: region
type: string
description: The IBM Cloud region where the cluster will be/has been installed.
- name: ibmcloud_api_key
type: string
- name: resource_group_name
type: string
description: The name of the resource group
Variables are not transferred to the variables.tf file I want to create 1 subnet and not 3.
Here are the steps to reproduce:
Step 1: Create own BOM file
Step 2: Use iascable to build the needed files
Step 3: Verify created bom.yaml file
It contains the wrong number or better doesn't use the right value for the variable.
Step 4: Verify created
variables.tf
fileIt contains the wrong number or better doesn't use the right value for the variable.
Step 5: Verify the create evenvironment
The result is 3 subnets will be created and not 1.