This repository contains additional exercises to the AWS Serverless Workshop - Image Processing.
If possible, please use eu-west-1
region. This is necessary for the API Gateway script. (TBD)
This exercise includes a Cloud Formation template to create the API in front of S3 to upload images. Please note: uploading images does not trigger Step Functions execution and should be performed manually.
- Navigate to Cloud Formation in your AWS account and click Create Stack.
- Find the template in
api/apigateway-setup.yaml
and upload it to Cloud Formation. - Give the name for the stack and paste the S3 Bucket name that you created during the AWS Serverless Workshop - Image Processing where the photos are stored.
- At the end of the 3rd step give AWS CloudFormation permission to "create IAM resources".
- Navigate to API Gateway, find the newly create API and get the public URL from Stages -> "dev". API is now ready to accept put requests.
This HTML page uses API Gateway created before to upload your jpeg images into S3 Bucket.
- In the
api
folder of this repository findindex.html
and replace<!!!API ID !!!>
with the correct API ID. - You can run it locally or try running with services like jsbin to testdrive it on your smartphone.
This exercise guide how to setup direct integration with SNS without the use of Lambda functions (difficulty: moderate). The complete documentation can be found here.
Before we begin, there are several ways to trigger SNS notifications from Step Functions. One of them is to use Lambda function, the skeleton for this function is provided in the original workshop. The second option is to trigger SNS directly from Step Functions and this exercise will show you how to do it.
- Open AWS Console and create new SNS topic, e.g.
PhotoDoesntMeetRequirementsTopic
. Copy the ARN of the new topic to the text editor. - Subscribe to the topic by opening it and clicking "Create subscription". Select email protocol and type your email. In few minutes you'll receive the email, please confirm the subscription using the link.
- Open AWS Console and navigate to IAM. Go to Roles and find role starting with
wildrydes-step-module-resources-StateMachineRole
. Now we need to update this role, so that the State Machine can access SNS. - Click "add inline policy", in the new dialog switch to JSON tab and paste the following policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sns:Publish"
],
"Resource": "*"
}
]
}
Add the name like snsPublish
6. Go back to Step Functions to alter the state machine. Locate the PhotoDoesNotMeetRequirement
and replace it with the following state
Please also replace <!!! Topic ARN !!!>
with ARN from step 1.
"PhotoDoesNotMeetRequirement": {
"Type": "Task",
"Resource": "arn:aws:states:::sns:publish",
"Parameters": {
"TopicArn": "<!!! Topic ARN !!!>",
"Message.$": "$.errorInfo.Error"
},
"End": true
},
- Create new execution with the same face to test your integarion works. In few minutes you'll receive an email with an error message.
(difficulty: high) If you feel ready for the challenge, please check the official documentation and try to implement the same for your solution.