Skip to content

Instantly share code, notes, and snippets.

@initcron
Last active August 29, 2015 14:18
Show Gist options
  • Select an option

  • Save initcron/8467a024a169625a0dc8 to your computer and use it in GitHub Desktop.

Select an option

Save initcron/8467a024a169625a0dc8 to your computer and use it in GitHub Desktop.
knife-ec2
sudo yum install patch libxml2-devel libxslt
sudo /opt/chef/embedded/bin/gem install knife-ec2 --no-ri --no-rdoc
# Add the following to knife.rb
# region: oregon
knife[:aws_access_key_id] = "Your AWS Access Key ID"
knife[:aws_secret_access_key] = "Your AWS Secret Access Key"
knife[:region] = "us-west-2"
#validate
knife ec2 flavor list
# Create ec2 instance with knife
knife ec2 server create \
-r "recipe[motd]" \
-I ami-e7527ed7 --flavor t2.micro \
-g <VPC_SEC_GRP_ID> \
-x ec2-user -N server01 \
–ssh-key <YOUR_KEYPAIR> \
-i <SSH_KEY> -s <VPC_SUBNET_ID> \
--associate-public-ip --server-connect-attribute public_ip_address \
--region us-west-2
e.g.
knife ec2 server create \
-r "recipe[motd]" -I ami-e7527ed7 \
--flavor t2.micro -g sg-c3576ca6 \
-x ec2-user -N server01 \
-i ~/.ssh/gshah2k10.pem \
--subnet subnet-5c8f3a2b \
--region us-west-2 --ssh-key gshah2k10 \
--associate-public-ip --server-connect-attribute public_ip_address
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment