Git Product home page Git Product logo

sam-example's Introduction

customer-account-service

This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes the following files and folders.

  • src/accounts-service - A mock set of Lambdas & Service for creating and retreiving customer accounts (refer to template-swagger.yaml for api descriptions).
  • src/authorizer-service - A custom Authorizer function for authenticating calls to the customer account service
  • template-sam.yaml - A template that defines the application's AWS resources.
  • template-swagger.yaml - A swagger template that defines the API

dependencies

Run SAM application locally

Note: PITA - SAM local does not currently support custom authorizer run locally

sam build -t template-sam.yaml
sam local start-api

Deploy the sample application

To build and deploy your application to AWS (requires valid AWS account and tokens):

sam build
sam deploy --guided

Cleanup

To delete the sample application that you created, use the AWS CLI. Assuming you used customer-account-service for the stack name, you can run the following:

aws cloudformation delete-stack --stack-name customer-account-service

Endpoints

  • Example GET request to /api/customer-account/v1/accounts/{accountId} Requires a Bearer token with value of letmein otherwise will deny a user access.
curl --location --request GET 'https://<api-gateway-endpoint>/api/customer-account/v1/accounts/12345' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer letmein' \
--data-raw ''
  • Example POST request to /api/customer-account/v1/accounts
curl --location --request POST 'https://<api-gateway-endpoint>/api/customer-account/v1/accounts' \
--header 'Content-Type: application/json' \
--data-raw '{
	"accountName": "my test account"
}'

Resources

See the AWS SAM developer guide for an introduction to SAM specification, the SAM CLI, and serverless application concepts.

See the Custom Authorizer Flow for details on how custom authorization works.

sam-example's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.