I have a custom module, which returns a single output - instance_mappings
const instanceMappingsOutput = new TerraformHclModule(this.stack, `${this.serviceName}-instance-type-filtering`, {
source: resolve(__dirname, "./instance-type-filtering"),
variables: {
gpu_type: "V100"
}
}).get("instance_mappings");
The output is an array of objects, i.e.
[
{
instance_type: "some_instance_type",
gpu_count: 1,
has_instant_storage: true
}
]
Now, I want to use the output to populate override property, which is an array, of CDK TF AutoScalingGroup
new AutoscalingGroup(this.stack, `${this.serviceName}-asg`, {
name: `${this.serviceName}-asg`,
...
mixedInstancesPolicy: {
...
launchTemplate: {
...
override:
},
}
})
})
In pure TF I want something like this:
override: [ for item in instanceMappingsOutput: {
instance_type: item.instance_type,
weight: item.gpu_count,
launch_template_tpecification: {
launch_template_id: ${item.has_instant_storage == true ? someTemplate.id : anotherTemplate.id}
}
}]
but I can’t figure out how to do this in CDK TF