Use GitHub Actions to deploy a Lambda Image or S3 bucket update
Instead of deploying your Lambda code in the same pipeline as your infrastructure, you can use CI/CD and GitHub Actions pipelines. With DuploCloud's GitHub Actions integration, you can build and deploy Lambda functions in your AWS account by deploying a Lambda image or by a package uploaded to an S3 bucket.
For general information about deploying serverless applications with GitHub Actions in AWS, reference this blog.
Update a Function Using an Image
Use the following code as a template to update a Lambda container image with GitHub Actions. In this example, the Lambda container image in the dev01 The tenant is updated and redeployed.
You must ensure the following are configured in your environment and your specific situation.
The name of lambda is set on the action to your actual lambda
Duplocloud context configured correctly
name:Update Lambdaon:workflow_dispatch:inputs:environment:description:The environment to deploy totype:environmentdefault:dev01image:description:The full imagetype:stringrequired:truejobs:update_service:name:Update Lambdaruns-on:ubuntu-latestenvironment:name:${{ inputs.environment }}env:DUPLO_TOKEN:${{ secrets.DUPLO_TOKEN }}DUPLO_HOST:${{ vars.DUPLO_HOST }}DUPLO_TENANT:${{ inputs.environment }}steps:# configures duplocloud and aws - name:Cloud CI Setupuses:5# uses duploctl from above - name:Update Lambdauses:duplocloud/actions/update-image@v0.0.5with:type:lambdaname:mylambdaimage:${{ inputs.image }}
Update Lambda based on a package in Amazon S3
Use the following code as a template to deploy your Lambda functions to an S3 bucket with GitHub Actions. In this example, the Lambda in the dev01 The tenant is updated using an S3 bucket that contains mylambda-v1.zip
You must ensure the following are configured in your environment and your specific situation.
Duplocloud context configured correctly
S3KEY
S3BUCKET
LAMBDA_NAME
name:Update Lambdaon:workflow_dispatch:inputs:environment:description:The environment to deploy totype:environmentdefault:dev01s3key:description:The key name in the s3 bucket with the version to deploy.type:stringrequired:falsedefault:mylambda-v1.zipjobs:update_service:name:Update Lambdaruns-on:ubuntu-latestenvironment:name:${{ inputs.environment }}env:DUPLO_TOKEN:${{ secrets.DUPLO_TOKEN }}DUPLO_HOST:${{ vars.DUPLO_HOST }}DUPLO_TENANT:${{ inputs.environment }}steps:# configures duplocloud and aws - name:Cloud CI Setupuses:duplocloud/actions/setup@v0.0.5# we can build the bucket name using context from setup - name:Discover True Bucket Nameenv:S3BUCKET:mybucketrun:echo "S3BUCKET=duploservices-${DUPLO_TENANT}-${S3BUCKET}-${AWS_ACCOUNT_ID}" >> $GITHUB_ENV# uses duploctl from above to run update lambda function - name:Update Lambda from S3env:LAMBDA_NAME:mylambdaS3KEY:${{ inputs.s3key }}run:duploctl lambda update_s3 $LAMBDA_NAME $S3BUCKET $S3KEY