Skip to content

Instantly share code, notes, and snippets.

@pedroduartecosta
Created October 27, 2018 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedroduartecosta/ac2df8d5abf38076464eb841d3bf18bf to your computer and use it in GitHub Desktop.
Save pedroduartecosta/ac2df8d5abf38076464eb841d3bf18bf to your computer and use it in GitHub Desktop.

Workshop instructions

  • Go to dynamo db

    • Create dynamoDB table
      • Table Name: posts
      • Primary key: id
      • Click create
  • Go to S3

    • Create s3 bucket
      • Bucket name: sinf-[your_name]
      • Click "Create" button
      • Click on the created bucket
      • Go to properties tab
      • Click on "Static website hosting"
      • Select "Use this bucket to host a website" and type "index.html" and then save
    • Create another bucket
      • Bucket name: sinf-mp3-[your_name]
      • Click "Create" button
  • Go to IAM (Identity Access Management)

    • Go to "Roles" on the left side panel
      • Click create a Role
        • Under "Choose the services that will use this role", click "Lambda"
        • Click "Next: Permissions"
        • Click "Create policy"
        • Click on the "JSON" tab
        • Copy the code from lambdapolicy.json to the editor
        • Click "Review Policy"
        • Write "myLambdaPollyPolicy" in the name and descriptions
        • Click "Create"
  • Go to IAM (Identity Access Management)

    • Go to "Roles" on the left side panel
      • Click create a Role
        • Under "Choose the services that will use this role", click "Lambda"
        • Search for the policy "myLambdaPollyPolicy"
        • Select that policy
        • CLick next
        • Write "MyLambdaRole" in the role name and description
  • Go to S3

    • Click on the bucket sinf-[your_name]
    • Go to "Permissions" tab
    • Click on "Bucket Policy"
    • Copy the code from bucketpolicypermissions.json to the editor
    • Change "BUCKET_NAME" in your code to your bucket name
    • Click "Save"
  • Go to SNS (Simple Notification Service)

    • Create a topic
      • Write "new_posts" on the Topic name
      • Write "SNSpolly" on the Display name
      • Click "Create topic"
      • Copy the "Topic ARN" to here: arn:aws:sns:eu-west-1:012092614597:new_posts
  • Go to Lambda

    • Click "Create function"
      • Write "PostReader_NewPosts" in the name field
      • Select Python 2.7 on Runtime
      • On "Role" select "Choose an existing role
      • On "Existing role" select "myLambdaPollyRole"
      • Click "Create function"
      • Copy the code from newposts.py to the editor
      • Click "Save"
      • Scroll down to Environment variables
        • Add variable "DB_TABLE_NAME" with value "posts"
        • Add variable "SNS_TOPIC" with the preivous saved Topic ARN
      • Scroll down to description
        • Write: "This function inserts data into DynamoDB"
      • Scroll up and hit Save
    • Click on test
      • Select "Create new test event"
      • Copy the code from sample.json to the editor
      • Hit "Create"
      • Click on "Test"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment