【发布时间】:2022-06-13 09:33:27
【问题描述】:
我的笔记本电脑上有 4 个环境变量,ami_id、instance_type、key_name 和 security_group_ids。我正在尝试使用这些变量创建启动模板版本,但我不知道如何将它们正确传递到 JSON 数组中
aws ec2 create-launch-template-version --launch-template-id lt-xxx --launch-template-data '{"ImageId":"$ami_id", "InstanceType": "$instance_type", "KeyName": "$key_name", "SecurityGroupIds": ["$security_group_ids"]}'
An error occurred (InvalidAMIID.Malformed) when calling the CreateLaunchTemplateVersion operation: The image ID '$ami_id' is not valid. The expected format is ami-xxxxxxxx or ami-xxxxxxxxxxxxxxxxx.
【问题讨论】:
-
看看使用合适的工具来生成 JSON(类似于
jq)。 stackoverflow.com/questions/48470049/… 可能会有所帮助
标签: json bash variables aws-cli