Hey folks, I’m using cdktf golang to build an ASG with a launch template. What I have is this:
provider.NewAwsProvider(stack, jsii.String("aws"), &provider.AwsProviderConfig{
Region: jsii.String("ap-northeast-1"),
})
serverLt := launchtemplate.NewLaunchTemplate(stack, jsii.String("serverLt"), &launchtemplate.LaunchTemplateConfig{})
autoscalinggroup.NewAutoscalingGroup(stack, jsii.String("serverAsg"), &autoscalinggroup.AutoscalingGroupConfig{
MaxSize: jsii.Number[float64](1),
MinSize: jsii.Number[float64](1),
LaunchTemplate: &autoscalinggroup.AutoscalingGroupLaunchTemplate{
Id: serverLt.Id(),
Version: serverLt.GetStringAttribute(jsii.String("latest_version")),
},
})
But the GetStringAttribute
feels a little rough.
In Typescript, I can take the (float) latestVersion
and simply call toString
to get a string-typed reference:
new AwsProvider(this, "aws", {
region: "ap-northeast-1"
})
const launchTemplate = new LaunchTemplate(this, "serverLt", {
name: "server",
})
new AutoscalingGroup(this, "serverAsg", {
name: "server",
minSize: 1,
maxSize: 1,
launchTemplate: {
id: launchTemplate.id,
version: launchTemplate.latestVersion.toString(),
}
})
But doing something like jsii.String(strconv.FormatFloat(*serverLt.LatestVersion(), 'E', -1, 64))
in golang ends up jamming a junk float value (-8.10956221259138E+298
) into the synthesized JSON.
Is there a cleaner API to get a string reference from a float64 reference in terraform-cdk-go?
Thanks in advance!
Mat