Giter Site home page Giter Site logo

aws-lambda-scheduled's Introduction

aws-lambda-scheduled

A simple lambda function that is triggered via scheduled event

Manual deployment

Following works fine:

  1. create a bucket
aws s3 mb s3://scheduled-event-lambda-integration-bucket
  1. build the lambda
./gradlew clean build
  1. package the artifacts
aws cloudformation package --template-file infrastructure/cf-template.yaml \
    --s3-bucket scheduled-event-lambda-integration-bucket \
    --output-template-file packaged-stack.yaml
  1. deploy
aws cloudformation deploy --template-file packaged-stack.yaml \
    --stack-name scheduled-event-lambda \
    --capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM

Now check the CloudWatch. There will be a log entry every 5 minutes.

You can change the cron expression in cf-template.yaml to suits your needs.

Fully automated deployment

Create an OAuth Token in your GitHub account and store it in the Parameter Store under /github/token

Then from terminal run:

aws cloudformation create-stack --stack-name scheduled-event-lambda \
    --template-body file://cicd/pipeline.yaml \
    --parameters ParameterKey=TableName,ParameterValue=<DYNAMODB_TABLE> \
                 ParameterKey=SearchTerm,ParameterValue=<TWITTER_SEARCH_TERM> \
                 ParameterKey=TwitterApiKey,ParameterValue=<TWITTER_API_KEY> \
                 ParameterKey=TwitterApiSecret,ParameterValue=<TWITTER_API_SECRET> \
                 ParameterKey=TwitterAccessToken,ParameterValue=<TWITTER_ACCESS_TOKEN> \
                 ParameterKey=TwitterAccessTokenSecret,ParameterValue=<TWITTER_ACCESS_TOKEN_SECRET> \
    --capabilities CAPABILITY_NAMED_IAM

To do

  • use nested stacks
  • use the principle of the least privilege and restrict cloudformation policy even more
  • add a webhook to trigger build on each code change

aws-lambda-scheduled's People

Contributors

sekibomazic avatar

Watchers

 avatar  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.