Saving snapshots to S3
By default, Cloud Pod artifacts are stored in the LocalStack platform. However, if your organization’s data regulations or sovereignty requirements prohibit storing Cloud Pod assets in LocalStack’s managed storage, saving snapshots directly to your own Amazon S3 bucket is the recommended solution for keeping full control over where that data lives.
When saving to, loading from, or listing a snapshot in your own S3 bucket, lstk uses pre-signed S3 URLs to transfer the data directly between the emulator and your bucket, without proxying it through LocalStack’s platform.
Using the lstk CLI
Section titled “Using the lstk CLI”The lstk snapshot command lets you save, load, and list snapshots stored in your own S3 bucket by passing an s3://bucket/prefix location alongside a pod name.
The initial step is to export the necessary AWS credentials within the terminal session.
export AWS_ACCESS_KEY_ID=...export AWS_SECRET_ACCESS_KEY=...A possible option is to obtain credentials via AWS SSO CLI.
Alternatively, pass --profile <name> to have lstk read credentials from a named AWS profile instead of the environment.
To save a snapshot to your bucket, provide a pod name followed by the s3:// location:
lstk snapshot save my-pod s3://ls-pods-bucket-testOnce the command has been executed, you can confirm the presence of the snapshot artifacts in the S3 bucket by simply running:
aws s3 ls s3://ls-pods-bucket-test2023-09-27 13:50:10 83650 localstack-pod-my-pod-state-1.zip2023-09-27 13:50:11 85103 localstack-pod-my-pod-version-1.zipYou can use lstk snapshot load to load the same snapshot that was previously saved to this bucket:
lstk snapshot load my-pod s3://ls-pods-bucket-testSimilarly, you can list the snapshots stored in this bucket with lstk snapshot list:
lstk snapshot list s3://ls-pods-bucket-testComprehensive instructions on using the lstk snapshot CLI command, including credential resolution order, are found in the lstk CLI Guide.