-
Notifications
You must be signed in to change notification settings - Fork 862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to configure S3 Client when using DynamoDB S3Link #3479
Comments
@Danny-UKDM We added a new configuration option called service-specific endpoints where you can set an environment variable or a profile for a specific service and that will set the serviceURL for that service. Can you try adding this in your application? AWS_ENDPOINT_URL_S3 = "http://localhost:4566/"; |
@peterrsongg Thanks for leading me to that 👍 it seems to have resolved the issue with I managed to break here on an e2e test run and manually change Could there be a way to override the |
@Danny-UKDM There is no way to do that via environment variables, only the service-specific endpoints work with that at the moment. However, you should be able to do something like
in your config file but I see that we haven't added that as a reserved property in our |
@peterrsongg that would be greatly appreciated, thank you! 👍 I must say, with a few years of experience working with If AWS client construction takes client configuration from |
@Danny-UKDM Spoke with the team and decided this is most likely just a miss when implementing |
@peterrsongg this is great news! I appreciate the resolution 👍 |
Describe the bug
When implementing
S3Link
for bothS3Link.Create()
andmyLinkedProperty.UploadStreamAsync()
there appears to be no method for configuring theAmazonS3Client
which is created under the hood, or for providing your own configured instance of anAmazonS3Client
.This appears fine for a production environment, but prevents you from being able to ensure the underlying
AmazonS3Client
is correctly configured for end-to-end integration testing via a service like localstack.Despite best efforts to ensure the
DynamoDBContext
passed intoS3Link.Create()
is configured for localstack in a"Development"
environment (which functions as expected elsewhere), theAmazonS3Client
ultimately throws an error of:Regression Issue
Expected Behavior
Either:
1 - When correctly configuring the DI registration of
DynamoDBContext
forDevelopment
, which is passed intoS3Link.Create()
, the underlying functionality correctly clones the configuration and creates the correctlyDevelopment
-configuredAmazonS3Client
under the hood when performing operations.2 -
S3Link
allows the caller to pass their own configured instance(s) ofAmazonS3Client
which is known to be correctly configured forDevelopment
and end-to-end integration testing via a service like localstack.Current Behavior
1 - Once calling
myLinkedProperty.UploadStreamAsync()
after usingS3Link.Create()
with a localstack-configured instance ofDynamoDBContext
, the following exception is ultimately thrown:The above happens regardless of manual
AmazonDynamoDBClient
instance creation with:2 - There appears to be no specific configuration options or opportunities to pass my own configured
AmazonS3Client
toS3Link
Reproduction Steps
Minimal reproduction via .NET 8 Console App:
csproj:
docker-compose.yml:
Possible Solution
From attempting to step through the AWS SDK call stack after attempting to configure for localstack:
S3Link
CreatClientCacheFromContext(DynamoDBContext context)
(typo here btw) did not seem to add the creatednew S3ClientCache
to theS3Link.Caches
dictionary despite not throwing an exception. This seemed to causeS3ClientCache
GetClient
to always fall in toif (!this.clientsByRegion.TryGetValue(region.SystemName, out output))
when S3Link operations are performed, whereServiceClientHelpers.CreateServiceFromAssembly()
is then used.AmazonServiceClient
CloneConfig(ClientConfig newConfig)
, which looks to construct the configuration for theAmazonS3Client
created under the hood byS3Link
, does not seem to respect client configuration which is necessary for localstack (e.g. maintaining the "localstack"accessKey
andsecreyKey
, maintaining the localstackserviceUrl
over using an AWS Region and allowing the necessary setting ofForcePathStyle = true
for integration testing)I believe offering the ability to either configure the created
AmazonS3Client
viaS3Link
or to provide your own configured instance ofAmazonS3Client
toS3Link
would allow for end-to-end testing via localstack as expected.Additional Information/Context
appsettings.Development.json
read in as config for my specific code experiencing this issue:and my service registrations (called in order):
NB - I have confirmed that it is indeed the
Development
routes which are invoked as part of my end-to-end testingAWS .NET SDK and/or Package version used
AWSSDK.DynamoDBv2 3.7.400.21
AWSSDK.Extensions.NETCore.Setup 3.7.301
AWSSDK.S3 3.7.403
Targeted .NET Platform
.NET 8
Operating System and version
Windows 11 (with WSL)
The text was updated successfully, but these errors were encountered: