-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocalStackFixture.cs
More file actions
46 lines (36 loc) · 1.03 KB
/
Copy pathLocalStackFixture.cs
File metadata and controls
46 lines (36 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
namespace Envilder.Examples.Tests;
using Amazon.Runtime;
using Amazon.SimpleSystemsManagement;
using Testcontainers.LocalStack;
public sealed class LocalStackFixture : IAsyncLifetime
{
private LocalStackContainer _container = null!;
public IAmazonSimpleSystemsManagement Ssm { get; private set; } = null!;
public HttpClient Http { get; private set; } = null!;
public async ValueTask InitializeAsync()
{
_container = new LocalStackBuilder("localstack/localstack:stable")
.WithEnvironment(await Env.ResolveFileAsync("envilder.json"))
.Build();
await _container.StartAsync();
Ssm = new AmazonSimpleSystemsManagementClient(
new BasicAWSCredentials("test", "test"),
new AmazonSimpleSystemsManagementConfig
{
ServiceURL = _container.GetConnectionString(),
});
Http = new HttpClient
{
BaseAddress = new Uri(_container.GetConnectionString()),
};
}
public async ValueTask DisposeAsync()
{
Http?.Dispose();
Ssm?.Dispose();
if (_container is not null)
{
await _container.DisposeAsync();
}
}
}