Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Serverless Architectures with AWS

You're reading from  Serverless Architectures with AWS

Product type Book
Published in Dec 2018
Publisher Packt
ISBN-13 9781789805024
Pages 226 pages
Edition 1st Edition
Languages
Concepts
Author (1):
Mohit Gupta Mohit Gupta
Profile icon Mohit Gupta
Toc

Chapter 2: Working with the AWS Serverless Platform


Solution for Activity 3: Setting up a Mechanism to Get an Email Alert When An Object is Uploaded into an S3 Bucket

  1. Go to the AWS S3 service and click on Create bucket.

  2. Provide a Bucket name and select the region where the S3 bucket will be created. Click on Next. Note that the bucket name can't be duplicated.

  3. If you want to change any configuration, you can do it here. Click on Next.

  4. Now, you can change the settings related to the security of the S3 bucket. If you want to allow public access to the S3 bucket, you can uncheck the options here. Click on Next.

  5. Review all of the configuration settings. If you want to change anything, you can go back. Alternatively, click on Finish and your bucket should be created successfully.

  6. Go to the Lambda function that we created in the earlier exercise. Add S3 as a trigger under the Lambda configuration section:

    Figure 2.54: Lambda configuration window

  7. Click on Configuration required and add the required details related to S3 bucket configuration, mainly the bucket name. Keep the rest of the settings as default:

    Figure 2.55: Configure triggers window

  8. Click on Add to add that S3 bucket as a trigger to execute the Lambda function:

    Figure 2.56: Window showing S3 bucket being added as a trigger

  9. Click on Save to save the changes to the Lambda function:

    Figure 2.57: Window showing S3 bucket getting saved

  10. Also, the email message will have changed in the Lambda code to reflect our activity. See line # 8 in the following screenshot. You can customize it based on your needs:

    Figure 2.58: Window showing code of index.js

  11. Now, upload a new sample file to the S3 bucket. You should see an email alert in your mailbox.

  12. Go back to the Amazon S3 service, click on the bucket name, and click on the Upload button.

  13. Click on Add files and select the file that you want to load into the S3 bucket. Click on Next.

  14. Set the file level permissions. Click on Next.

  15. Select the storage class. You can continue with the default option. Click on Next.

  16. Review the configuration and click on Upload.

  17. The file should be uploaded successfully:

    Figure 2.59: Overview section of Amazon S3

  18. Once the file has been uploaded, go to your mailbox and you should see an email alert:

    Figure 2.60: Output showing a new object being uploaded to the S3 bucket

This concludes our activity.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime