Closed enrico-usai closed 2 years ago
Hey @enrico-usai,
Sorry for the long response time here. Unfortunately, there is no way to use the CloudFormationInit
class with a Launch Template. You'll have to submit a feature request if you'd like to be able to do this with the LaunchTemplate
class.
If you need to be able to use cfn-init for the launch template, you'll have to find a way to workaround that. I'm not too sure what the best workaround (if there are any) would be, but I can research that if you want.
Hi @peterwoodworth thanks for your answer.
I'm currently using the workaround of adding CloudFormation::Init
as a raw metadata:
my_launch_template = ec2.CfnLaunchTemplate(
self,
"MyLaunchTemplate",
launch_template_data=ec2.CfnLaunchTemplate.LaunchTemplateDataProperty(
[...]
}
cfn_init = {
"configSets": {
"default": [
"deployConfigFiles",
"chefPrepEnv",
"chefConfig",
"chefFinalize",
],
},
"deployConfigFiles": {
[...]
}
my_launch_template.add_metadata("AWS::CloudFormation::Init", cfn_init)
Anyway it would be good to have it natively supported.
@enrico-usai have you been successfully deploying and using this workaround? I ask because Rico said this about addMetadata
[This] is not how you're supposed to attach this. You're not writing CloudFormation templates.
This comment is why I didn't suggest this workaround for you, but I don't see why it wouldn't work fine. Let me know! I'll post a feature request to natively support this once I have confirmation your workaround works.
I know about that comment but I didn't have any alternative.
Yes the workaround is working correctly, we're using it for AWS ParallelCluster: https://github.com/aws/aws-parallelcluster/blob/develop/cli/src/pcluster/templates/cluster_stack.py#L1174
Converted this into a feature request, I can try to submit a PR for this at some point.
I'm not going to be able to work on this, and this issue is marked as p2, so no one on the team will be able to work on this soon.
We use +1s to help prioritize our work, and are happy to revaluate this issue based on community feedback. You can reach out to the cdk.dev community on Slack to solicit support for reprioritization.
Closing as duplicate of https://github.com/aws/aws-cdk/issues/6734
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
Hi,
It seems to me that
CloudFormationInit
is supported for Instances and for ASG but it's not yet supported forCfnLaunchTemplate
(I didn't findinit
parameter there).I'd like to add
CloudFormationInit.from_config_sets
to aCfnLaunchTemplate
, as requested in https://github.com/aws/aws-cdk/issues/11021 How can I do it?Thanks