Code Monkey home page Code Monkey logo

lambda_pipeline's Introduction

Lambda Configuration

  1. Generates a function.

    aws lambda create-function  --function-name dev-function   --runtime python3.10 --role arn:aws:iam::123456789999:role/service-role/lambda-role --zip-file fileb://lambda_function.zip --handler lambda_function.lambda_handler
  2. lambda_function.zip content

    • lambda_function.py
    import json
    
    def lambda_handler(event, context):
        # TODO implement
        return {
            'statusCode': 200,
            'body': json.dumps('Hello from Lambda!')
        }
  3. Create version

    aws lambda publish-version --function-name dev-function
    
  4. lambda_alias

    aws lambda create-alias --function-name dev-function --function-version 1 --name development
  • appspec.yaml

    version: 0.0
    Resources:
      - dev-function:
          Type: AWS::Lambda::Function
          Properties:
            Name: "dev-function"
            Alias: "development"
            CurrentVersion: 1
            TargetVersion: 2
  • buildspec.yml

    version: 0.2
    
    phases:
      install:
        commands:
          - yum install -y zip
      pre_build:
        commands:
          - export CURRENT_VERSION=$(aws lambda get-alias --function-name dev-function --name development --query 'FunctionVersion' --output text)
          - NEW_VERSION=$((CURRENT_VERSION + 1))
          - export NEW_VERSION
          - zip lambda_function.zip lambda_function.py
      build:
        commands:
          - aws lambda create-alias --function-name dev-function --function-version $NEW_VERSION --name development
          - aws lambda update-function-code --function-name dev-function --zip-file fileb://lambda_function.zip
      post_build:
        commands:
          - sed -i "s/1/$CURRENT_VERSION/g" appspec.yaml
          - sed -i "s/2/$NEW_VERSION/g" appspec.yaml
    
    artifacts:
      files:
        - appspec.yaml
      discard-paths: yes
    cache:
      paths:
        - '/root/.m2/**/*'
  • lambda_function.py

    import json
    
    def lambda_handler(event, context):
        # TODO implement
        return {
            'statusCode': 200,
            'body': json.dumps('Hello from test!')
        }

lambda_pipeline's People

Contributors

yyeongjin avatar

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.