Git Product home page Git Product logo

hello_world's Introduction

Hello World

CircleCI

Hello World is a AWS Lambda function written in node.js that is triggered via AWS API Gateway. The function turns the string Hello World on <current_date_and_time> into an object /$ENVIRONMENT_NAME/hello.txt and uploads the file to the S3 bucket hello-world-tech-test. All AWS resources are provisioned in the eu-west-1 (Ireland) region and uses the Serverless Framework.

Getting Started

$ git clone [email protected]:nayoa/hello_world.git
$ export AWS_ACCESS_KEY_ID=<YOUR AWS CREDENTIALS>
$ export AWS_SECRET_ACCESS_KEY=<YOUR AWS CREDENTIALS>
$ export ENV=<ENVIRONMENT_NAME>

To upload to an S3 bucket of your choice, amend the bucket name in the s3Params variable. In addition, you need to amend the IAM permissions in the serverless.yml. Change the S3 ARN to your S3 bucket ARN. Make sure that you keep /* at the end of the ARN.

Prerequisites

$ npm install
$ npm install -i -g serverless

Running the tests

$ serverless invoke local --function hello

In the future, we want to improve the tests using Jest

Expected output:

Upload Successful

{
    "statusCode": 200,
    "body": "\"Upload Successful\""
}

Deployment

Change $ENV name to choice of environment to deploy to

$ serverless deploy

The deployment will create or amend a cloudformation stack with the new changes.

Expected output:

..............
Serverless: Stack update finished...
Service Information
service: helloWorld
stage: $ENV
region: eu-west-1
stack: helloWorld-$ENV
resources: 10
api keys:
  None
endpoints:
  GET - https://xstmyycz1j.execute-api.eu-west-1.amazonaws.com/$ENV/hello
functions:
  hello: helloWorld-$ENV-hello
layers:
  None
Serverless: Removing old service artifacts from S3...
Serverless: Run the "serverless" command to setup monitoring, troubleshooting and testing.

You are then able to send a GET request to the endpoint displayed. If working correctly, the reponse expected is Upload Successful.

To automate the deployment, a CircleCI pipeline it attached to this repository. When a change is made to the deploy branch the tests are triggered and staging is deployed. When a change is made to the master branch, the master pushes to production with manual approval.

Built With

Authors

  • Nayo Akinyele

Thoughts and Observations

  • More comfortable with Python and Boto3
  • New to the Serverless Framework
  • Should have more tests as part of the pipeline
  • Create docker image with npm package serverless pre-installed

hello_world's People

Watchers

Nayo Akinyele 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.