Raw JSON / Dict in Troposphere Attribute

22 views
Skip to first unread message

Will Dawe

unread,
Feb 18, 2025, 5:51:05 AMFeb 18
to cloudtools-dev
I'm currently trying to define an EC2 ASG MixedInstancePolicy in my Troposphere script. I have an stack parameter which is a CommaDelimitedList of instance types, which i'd like to use in my MixedInstancePolicy.

However, i'm running into an issue whereby Troposphere requires certain attributes to be a specific class. I can't use raw JSON in certain places.

```
MixedInstancesPolicy={
"LaunchTemplate": {
"LaunchTemplateSpecification": LaunchTemplateSpecification(
LaunchTemplateId=Ref(launch_template),
Version=GetAtt(launch_template, "LatestVersionNumber")
),
"Overrides": {
"Fn::ForEach::InstanceTypes": [
"InstanceType",
Ref(instance_types),
[
LaunchTemplateOverrides(
InstanceType="${InstanceType}",
)
]
]
}
}
}
```
The above results in the below error:
```
TypeError: <class 'troposphere.autoscaling.AutoScalingGroup'>: ComponentAutoScalingGroup.MixedInstancesPolicy is <class 'dict'>, expected <class 'troposphere.autoscaling.MixedInstancesPolicy'>
```

Is there a way to override this requirement? So that I can use a dictionary instead of an expected class to output my required contents?

Many thanks :) 

Will Dawe

unread,
Feb 18, 2025, 7:28:52 AMFeb 18
to cloudtools-dev
Reply all
Reply to author
Forward
0 new messages