S3

S3

AWS S3 is a managed scalable object storage service that can be used to store any amount of data for a wide range of use cases.

S3 is shipped with the LocalStack Community version and is extensively supported. Trying to run the examples in the official AWS developer guide against LocalStack is a great place to start.

Assuming you have awslocal installed you can also try the following commands. Make sure the file you put into the bucket exists:

  1. $ awslocal s3api create-bucket --bucket sample-bucket
  2. {
  3. "Location": "/sample-bucket"
  4. }
  5. $ awslocal s3api list-buckets
  6. {
  7. "Buckets": [
  8. {
  9. "Name": "sample-bucket",
  10. "CreationDate": "2021-10-05T10:48:38+00:00"
  11. }
  12. ],
  13. "Owner": {
  14. "DisplayName": "webfile",
  15. "ID": "bcaf1ffd86f41161ca5fb16fd081034f"
  16. }
  17. }
  18. $ awslocal s3api put-object --bucket sample-bucket --key index.html --body index.html
  19. {
  20. "ETag": "\"d41d8cd98f00b204e9800998ecf8427e\""
  21. }

Path-Style Requests versus Virtual Hosted-Style Requests

Just like AWS, LocalStack differentiates between Path-Style and Virtual Hosted-Style Requests depending on your Host header for a request.

Example:

  1. <bucket-name>.s3.<region>.localhost.localstack.cloud # host-style request
  2. <bucket-name>.s3.<region>.amazonaws.com # host-style request

As a special case in LocalStack, leaving out .s3.<region> also works for the localhost.localstack.cloud domain:

<bucket-name>.localhost.localstack.cloud is also a host-style request.

All other requests will be considered path-style requests.

Last modified June 29, 2022: clarify possible error source (dd5a5645)