1
votes

t2 instances only work with a VPC (as documented here: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/t2-instances.html#t2-instances-vpc-support). So when running via AWS CLI, how do I specify a VPC on the command line? I've followed the document here (http://docs.aws.amazon.com/codedeploy/latest/userguide/how-to-set-up-new-instance.html) and have the command line setup as outlined:

aws ec2 run-instances \
  --image-id amiID \
  --key-name keyName \
  --user-data file://instance-setup.sh \
  --count 1 \
  --instance-type instanceType \
  --iam-instance-profile Name=CodeDeployDemo-EC2-Instance-Profile

I realize using an m3 instance works as expected, but I'd like a t2.micro since this instance will only be used for deployment.

1
You need to set the --subnet-id of the command. Full docs: docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html - datasage

1 Answers

2
votes

The command will automatically use the Default VPC and a random subnet (which also selects the Availability Zone). If you wish to specify the VPC & Subnet, use --subnet-id parameter.

To select a T2 instance, be sure to include an instance type identifier, such as --instance-type t2.micro

Also, T2 instances require an AMI configured for HVM (Windows uses this by default, but Linux has a choice of PV or HVM).