Skip to content

Commit f7cc673

Browse files
authored
Merge branch 'master' into master
2 parents 9e9b742 + 2d0417c commit f7cc673

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# CloudFormation Deploy to S3
22

3-
43
Before the official announcement for this deployment, if you wanted to deploy your SPA app, along with your other serverless services, to try it out, in the `/example` directory, run:
54

6-
`make deploy STACK_NAME=<name of cf stack> DEPLOYMENT_BUCKET_NAME=<s3 cloudformation deployment bucket>`
5+
`make deploy STACK_NAME=<name of cf stack> BUCKET_NAME=<s3 cloudformation deployment bucket>`
76

87
For an explanation of how this works, check out the example [`template.yml`](example/template.yml)
98

src/deployer.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ def resource_handler(event, context):
2929

3030
print('uploading')
3131
upload(lambda_src, target_bucket, acl, cacheControl)
32+
elif event['RequestType'] == 'Delete':
33+
print('delete')
3234
else:
3335
print('ignoring')
3436

@@ -58,6 +60,13 @@ def upload_file(source, bucket, key, s3lib, acl, cacheControl, contentType):
5860
s3lib.Object(bucket, key).put(ACL=acl, Body=open(source, 'rb'),
5961
CacheControl=cacheControl, ContentType=contentType)
6062

63+
def delete(lambda_src, target_bucket, s3lib):
64+
for folder, subs, files in os.walk(lambda_src):
65+
for filename in files:
66+
source_file_path = os.path.join(folder, filename)
67+
destination_s3_key = os.path.relpath(source_file_path, lambda_src)
68+
print('deleting file {} from {}'.format(destination_s3_key, target_bucket))
69+
s3lib.Object(target_bucket, destination_s3_key).delete()
6170

6271
def send_result(event):
6372
response_body = json.dumps({

0 commit comments

Comments
 (0)