You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/aws/services/s3.mdx
+72-57Lines changed: 72 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,5 @@
1
1
---
2
2
title: "Simple Storage Service (S3)"
3
-
linkTitle: "Simple Storage Service (S3)"
4
3
description: Get started with Amazon S3 on LocalStack
5
4
persistence: supported
6
5
tags: ["Free"]
@@ -14,30 +13,30 @@ Each object or file within S3 encompasses essential attributes such as a unique
14
13
S3 can store unlimited objects, allowing you to store, retrieve, and manage your data in a highly adaptable and reliable manner.
15
14
16
15
LocalStack allows you to use the S3 APIs in your local environment to create new buckets, manage your S3 objects, and test your S3 configurations locally.
17
-
The supported APIs are available on our [API coverage page]({{< ref "coverage_s3" >}}), which provides information on the extent of S3's integration with LocalStack.
16
+
The supported APIs are available on our [API coverage page](), which provides information on the extent of S3's integration with LocalStack.
18
17
19
18
## Getting started
20
19
21
20
This guide is designed for users new to S3 and assumes basic knowledge of the AWS CLI and our [`awslocal`](https://github.com/localstack/awscli-local) wrapper script.
22
21
23
-
Start your LocalStack container using your [preferred method]({{< ref "getting-started/installation" >}}).
22
+
Start your LocalStack container using your preferred method.
24
23
We will demonstrate how you can create an S3 bucket, manage S3 objects, and generate pre-signed URLs for S3 objects.
25
24
26
25
### Create an S3 bucket
27
26
28
27
You can create an S3 bucket using the [`CreateBucket`](https://docs.aws.amazon.com/cli/latest/reference/s3api/create-bucket.html) API.
29
28
Run the following command to create an S3 bucket named `sample-bucket`:
You will see a generated pre-signed URL for your S3 object.
123
125
You can use [curl](https://curl.se/) or [`wget`](https://www.gnu.org/software/wget/) to retrieve the S3 object using the pre-signed URL.
@@ -143,13 +145,13 @@ By default, most SDKs will try to use **Virtual-Hosted style** requests and prep
143
145
However, if the endpoint is not prefixed by `s3.`, LocalStack will not be able to understand the request and it will most likely result in an error.
144
146
145
147
You can either change the endpoint to an S3-specific one, or configure your SDK to use **Path style** requests instead.
146
-
Check out our [SDK documentation]({{< ref "sdks" >}}) to learn how you can configure AWS SDKs to access LocalStack and S3.
148
+
Check out our [SDK documentation](/aws/integrations/aws-sdks) to learn how you can configure AWS SDKs to access LocalStack and S3.
147
149
148
-
{{< callout "tip" >}}
150
+
:::note
149
151
While using [AWS SDKs](https://aws.amazon.com/developer/tools/#SDKs), you would need to configure the `ForcePathStyle` parameter to `true` in the S3 client configuration to use **Path style** requests.
150
152
If you want to use virtual host addressing of buckets, you can remove `ForcePathStyle` from the configuration.
151
-
The `ForcePathStyle` parameter name can vary between SDK and languages, please check our [SDK documentation]({{< ref "sdks" >}})
152
-
{{< /callout >}}
153
+
The `ForcePathStyle` parameter name can vary between SDK and languages, please check our [SDK documentation](/aws/integrations/aws-sdks)
154
+
:::
153
155
154
156
If your endpoint is not prefixed with `s3.`, all requests are treated as **Path style** requests.
155
157
Using the `s3.localhost.localstack.cloud` endpoint URL is recommended for all requests aimed at S3.
@@ -168,12 +170,17 @@ Follow this step-by-step guide to configure CORS rules on your S3 bucket.
168
170
169
171
Run the following command on your terminal to create your S3 bucket:
Next, create a JSON file with the CORS configuration.
179
186
The file should have the following format:
@@ -191,22 +198,22 @@ The file should have the following format:
191
198
}
192
199
```
193
200
194
-
{{< callout >}}
201
+
:::note
195
202
Note that this configuration is a sample, and you can tailor it to fit your needs better, for example, restricting the **AllowedHeaders** to specific ones.
196
-
{{< /callout >}}
203
+
:::
197
204
198
205
Save the file locally with a name of your choice, for example, `cors-config.json`.
199
206
Run the following command to apply the CORS configuration to your S3 bucket:
On applying the configuration successfully, you should see the same JSON configuration file you created earlier.
212
219
Your S3 bucket is configured to allow cross-origin resource sharing, and if you try to send requests from your local application running on [localhost:3000](http://localhost:3000), they should be successful.
@@ -233,10 +240,10 @@ We can edit the JSON file `cors-config.json` you created earlier with the follow
233
240
234
241
You can now run the same steps as before to update the CORS configuration and verify if it is applied correctly:
You can try again to upload files in your bucket from the [LocalStack Web Application](https://app.localstack.cloud) and it should work.
242
249
@@ -245,17 +252,22 @@ You can try again to upload files in your bucket from the [LocalStack Web Applic
245
252
LocalStack provides a Docker image for S3, which you can use to run S3 in a Docker container.
246
253
The image is available on [Docker Hub](https://hub.docker.com/r/localstack/localstack) and can be pulled using the following command:
247
254
248
-
{{< command >}}
249
-
$ docker pull localstack/localstack:s3-latest
250
-
{{< / command >}}
255
+
```bash
256
+
docker pull localstack/localstack:s3-latest
257
+
```
251
258
252
259
The S3 Docker image only supports the S3 APIs and does not include other services like Lambda, DynamoDB, etc. You can run the S3 Docker image using any of the following commands:
The S3 Docker image has similar parity with the S3 APIs supported by LocalStack Docker image.
280
-
You can use similar [configuration options]({{< ref "configuration/#s3" >}}) to alter the behaviour of the S3 Docker image, such as `DEBUG` or `S3_SKIP_SIGNATURE_VALIDATION`.
295
+
You can use similar [configuration options](/aws/capabilities/config/configuration/#s3) to alter the behaviour of the S3 Docker image, such as `DEBUG` or `S3_SKIP_SIGNATURE_VALIDATION`.
281
296
282
-
{{< callout >}}
297
+
:::note
283
298
The S3 Docker image does not support persistence, and all data is lost when the container is stopped.
284
299
To use persistence or save the container state as a Cloud Pod, you need to use the [`localstack/localstack-pro`](https://hub.docker.com/r/localstack/localstack-pro) image.
285
-
{{< /callout >}}
300
+
:::
286
301
287
302
## SSE-C Encryption
288
303
@@ -303,10 +318,10 @@ However, LocalStack does not support the actual encryption and decryption of obj
303
318
304
319
## Resource Browser
305
320
306
-
The LocalStack Web Application provides a [Resource Browser]({{< ref "resource-browser" >}}) for managing S3 buckets & configurations.
321
+
The LocalStack Web Application provides a [Resource Browser](/aws/capabilities/web-app/resource-browser) for managing S3 buckets & configurations.
307
322
You can access the Resource Browser by opening the LocalStack Web Application in your browser, navigating to the **Resources** section, and then clicking on **S3** under the **Storage** section.
0 commit comments