From 696ff970da56b1d61fab1ec041d1b97898b18184 Mon Sep 17 00:00:00 2001
From: Jon Burgess <jkburges@gmail.com>
Date: Fri, 16 Jul 2021 10:21:47 +1000
Subject: [PATCH] Allow s3 prefix to be provided

This enables S3 buckets to be a little more organised if you desire.
---
 Makefile  | 7 ++++---
 README.md | 6 ++++++
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 8eb1cf7..394b12a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,16 +1,17 @@
 STACK_NAME ?= ffmpeg-lambda-layer
+DEPLOYMENT_PREFIX ?= ""
 
-clean: 
+clean:
 	rm -rf build
 
-build/layer/bin/ffmpeg: 
+build/layer/bin/ffmpeg:
 	mkdir -p build/layer/bin
 	rm -rf build/ffmpeg*
 	cd build && curl https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz | tar x
 	mv build/ffmpeg*/ffmpeg build/ffmpeg*/ffprobe build/layer/bin
 
 build/output.yaml: template.yaml build/layer/bin/ffmpeg
-	aws cloudformation package --template $< --s3-bucket $(DEPLOYMENT_BUCKET) --output-template-file $@
+	aws cloudformation package --template $< --s3-bucket $(DEPLOYMENT_BUCKET) --s3-prefix $(DEPLOYMENT_PREFIX) --output-template-file $@
 
 deploy: build/output.yaml
 	aws cloudformation deploy --template $< --stack-name $(STACK_NAME)
diff --git a/README.md b/README.md
index 8a576d7..4689dad 100644
--- a/README.md
+++ b/README.md
@@ -29,6 +29,12 @@ Run the following command to deploy the compiled result as a layer in your AWS a
 make deploy DEPLOYMENT_BUCKET=<YOUR BUCKET NAME>
 ```
 
+You can optionally provide an S3 prefix, e.g.:
+
+```
+make deploy DEPLOYMENT_BUCKET=<YOUR BUCKET NAME> DEPLOYMENT_PREFIX=<YOUR PREFIX>
+```
+
 ### configuring the deployment
 
 By default, this uses `ffmpeg-lambda-layer` as the stack name. Provide a `STACK_NAME` variable when calling `make deploy` to use an alternative name.