/serverless-on-aws

This is repository for lightning talk about Serverless framework on AWS.

Primary LanguageCSSMIT LicenseMIT

Serverless + AWS


This is repository for lightning talk about Serverless framework on AWS.

Example

Requirements

  • Serverless framework installed.

  • AWS CLI installed and proper profile created

    ~/.aws/config

    [profile demo-aws-profile]
    output = json
    region = eu-central-1
    

    ~/.aws/credentials

    [demo-aws-profile]
    aws_access_key_id = XXXXXXXXXXXXXXXXXXXX
    aws_secret_access_key = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    
  • jq JSON processor installed (optional).

Deploy

deploy and run example:

  • go to example directory

  • deploy serverless service

    # default dev stage
    serverless deploy
    
    # prod stage
    serverless deploy --stage prod
  • test API call

    # call dev stage
    curl -v -H "x-api-key: DEV-API-KEY" https://DEV-API-ID.execute-api.eu-central-1.amazonaws.com/dev/example | jq
    
    # call prod stage
    curl v -H "x-api-key: PROD-API-KEY" https://PROD-API-ID.execute-api.eu-central-1.amazonaws.com/dev/example | jq

NOTE: The URL displayed next to Invoke URL should look something like this, where API-ID is the identifier API Gateway assigns to your API, REGION-ID is the AWS region identifier (for example, us-east-1 ) where you deployed your API, and STAGE-NAME is the name of the stage for the API you want to call:

https://API-ID.execute-api.REGION-ID.amazonaws.com/STAGE-NAME/RESOURCE-PATH

Cleanup

cleanup AWS environment:

  • go to example directory

  • remove serverless service

    # default dev stage
    serverless remove
    
    # prod stage
    serverless remove --stage prod

Links

License

The MIT License, see LICENSE