AWS

AWS Developer Certification – My Plan

Below is my plan to obtain the AWS Developer Certification.

For each of the following areas listed further down, I am trying to do the following:

  • Read the FAQ’s
  • Practice in the console
  • Practice with the CLI and understand the functions\parameters
  • Review all HTTP codes
  • Review all defaults and limits
  • Review uniqueness of each area

Here are the areas I am covering in preparation for the exam.

  • EC2
  • S3
  • DynamoDB
  • SNS
  • SQS
  • VPC
  • ELB
  • Lambda
  • Route 53
  • RDS
  • SWF
  • Cloudformation
  • Elastic Beanstalk
  • API Gateway
  • Storage Gateway
  • EFS
  • CloudWatch
  • CloudTrail

The exam is only 55 questions, so i’m not sure how in depth the exam will go on each of these.  Regardless, its a good to review all of the areas!

AWS Consistency Models

S3 Consistency Model

  • Puts (New record) = Read-after-write consistency model
  • Updates and Deletes = Eventual consistency model

DynamoDB Consistency Model

  • Write = Eventual consistency model
  • Read = Eventual consistency model
  • Read  = Optional – Strong consistency model

Definitions

  • Read-after-write consistency model = New objects should be available with out delays to clients.
  • Eventual consistency model = “Eventually” all access attempts to a particular item will return the last updated value.  There is potential here for stale or old data reads while data replication occurs.
  • Strong consistency model = All access attempts (e.g. parallel) to a particular item return the same unique state.  Old\stale data reads are avoided, but it will cost you more.

Good information to know for any AWS certification tests…. 🙂

AmazonWebservices_Logo.svg_

AWS DynamoDB Throughput Capacity

Calculating throughput capacity!

Read capacity units

  • 1 strong consistent read per second up to 4 KB item
  • 2 eventually consistent reads per second up to 4 KB item

Write capacity unit

  • 1 write per second for an item up to 1 KB in size

Example: 1000 writes per 10 seconds @ 512 bytes evenly distributed.

Solution: 1000\10 = 100, 512 bytes rounded up = 1 KB, 100 write units

Good certification exam information… 🙂

AmazonWebservices_Logo.svg_

AWS Linux 2 – VirtualBox

So you want to run the AWS Linux 2 OS on your laptop for development purposes?  Its no problem now!

I followed the instructions (here) to get Linux 2 running with a VirtualBox VM.

These are the high-level steps I took.

  1. Create a cloud-init configuration ISO
    • Create my user-data and meta-data files
    • Validate the user-data YAML file syntax in a validator (important)
    • Create a new ISO with these 2 files on a linux server using genisoimage
      • genisoimage -output mySeed.iso -volid cidata -joliet – rock user-data meta-data
  2. Download the latest Linux 2 vdi file from AWS
  3. Copy the ISO file back to my Windows machine
  4. Create my new VM in VirtualBox (Linux\Other Linux 64-bit) using the new ISO and the downloaded vdi
    • IDE Primary Master = Linux 2 vdi file
    • IDE Secondary Master (Optical) = mySeed ISO file

VirtualBox.png

Now you should be able to startup your VM and connect via any user defined in your user-data file.

VirtualBox2.png

JMESPATH and Visual Studio Code

The default format in which AWS CLI data is returned is JSON.  The JSON data that is returned can be queried with the query language JMESPath.

For example, using the AWS CLI, I can list the details of the volumes associated with my CLI profile.  (aws ec2 describe-volumes)

Example output:

{
    “Volumes”: [{
        “AvailabilityZone”: “myZone”,
        “VolumeType”: “standard”,
        “VolumeId”: “myVolumeID1”,
        “State”: “in-use”,
        “SnapshotId”: “mySnapID”,
        “CreateTime”: “2017-01-02T00:55:03.000Z”,
        “Size”: 1
},
{
        “AvailabilityZone”: “myZone”,
        “VolumeType”: “standard”,
        “VolumeId”: “myVolumeID2”,
        “State”: “in-use”,
        “SnapshotId”: “mySnapID”,
        “CreateTime”: “2016-01-02T00:55:03.000Z”,
        “Size”: 1
    }]
}

Now, lets say there are many more volumes returned from this CLI command and from that output I want to find the volume(s) that were created before a specific date. (January 01, 2017)

I can utilize the query option on the AWS CLI command to return specifics from the JSON results.  (aws ec2 describe-volumes –query ‘Volumes[?CreateTime<`2017-01-01`].VolumeId’)

However, sometimes getting the JMESPath syntax correct is not always easily.  The extra tools that I utilize to help me are Visual Studio Code with the JMESPath plugin.

JMESPath

So with this VSCode plugin, you can quickly validate your JMESPath syntax if you need.  One note when using the “–query” option on the CLI is that the processing is happening on the Client machine, unlike the “–filter” option that happens on the server.

vscode.png

AWS Lambda and S3

Below are a couple of problems I ran into when writing a Python 2.7 Lambda function that created a file and then uploaded it to S3. (s3.upload_file)

  1. The file I was creating and writing to in the function was empty in S3 after the upload.
    • Turns out I needed the “( )” braces on the Python “close” command.  Silly issue, but took my like 20 minutes to figure out….
  2. In your Lambda function, you need to create your files under /tmp, which is your functions ephemeral storage.
    • fileName = ‘/tmp/’ + name

s3_image

EC2 – Run Instances – InstanceId

So you are creating EC2 instances from the AWS CLI and\or Python using BOTO 3 and you want to get the InstanceId afterwards.  Below are the method(s) I use in each scenario.

Create 1 EC2 Instance with AWS CLI:

Example Command:

aws ec2 run-instances --profile <value> --image-id <value> --security-group-ids <value> --count 1 --instance-type <value> --subnet-id <value> --query 'Instances[0].InstanceID'

Create multiple EC2 Instances with Python\Boto3:

Example Command:

ec2_session_client = session.client('ec2')
response = ec2_session_client.run_instances(ImageID="value",SecurityGroupIds=["value"],MaxCount=value,MinCount=value,InstanceType="value",SubnetId="value")
for instance in response["Instances"]:
   if 'InstanceId' in instance"
      print (instance['InstanceId'])

So these are just a couple ways to grab the InstanceId for use later in your script.

aws_instanceid.png