Reputation: 151
Executing query:
aws ec2 run-instances --image-id ami-7a85a01a --security-group-ids sg-756ae512 --count 1 --instance-type t2.micro --tag-specifications ResourceType=instance,Tags=[{Key=webserver,Value=production}] --subnet-id subnet-cc0b0e8a
Its throwing an error saying:
Unknown options: --tag-specifications, ResourceType=instance,Tags=[{Key=webserver,Value=production}]
Does anybody know if this is depricated, or is the syntax different from expected? I've been running in circles with this.
Possible solution with new syntax:
aws ec2 run-instances --image-id ami-xxxxxxxxxx --security-group-ids sg-ef95c791 --count 1 --instance-type m4.2xlarge --key-name mypemkey --query Reservations[*].Instances[*].[PublicIpAddress,InstanceId]
The best I can come up with, seems to be working:
aws ec2 run-instances --image-id ami-7a85a01a --count 1 --instance-type t2.micro --key-name mykeypair --subnet-id sn-756ae512 --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=production}]' --associate-public-ip-address --output=text
Upvotes: 6
Views: 25596
Reputation: 189
Adding this as a possible solution. My issue was similar in terms of the error output, though I was dealing with the 'aws cloudfront update-continuous-deployment-config' command. Turns out the json I was passing to it was not in a compact form. I had to run it through jq to make it compact, and then everything was fine.
BEFORE CODE:
CF_CD_CONFIG=$(cat cf_cd_config.json)
AFTER CODE:
CF_CD_CONFIG=$(cat cf_cd_config.json | jq -c)
aws cloudfront update-continuous-deployment-policy --continuous-deployment-policy-config ${CF_CD_CONFIG} --id ${CF_CD__ID} --if-match ${CF_CD_ETAG}
Upvotes: 0
Reputation: 151
found an answer. Different syntax in the call: http://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html
edit:
QUERY=$(aws ec2 run-instances --image-id ${AMI_ID} --count 1 --instance-type t2.micro --key-name ${KEY_PAIR} --subnet-id ${SUBNET_ID} \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value='${EC2_TAG}'}]' --associate-public-ip-address --output=text )
Upvotes: 0
Reputation: 1461
Your syntax is correct, per the documentation; but your AWS client is too old to support the --tag-specifications
option.
[On OS X, at least] use pip install --upgrade --user awscli
to upgrade the client to the current version.
Upvotes: 2
Reputation: 126
I ran into this issue today and figured it out after an hour or so of struggling through the infamously horrendous AWS documentation.
The problem was that the installation instructions (pip install
and using the bundled installer) are just wrong: though the commands were copied perfectly and the requirements (specifically the "Python 2 version 2.6.5+ or Python 3 version 3.3+") were met, the aws-cli
package would never install/update past 1.11.13
.
The solution: use pip3 install
instead of pip install
. This updated it to 1.11.97
, which enabled the --tag-specifications
parameter. I don't know if this will solve the problem for you, but I suspect many Ubuntu users will experience this, so I decided to post it anyway.
Upvotes: 9
Reputation: 2943
You are missing a single quote for '
--tag-specifications value:
eg. from aws ec2 run-instances documentation:
aws ec2 run-instances --image-id ami-abc12345 --count 1 --instance-type t2.micro --key-name MyKeyPair --subnet-id subnet-6e7f829e --tag-specifications 'ResourceType=instance,Tags=[{Key=webserver,Value=production}]' 'ResourceType=volume,Tags=[{Key=cost-center,Value=cc123}]'
Upvotes: -1