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:
$ awslocal s3api create-bucket --bucket sample-bucket
{
"Location": "/sample-bucket"
}
$ awslocal s3api list-buckets
{
"Buckets": [
{
"Name": "sample-bucket",
"CreationDate": "2021-10-05T10:48:38+00:00"
}
],
"Owner": {
"DisplayName": "webfile",
"ID": "bcaf1ffd86f41161ca5fb16fd081034f"
}
}
$ awslocal s3api put-object --bucket sample-bucket --key index.html --body index.html
{
"ETag": "\"d41d8cd98f00b204e9800998ecf8427e\""
}
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:
<bucket-name>.s3.<region>.localhost.localstack.cloud # host-style request
<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)