From ad5a7d43b2160e1351c3d75fc2e99955e4580174 Mon Sep 17 00:00:00 2001 From: Amri Date: Wed, 30 Jan 2019 16:00:59 +0100 Subject: [PATCH] =?UTF-8?q?docs:=20=E2=9C=8F=EF=B8=8F=20add=20a=20section?= =?UTF-8?q?=20about=20cleaning=20the=20bucket?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc_source/serverless-deploying.md | 31 +++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/doc_source/serverless-deploying.md b/doc_source/serverless-deploying.md index 647b4fe..0594d8d 100644 --- a/doc_source/serverless-deploying.md +++ b/doc_source/serverless-deploying.md @@ -37,4 +37,33 @@ You can use AWS SAM with a number of other AWS services to automate the deployme + **AWS CodePipeline**: You use AWS CodePipeline to model, visualize, and automate the steps that are required to release your serverless application\. For more information, see [What Is AWS CodePipeline?](https://docs.aws.amazon.com/codepipeline/latest/APIReference/)\. **Topics** -+ [Gradual Code Deployment](automating-updates-to-serverless-apps.md) \ No newline at end of file ++ [Gradual Code Deployment](automating-updates-to-serverless-apps.md) + +## Cleaning up the bucket + +After the Lambda is created, a "private" copy of the code is made. +In the case you're using S3 for the code, you can safely remove your objects after creating the functions. One way to do that is using a Lifecycle rule. + +Using CloudFormation +```yml +Outputs: + BucketName: + Value: !Ref CodeBucket + Description: The name of your code bucket. + +Resources: + CodeBucket: + Type: AWS::S3::Bucket + Properties: + LifecycleConfiguration: + Rules: + - ExpirationInDays: 1 + Status: Enabled +``` + +Using the CLI +```bash +aws s3 mb s3://{bucketNname} +aws s3api put-bucket-lifecycle-configuration --bucket {bucketNname} --lifecycle-configuration '{"Rules": [{"Expiration": {"Days": 1}, "ID": "Expire old objects", "Prefix": "", "Status": "Enabled"}]} +' +```