Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ldipotetjob/e9e31ff11dd5bea791b50014ba1cb77d to your computer and use it in GitHub Desktop.
Save ldipotetjob/e9e31ff11dd5bea791b50014ba1cb77d to your computer and use it in GitHub Desktop.

Revisions

  1. ldipotetjob revised this gist May 22, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion makefile_for_update_deploy_lambda_function
    Original file line number Diff line number Diff line change
    @@ -19,7 +19,7 @@ help:

    build:
    mkdir -p deployment-package
    cp src/$(HANDLER)/lambda_function.py src/standard_utils.py deployment-package/
    cp -r src/$(HANDLER)/. src/standard_utils.py deployment-package/
    if [ -f requirements.txt ]; then pip install -r requirements.txt --target deployment-package/; fi
    cd deployment-package && zip -r9 ../$(ZIP_FILE) .

  2. ldipotetjob revised this gist May 22, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion makefile_for_update_deploy_lambda_function
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ ROLE_ARN=$(ROLE)
    ZIP_FILE=deployment-package.zip
    REGION=eu-west-1

    # run under this project structure: https://raw.githubusercontent.com/ldipotetjob/AWS/refs/heads/main/serverless/lambda/project/structure.md
    # run under this project structure: https://github.com/ldipotetjob/AWS/blob/main/serverless/lambda/project/structure.md

    # keep in mind your security tokens export in your terminal:
    # export AWS_ACCESS_KEY_ID=${token_access_key}
  3. ldipotetjob revised this gist May 22, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion makefile_for_update_deploy_lambda_function
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ REGION=eu-west-1
    # export AWS_SECRET_ACCESS_KEY=${token_secret_key}

    # @see: https://makefiletutorial.com/
    # example of use: make all HANDLER=test_make ROLE=execution_role_of_the_lambda_function
    # example of use: make all HANDLER=my_lambda_function ROLE=execution_role_of_the_lambda_function

    FUNCTION_NAME=$(HANDLER)
    all: help build deploy clean
  4. ldipotetjob revised this gist May 22, 2025. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions makefile_for_update_deploy_lambda_function
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,8 @@ ROLE_ARN=$(ROLE)
    ZIP_FILE=deployment-package.zip
    REGION=eu-west-1

    # run under this project structure: https://raw.githubusercontent.com/ldipotetjob/AWS/refs/heads/main/serverless/lambda/project/structure.md

    # keep in mind your security tokens export in your terminal:
    # export AWS_ACCESS_KEY_ID=${token_access_key}
    # export AWS_SECRET_ACCESS_KEY=${token_secret_key}
  5. ldipotetjob created this gist May 22, 2025.
    29 changes: 29 additions & 0 deletions makefile_for_update_deploy_lambda_function
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    ROLE_ARN=$(ROLE)
    ZIP_FILE=deployment-package.zip
    REGION=eu-west-1

    # keep in mind your security tokens export in your terminal:
    # export AWS_ACCESS_KEY_ID=${token_access_key}
    # export AWS_SECRET_ACCESS_KEY=${token_secret_key}

    # @see: https://makefiletutorial.com/
    # example of use: make all HANDLER=test_make ROLE=execution_role_of_the_lambda_function

    FUNCTION_NAME=$(HANDLER)
    all: help build deploy clean

    help:
    echo "deploying " $(HANDLER)

    build:
    mkdir -p deployment-package
    cp src/$(HANDLER)/lambda_function.py src/standard_utils.py deployment-package/
    if [ -f requirements.txt ]; then pip install -r requirements.txt --target deployment-package/; fi
    cd deployment-package && zip -r9 ../$(ZIP_FILE) .

    deploy:
    echo "Deploying lambda function:" $(HANDLER)
    aws lambda update-function-code --function-name $(FUNCTION_NAME) --zip-file fileb://$(ZIP_FILE) --region $(REGION)

    clean:
    rm -rf deployment-package $(ZIP_FILE)