|
| 1 | +# Amazon S3 Bucket Replication |
| 2 | + |
| 3 | +This pattern demonstrates how to replicate S3 bucket objects to multiple S3 buckets. Implemented with SAM. |
| 4 | + |
| 5 | +**Key Benefits**: |
| 6 | + |
| 7 | +- **Data Redundancy and Durability**: |
| 8 | + S3 replication ensures that your data is replicated across multiple S3 buckets, offering redundancy and safeguarding against data loss. |
| 9 | +- **Disaster Recovery**: |
| 10 | + By replicating your data to a different region or account, you establish a robust disaster recovery strategy. In the event of an outage or data corruption, you can quickly restore operations using the replicated data. |
| 11 | +- **Global Content Distribution**: |
| 12 | + Replicate frequently accessed data to different geographical locations, reducing latency and enhancing the user experience for global audiences. |
| 13 | +- **Compliance and Data Retention**: |
| 14 | + Address compliance requirements by replicating data to a separate account or region. This ensures data integrity and facilitates adherence to regulatory standards. |
| 15 | +- **Operational Efficiency**: |
| 16 | + S3 replication operates asynchronously, allowing you to focus on other tasks while data is efficiently copied in the background. |
| 17 | + |
| 18 | + |
| 19 | +Learn more about this pattern at Serverless Land Patterns: [https://serverlessland.com/patterns/s3-s3-replication-sam](https://serverlessland.com/patterns/s3-s3-replication-sam) |
| 20 | + |
| 21 | +**Important**: This application utilizes various AWS services, and there are associated costs after Free Tier usage. Please refer to the [AWS Pricing page](https://aws.amazon.com/pricing/) for details. You are responsible for any incurred AWS costs. No warranty is implied in this example. |
| 22 | + |
| 23 | +## Requirements |
| 24 | + |
| 25 | +* [Create an AWS account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) if you do not already have one and log in. Ensure that the IAM user used has sufficient permissions to make necessary AWS service calls and manage resources. |
| 26 | +* [Install and configure AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) |
| 27 | +* [Install Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) |
| 28 | +* [Install AWS Serverless Application Model (AWS SAM)](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) |
| 29 | + |
| 30 | +## Deployment Instructions |
| 31 | + |
| 32 | +1. Create a new directory, navigate to that directory in a terminal, and clone the GitHub repository: |
| 33 | + ```bash |
| 34 | + git clone https://github.com/aws-samples/serverless-patterns |
| 35 | + ``` |
| 36 | +1. Change the directory to the pattern directory: |
| 37 | + ```bash |
| 38 | + cd s3-s3-replication-sam |
| 39 | + ``` |
| 40 | +1. From the command line, use AWS SAM to deploy the AWS resources for the pattern as specified in the template.yml file: |
| 41 | + ```bash |
| 42 | + sam deploy --guided |
| 43 | + ``` |
| 44 | +1. During the prompts: |
| 45 | + * Enter a stack name. |
| 46 | + * Enter the desired AWS Region. |
| 47 | + * Allow SAM CLI to create IAM roles with the required permissions. |
| 48 | + |
| 49 | + Once you have run `sam deploy --guided` mode once and saved arguments to a configuration file (samconfig.toml), you can use `sam deploy` in the future to use these defaults. |
| 50 | + |
| 51 | +1. Note the outputs from the SAM deployment process. These contain the resource names and/or ARNs used for testing. |
| 52 | + |
| 53 | +## How it Works |
| 54 | + |
| 55 | +S3 replication in the same region involves copying objects from one S3 bucket to another within the same AWS region. When replication is configured, S3 automatically copies objects from the source bucket to the destination bucket, ensuring redundancy and data durability. This process helps in scenarios such as data backup, compliance requirements, and minimizing latency for accessing data. |
| 56 | + |
| 57 | + |
| 58 | +## Testing |
| 59 | + |
| 60 | +Upload some images to the source bucket, and then check the replication bucket. You should be able to see the same data replicated there. |
| 61 | + |
| 62 | +## Cleanup |
| 63 | + |
| 64 | +1. Empty buckets |
| 65 | + ```bash |
| 66 | + aws s3 rm s3://BUCKET_NAME_SOURCE --recursive |
| 67 | + aws s3 rm s3://BUCKET_NAME_REPLICA --recursive |
| 68 | +
|
| 69 | + ``` |
| 70 | +2. Confirm the stack has been deleted: |
| 71 | + ```bash |
| 72 | + sam delete --stack-name STACK_NAME |
| 73 | +
|
| 74 | + ``` |
| 75 | + |
| 76 | +---- |
| 77 | + |
| 78 | +Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 79 | + |
| 80 | +SPDX-License-Identifier: MIT-0 |
0 commit comments