Allow `aws cloudformation package` to run a build script before zip'ing
- Dominant language
- Python
- Stars
- 17.3k
- Forks
- 4.6k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 13
Description
Often when building packages, there is need for a build step before code can be zipped. Eg. to gather dependencies that need to be packaged. Currently that means that this build should happen before `aws cloudformation package`is run.
It would be nice if building could be done by the `package` command. Eg. by using some hook.
My initial idea was:
- run `aws cloudformation package --build-with ${command}`
- for every path in the template:
- the full directory gets copied to a temporary directory
- `${command}` is run in that directory
- the contents of the directory gets zipped
- the zip is uploaded to S3
- the temporary directory is deleted
This isn't very flexible, but allows you to run `make` or `pip install -r requirements.txt -t .` or `./build.sh`, without leaving the files they create on disk. A big downside is that builds can't reuse the output of a previous build. An alternative could be:
- run `aws cloudformation package --build-hooks pre=${command01}, post=${command02}`
- for every path in the template:
- `${command01} /path/from/template` is run. This must output a path to directory (or if nothing is in the output, the original path will be used)
- the contents of the directory that the command gave as output gets zipped
- the zip is uploaded to S3
- `${command02} /output/form/command01` gets run
This is more flexible, and allows the user to decide if he wants to reuse build artifacts, but is harder to use.
I'd be happy to work on implementing this (time permitting), once there is a decision on the best approach.
Contributor guide
Assessment
This issue has not been assessed yet.