Skip to content

simone-zennaro/serverless-workshop-1

Repository files navigation

Serverless Workshop 1

Serverless Barcelona Meetup

This PoC is part of the Serverless Workshop organized by the Serverless Barcelona Meetup. It is implemented with the Serverless Framework and not meant for production environments. The purpose of this workshop is to explain how to deploy a typical use case adopting the serverless services that AWS offers.

What contains?

  • A serverless stack deployable in an AWS account.
  • A Bitbucket pipeline to deploy the stack.
  • A Dockerfile used by the Bitbucket pipeline.
  • The website code.

Stack details

Workshop

The stack will deploy:

  • A website bucket where to store static HTML and JS.
  • An Api-Gateway endpoint with two paths (/private-api /open-api )
  • A Cognito User Pool where to create users and to use with the Api-Gateway Authorizer to protect the api calls which arrive to the /private-api
  • A Lambda which responds to the /open-api path
  • A Lambda which responds to the /private-api

How to deploy through Bitbucket pipeline

  • Clone this repo to a private repository in your Bitbucket account.
  • Enable the pipeline in your bitbucket repository: Bitbucket
  • Configure the repository variables: Bitbucket
  • Change the service name in the serverless.yml file (fill it with another one, ie: serverless-workshop-YOUR_AWS_ACCOUNTID)
  • Push the changes to the master branch to trigger the pipeline and deploy the stack

How to deploy from your laptop

Requirements:

  • NodeJS
  • AWS CLI
  • Serverless Framework (npm install serverless -g)

Deploy

$ npm run deploy

How to try the stack

  • Open the website bucket Url in your browser (you can find it in the pipeline output or in the Cloudformation stack output)

Bitbucket

  • Try to click on the CALL AUTHENTICATED button, you will receive a 401 response (Unauthorized)
  • Register a new user with a valid email address
  • Confirm the registration by inserting the code that you will receive by mail
  • Sign in
  • Try the CALL AUTHENTICATED button again, you will receive a message like that:

Bitbucket

Notes

All the steps must be followed in the correct order, in case something goes wrong and you want to recreate a user with the same email, you must go to the Cognito User Pool console --> Users and Groups, and disable/delete the user. We know, the UX is not the best one, but the PoC is built to start with the serverless framework, Cognito, Api-Gateway, Authorizer and Lambda.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published