AWS EC2 Essentials
Meta Data
curl http://169.254.169.254/latest/meta-data/placement/availability-zone
curl http://169.254.169.254/latest/meta-data/instance-id
curl http://169.254.169.254/latest/meta-data/public-ipv4
curl http://169.254.169.254/latest/meta-data/local-ipv4
CloudFormation
Most basic template
EC2Instance:
Type: AWS::EC2::Instance
Properties:
ImageId: ami-999999999
Sample Bootstrap Scripts
#!/bin/bash
yum update -y
yum install httpd -y
echo "<html><body><h1>Hello World</h1></body></html>" >/var/www/html/index.html
systemctl start httpd
systemctl enable httpd
#!/bin/bash
yum update -y
yum install -y httpd
yum install -y curl
chkconfig httpd on
service httpd start
Related
Links
- https://aws.amazon.com/ec2/
- https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
- https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volume-types.html
- https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-ec2.html
- https://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html
- https://aws.amazon.com/blogs/compute/query-for-the-latest-amazon-linux-ami-ids-using-aws-systems-manager-parameter-store/