Skip to content

Demo code to trigger AWS CodeBuild jobs for selective file changes in AWS CodeCommit repositories

License

Notifications You must be signed in to change notification settings

aws-samples/aws-codecommit-selective-build-trigger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

aws-codecommit-selective-build-trigger

This demo illustrates the deployment of AWS Lambda to build Docker Images of application in AWS CodeCommit repository automatically when selective files are modified and the changes are pushed to the repository. The AWS Lambda receives the AWS CodeCommit events for push to repository and triggers a AWS CodeBuild job to build the Docker image and push to AWS Elastic Container Registry.

AWS services used for the CI/CD portion:

Solution Diagram

Solution Diagram

Stack deployment

The cloudformation stack can be deployed using Cloudoformation page in AWS Console or using the AWS CLI as shown below

First, zip and upload the lambda code to an S3 bucket

cd src/

zip lambda.zip lambda_code.py

aws s3 cp lambda.zip s3://aws-codecommit-selective-build-trigger/

Trigger the cloudformation stack creation pointing to that S3 bucket zip.

aws cloudformation create-stack --stack-name myteststack --template-body file://src/aws-codecommit-selective-build-trigger.yml --parameters ParameterKey=ProjectName,ParameterValue=testproject ParameterKey=LambdaZipS3Bucket,ParameterValue=aws-codecommit-selective-build-trigger ParameterKey=LambdaZipS3Key,ParameterValue=lambda.zip --capabilities CAPABILITY_NAMED_IAM

Components details

src/aws-codecommit-selective-build-trigger.yml - Cloudformation template for demonstrating the solution of AWS Lambda triggered AWS CodeBuild job based on changes to specific files in AWS CodeCommit repository

src/lambda_code.py - Python code for AWS Lambda to filter the AWS CodeCommit event and find the files changed as part of the commit and trigger AWS CodeBuild job if needed.

src/lambda.zip - Compressed zip file for lambda_code.py file for deploying using Cloudformation template

License

This library is licensed under the MIT-0 License. See the LICENSE file.

About

Demo code to trigger AWS CodeBuild jobs for selective file changes in AWS CodeCommit repositories

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages