aws cli 在 create-image 命令上返回未知选项
aws cli returning unknown options on create-image command
我正在 运行ning 下面的命令从带有标签的现有 ec2 服务器创建 ami。下面是我在 redhat linux 8.3
上用于 运行 的命令
aws ec2 create-image --instance-id $instance_id --name "$ami_name" --region $region --description "$desc" --no-reboot --tags-specifications 'ResourceType=image,Tags=[{Key='Owner',Value='Some_one'},{Key='Environment',Value='Production:Dev'},{Key='Stack',Value='ETL'},{Key='Role',Value='Database'}]'
我正在正确替换所有变量,但是 --tags-specifications 有一些问题。
我尝试了以下带有标签规范的选项,但其中 none 对我有用。
--tags-specifications 'ResourceType=image,Tags=[{Key=Owner,Value="Some_one"},{Key=Environment,Value="Production:Dev"},{Key=Stack,Value="ETL"},{Key=Role,Value="Database"}]'
--tags-specifications 'ResourceType=image,Tags=[{Key=Owner,Value=Some_one},{Key=Environment,Value=Production:Dev},{Key=Stack,Value=ETL},{Key=Role,Value=Database}]'
--tags-specifications 'ResourceType=image,Tags=[{Key='Owner',Value="Some_one"},{Key='Environment',Value="Production:Dev"},{Key='Stack',Value="ETL"},{Key='Role',Value="Database"}]'
--tags-specifications, ResourceType=image,Tags=[{Key="Owner",Value="Some_one"},{Key="Environment",Value="Non-Production:Dev"},{Key="Stack",Value="ETL"},{Key="Role",Value="Database"}]
谁能告诉我这里出了什么问题?
应该是--tag-specifications
:
aws ec2 create-image --instance-id $instance_id --name "$ami_name" --region $region --description "$desc" --no-reboot --tag-specifications 'ResourceType=image,Tags=[{Key='Owner',Value='Some_one'},{Key='Environment',Value='Production:Dev'},{Key='Stack',Value='ETL'},{Key='Role',Value='Database'}]'
您没有指定错误是什么或您使用的 aws cli 版本。当您使用 --tag-specification 更正拼写错误时,我猜问题可能出在您使用的 aws-cli 版本上。
在 December 2020 之前,AWS 没有在图像创建期间添加标签的选项。如果您碰巧有几个月前的 aws-cli 版本,当您 运行 创建图像和添加标签的命令时,您可能会收到类似以下的错误:
unknown options: --tag-specifications, ResourceType=image,Tags=[{Key=somekey,Value=some value}]
如果是这种情况,请尝试升级您的 aws cli。不确定你是如何安装它的,但如果你使用 pip,假设你确实可以访问更高版本,类似下面的东西应该升级它:
python3 -m pip install awscli --upgrade
我正在 运行ning 下面的命令从带有标签的现有 ec2 服务器创建 ami。下面是我在 redhat linux 8.3
上用于 运行 的命令aws ec2 create-image --instance-id $instance_id --name "$ami_name" --region $region --description "$desc" --no-reboot --tags-specifications 'ResourceType=image,Tags=[{Key='Owner',Value='Some_one'},{Key='Environment',Value='Production:Dev'},{Key='Stack',Value='ETL'},{Key='Role',Value='Database'}]'
我正在正确替换所有变量,但是 --tags-specifications 有一些问题。 我尝试了以下带有标签规范的选项,但其中 none 对我有用。
--tags-specifications 'ResourceType=image,Tags=[{Key=Owner,Value="Some_one"},{Key=Environment,Value="Production:Dev"},{Key=Stack,Value="ETL"},{Key=Role,Value="Database"}]'
--tags-specifications 'ResourceType=image,Tags=[{Key=Owner,Value=Some_one},{Key=Environment,Value=Production:Dev},{Key=Stack,Value=ETL},{Key=Role,Value=Database}]'
--tags-specifications 'ResourceType=image,Tags=[{Key='Owner',Value="Some_one"},{Key='Environment',Value="Production:Dev"},{Key='Stack',Value="ETL"},{Key='Role',Value="Database"}]'
--tags-specifications, ResourceType=image,Tags=[{Key="Owner",Value="Some_one"},{Key="Environment",Value="Non-Production:Dev"},{Key="Stack",Value="ETL"},{Key="Role",Value="Database"}]
谁能告诉我这里出了什么问题?
应该是--tag-specifications
:
aws ec2 create-image --instance-id $instance_id --name "$ami_name" --region $region --description "$desc" --no-reboot --tag-specifications 'ResourceType=image,Tags=[{Key='Owner',Value='Some_one'},{Key='Environment',Value='Production:Dev'},{Key='Stack',Value='ETL'},{Key='Role',Value='Database'}]'
您没有指定错误是什么或您使用的 aws cli 版本。当您使用 --tag-specification 更正拼写错误时,我猜问题可能出在您使用的 aws-cli 版本上。
在 December 2020 之前,AWS 没有在图像创建期间添加标签的选项。如果您碰巧有几个月前的 aws-cli 版本,当您 运行 创建图像和添加标签的命令时,您可能会收到类似以下的错误:
unknown options: --tag-specifications, ResourceType=image,Tags=[{Key=somekey,Value=some value}]
如果是这种情况,请尝试升级您的 aws cli。不确定你是如何安装它的,但如果你使用 pip,假设你确实可以访问更高版本,类似下面的东西应该升级它:
python3 -m pip install awscli --upgrade