Description
I am getting The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
My command:
sam local start-api --env-vars local_env.json -t ./cdk.out/ApiStack.template.json --region eu-central-1 --docker-network "<localstack-network-id>" --force-image-build
When I make a request that runs in my lambda, it fails to even reach localstack (no interaction logged on their side).
I ran the lambda code in its own docker container and my code works, even through docker so the issue must be with sam I guess.
So I don't get what I am doing wrong.
sam version: `1.76.0'
LOCALSTACK_ENDPOINT=""
The code I use to connect to the bucket:
let config = aws_config::load_from_env().await;
// local development
let mut config = aws_sdk_s3::config::Builder::from(&config);
if let Ok(endpoint) = env::var("LOCALSTACK_ENDPOINT") {
let ep = s3::Endpoint::immutable(endpoint.parse::<http::Uri>().unwrap());
let cred = s3::Credentials::new("access", "secret", None, None, "custom");
// Region is not used but is required by the SDK's API
let region = s3::Region::new("eu-central-1");
config = config
.endpoint_resolver(ep)
.region(region)
.credentials_provider(cred);
}
let client = s3::Client::from_conf(config.build());
local_env.json
{
"Parameters": {
"BUCKET_RAW_NAME": "rawbucket",
"LOCALSTACK_ENDPOINT": "http://127.17.0.1:4566/"
}
}
(I also tried 127.0.0.1, localhost, localstack, ...)