Chapter 4. Programming your infrastructure: the command line, SDKs, and CloudFormation
Listing 4.1. Infrastructure description in JIML
Listing 4.2. Linear flow of commands in pseudo language
Listing 4.3. Creating and terminating a server from the CLI (Bash)
Listing 4.4. Creating and terminating a server from the CLI (PowerShell)
Listing 4.6. CloudFormation template structure
Listing 4.7. CloudFormation parameter structure
Listing 4.8. CloudFormation resources structure
Listing 4.9. CloudFormation EC2 server resource
Listing 4.10. CloudFormation outputs structure
Listing 4.11. CloudFormation outputs example
Listing 4.12. Template to create an EC2 instance with CloudFormation
Chapter 5. Automating deployment: CloudFormation, Elastic Beanstalk, and OpsWorks
Listing 5.1. Deploying a VPN server to a virtual server: CloudFormation and a shell script
Listing 5.2. Parts of a CloudFormation template to start a virtual server with user data
Listing 5.3. Installing packages and writing configuration files on server startup
Listing 5.4. Describing the status of the Elastic Beanstalk environment
Listing 5.5. Creating a custom firewall with the help of CloudFormation
Chapter 6. Securing your system: IAM, security groups, and VPC
Listing 6.1. Installing security updates on all running EC2 instances
Listing 6.2. Empty security group associated with a single EC2 instance
Listing 6.3. Security group that allows ICMP
Listing 6.4. Security group that allows SSH
Listing 6.5. Security group that allows SSH only from specific IP address
Listing 6.6. Security group that allows SSH from bastion host
Chapter 7. Storing your objects: S3 and Glacier
Listing 7.1. Uploading an image with the AWS SDK for S3
Listing 7.2. Retrieving all the image locations from the S3 bucket
Listing 7.3. Template to render the data as HTML
Listing 7.4. Bucket policy allowing read-only access to every object in a bucket
Chapter 8. Storing your data on hard drives: EBS and instance store
Listing 8.1. Connecting an instance store with an EC2 instance with CloudFormation
Listing 8.2. Security groups for NFS
Listing 8.3. NFS server and volume
Chapter 9. Using a relational database service: RDS
Listing 9.1. Extract from the CloudFormation template setting up an RDS database
Listing 9.2. Checking the state of the CloudFormation stack
Listing 9.3. Describing a MySQL RDS database instance
Listing 9.4. Modifying an RDS database’s snapshot time frame and retention time
Listing 9.5. IAM policy allowing access to manage RDS
Listing 9.6. CloudFormation template extract: firewall rules for an RDS database
Listing 9.7. Modifying the RDS database by enabling high availability
Listing 9.8. Modifying the instance type to improve performance of an RDS database
Listing 9.9. Modifying the storage type to improve performance of an RDS database
Chapter 10. Programming for the NoSQL database service: DynamoDB
Listing 10.1. CLI description language docopt: using nodetodo (cli.txt)
Listing 10.2. nodetodo: using docopt in Node.js (index.js)
Listing 10.3. nodetodo: adding a user (index.js)
Listing 10.4. nodetodo: adding a task (index.js)
Listing 10.5. nodetodo: retrieving a user (index.js)
Listing 10.6. nodetodo: retrieving tasks (index.js)
Listing 10.7. nodetodo: retrieving tasks from a category index (index.js)
Listing 10.8. nodetodo: retrieving all users with paging (index.js)
Listing 10.9. nodetodo: removing a user (index.js)
Chapter 11. Achieving high availability: availability zones, auto-scaling, and CloudWatch
Listing 11.1. Creating a CloudWatch alarm to monitor the health of an EC2 instance
Listing 11.2. Starting an EC2 instance running a Jenkins CI server with a recovery alarm
Listing 11.3. Configuring an auto-scaling group and a launch configuration
Listing 11.4. Jenkins CI server with auto-scaling in two availability zones
Listing 11.5. Updating the image a new virtual server starts from in case of recovery
Chapter 12. Decoupling your infrastructure: ELB and SQS
Listing 12.1. Creating a load balancer and connecting it with an auto-scaling group
Listing 12.2. ELB health checks to determine whether a server can answer requests
Listing 12.3. ELB handling plain TCP traffic (not only HTTP)
Listing 12.4. Terminating SSL with ELB to offer encrypted communication
Listing 12.6. Activating access logs written by ELB
Listing 12.7. index.js: sending a message to the queue
Listing 12.8. worker.js: receiving a message from the queue
Listing 12.9. worker.js: processing a message (take screenshot and upload to S3)
Listing 12.10. worker.js: acknowledging a message (deletes the message from the queue)
Chapter 13. Designing for fault-tolerance
Listing 13.1. Initializing the Imagery server (server/server.js)
Listing 13.2. Imagery server: POST /image creates an image process
Listing 13.3. Imagery server: GET /image/:id looks up an image process
Listing 13.4. Imagery server: POST /image/:id/upload uploads an image
Listing 13.5. Initializing the Imagery worker (worker/worker.js)
Listing 13.6. Imagery worker: POST /sqs handles SQS messages
Listing 13.7. Imagery CloudFormation template: S3, DynamoDB, and SQS
Listing 13.8. Imagery CloudFormation template: Elastic Beanstalk for the server
Listing 13.9. Imagery CloudFormation template: Elastic Beanstalk for the worker
Chapter 14. Scaling up and down: auto-scaling and CloudWatch
Listing 14.1. Auto-scaling for a web app with multiple EC2 instances
Listing 14.2. Scheduling a one-time scaling action
Listing 14.3. Scheduling a recurring scaling action that runs at 20:00 o’clock UTC every day
Listing 14.4. CloudWatch alarm based on CPU load of an auto-scaling group
Listing 14.5. Scaling policy that will add one server when triggered
Listing 14.6. Scalable and highly available WordPress setup (part 1 of 2)
Listing 14.7. Scalable and highly available WordPress setup (part 2 of 2)