如果您正在使用AWS CLI或AWS SDK等其他工具,则可以使用“modify-launch-template”操作来编辑模板,并设置“UserData”字段为空值。
示例代码:
AWS CLI:
aws ec2 modify-launch-template --launch-template-id TEMPLATE_ID --user-data ''
AWS SDK:
exports.handler = async (event) => { const ec2 = new AWS.EC2();
const params = {
LaunchTemplateData: {
UserData: ''
},
LaunchTemplateId: 'TEMPLATE_ID'
};
await ec2.modifyLaunchTemplate(params).promise();
return {
statusCode: 200,
body: 'Launch template updated successfully.'
};
};