Skip to content
This repository has been archived by the owner on Jun 28, 2023. It is now read-only.

Add a section about cleaning the bucket #3

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion doc_source/serverless-deploying.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
+ [Gradual Code Deployment](automating-updates-to-serverless-apps.md)

## Cleaning up the bucket

In the case you are using S3 for the code, you can safely remove your objects after creating the functions because Lambda makes a copy. One way to do so is by 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:
# BucketName: somebucketname # You can also provide the name explicitly.
LifecycleConfiguration:
Rules:
- ExpirationInDays: 1
Status: Enabled
```

Using the CLI
```bash
aws s3 mb s3://{bucketName}
aws s3api put-bucket-lifecycle-configuration --bucket {bucketName} --lifecycle-configuration '{"Rules": [{"Expiration": {"Days": 1}, "ID": "Expire old objects", "Prefix": "", "Status": "Enabled"}]}
'
```