Skip to content

Commit 7e8d3d4

Browse files
committed
Fix LocalStack AWS client endpoint configuration
- Remove RegionEndpoint from client configs when using ServiceURL - Use BasicAWSCredentials instead of AnonymousAWSCredentials - Add ForcePathStyle to SQS config for proper endpoint resolution - Prevents clients from falling back to real AWS endpoints
1 parent a44cc69 commit 7e8d3d4

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

tests/SourceFlow.Cloud.AWS.Tests/TestHelpers/LocalStackTestFixture.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,18 @@ public async Task InitializeAsync()
143143
}
144144

145145
// Create AWS clients configured for LocalStack
146-
// Use AnonymousAWSCredentials to bypass credential validation in LocalStack
147-
var credentials = new Amazon.Runtime.AnonymousAWSCredentials();
146+
// Use BasicAWSCredentials with dummy values for LocalStack
147+
// AnonymousAWSCredentials can cause issues with endpoint resolution
148+
var credentials = new Amazon.Runtime.BasicAWSCredentials("test", "test");
148149

149150
var config = new Amazon.SQS.AmazonSQSConfig
150151
{
151152
ServiceURL = LocalStackEndpoint,
152153
UseHttp = true,
153-
RegionEndpoint = _configuration.Region,
154-
AuthenticationRegion = _configuration.Region.SystemName
154+
// Don't set RegionEndpoint when using ServiceURL - it can override the endpoint
155+
AuthenticationRegion = _configuration.Region.SystemName,
156+
// Force the use of the custom endpoint
157+
ForcePathStyle = true
155158
};
156159

157160
SqsClient = new AmazonSQSClient(credentials, config);
@@ -160,7 +163,7 @@ public async Task InitializeAsync()
160163
{
161164
ServiceURL = LocalStackEndpoint,
162165
UseHttp = true,
163-
RegionEndpoint = _configuration.Region,
166+
// Don't set RegionEndpoint when using ServiceURL
164167
AuthenticationRegion = _configuration.Region.SystemName
165168
};
166169

@@ -170,7 +173,7 @@ public async Task InitializeAsync()
170173
{
171174
ServiceURL = LocalStackEndpoint,
172175
UseHttp = true,
173-
RegionEndpoint = _configuration.Region,
176+
// Don't set RegionEndpoint when using ServiceURL
174177
AuthenticationRegion = _configuration.Region.SystemName
175178
};
176179

0 commit comments

Comments
 (0)