Reputation: 3104
I'm using AWS to package my node10.x lambda code & dependencies for my site. I have my git repos broken out by function - so I have a repo dedicated to my rest-auth lambdas as an example (I'm still actively developing this, so there are pleanty of missing buildspec & function files).
My git repo has the following layout:
.
├── buildspec
│ ├── postmark.yml
│ ├── rest-auth-login.yml
│ ├── rest-auth-password-link.yml
│ └── rest-auth-register.yml
├── function_code
│ ├── login.js
│ ├── password-link.ext
│ ├── postmark.js
│ ├── register.js
│ └── rgistration-confirm.js
├── .gitignore
└── README.md
Right now when I push an update to github all 4 buildspec configs fire and create 4 zip files in my S3 bucket for my lambdas to read from.
However, all 4 zip files are recreated even if there are only changes to ONE of their underlying code -- I know I can split each function into it's own repo, but is there a way to configure AWS CodeBuild to only trigger updates for a given buildspec if specific files are changed in the repo?
Ie only run the postmark.yml
if the postmark.js
file is changed?
Example postmark.yml
version: 0.2
phases:
install:
runtime-versions:
nodejs: 10
commands:
- npm install postmark
artifacts:
files:
- 'function_code/postmark.js'
- 'node_modules/**/*'
Upvotes: 1
Views: 274
Reputation: 2545
Yes. You can use the "file_path" option to only trigger when the specific file is changed as described in https://docs.aws.amazon.com/codebuild/latest/userguide/sample-github-pull-request.html#sample-github-pull-request-filter-webhook-events-console
Adding the following to the ource of the postmark build will result in that build only triggering when the postmark.js file is updated
Upvotes: 1