cloud-native-toolkit / iascable

IasCable is a node/typescript library to build installable component infrastructure components from a catalog of available modules
MIT License
13 stars 8 forks source link

Using example baseline-ocp.yaml give subnet errors #95

Open csantanapr opened 2 years ago

csantanapr commented 2 years ago

Use the following example

apiVersion: cloud.ibm.com/v1alpha1
kind: BillOfMaterial
metadata:
  name: baseline-ocp
spec:
  modules:
    - name: ibm-vpc-gateways
    - name: ibm-ocp-vpc
      variables:
        - name: flavor
          important: true
    - name: openshift-cicd

Run iascable

iascable build -i baseline-ocp.yaml

Run terraform

terraform init
terraform plan

Errors

│ Warning: Experimental feature "module_variable_optional_attrs" is active
│
│   on .terraform/modules/ibm-vpc-subnets/version.tf line 10, in terraform:
│   10:   experiments = [module_variable_optional_attrs]
│
│ Experimental features are subject to breaking changes in future minor or patch releases, based on feedback.
│
│ If you have feedback on the design of this feature, please open a GitHub issue to discuss it.
╵
╷
│ Error: Invalid value for module argument
│
│   on main.tf line 64, in module "ibm-vpc-subnets":
│   64:   acl_rules = var.ibm-vpc-subnets_acl_rules == null ? null : jsondecode(var.ibm-vpc-subnets_acl_rules)
│
│ The given value is not suitable for child module variable "acl_rules" defined at .terraform/modules/ibm-vpc-subnets/variables.tf:59,1-21: list of object required.
csantanapr commented 2 years ago

I think the problem is that the variable is being created with default value like this

variable "ibm-vpc-subnets_acl_rules" {
  type = string
  description = "List of rules to set on the subnet access control list"
  default = "\"[]\""
}
csantanapr commented 2 years ago

updating variables.tf default value then error goes away

variable "ibm-vpc-subnets_acl_rules" {
  type = string
  description = "List of rules to set on the subnet access control list"
  default = "[]"
}