Created
July 22, 2022 18:36
-
-
Save Kralizek/d10db75b0c3a6e83b22a69980857f693 to your computer and use it in GitHub Desktop.
LocalStack and Tye
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Amazon.SQS; | |
var builder = WebApplication.CreateBuilder(args); | |
builder.Configuration.AddInMemoryCollection(new Dictionary<string, string> { | |
["AWS:Profile"] = "LocalStack", | |
["AWS:Region"] = "us-east-1" | |
}); | |
var options = builder.Configuration.GetAWSOptions(); | |
var localstack = builder.Configuration.GetServiceUri("localstack"); | |
if (localstack is not null) | |
{ | |
options.DefaultClientConfig.ServiceURL = localstack.ToString(); | |
} | |
builder.Services.AddAWSService<IAmazonSQS>(options); | |
var app = builder.Build(); | |
app.MapGet("/", async (IAmazonSQS sqs) => { | |
var queue = await sqs.GetQueueUrlAsync("test"); | |
var messages = await sqs.ReceiveMessageAsync(queue.QueueUrl); | |
return Results.Ok(messages.Messages.Select(m => m.Body)); | |
}); | |
app.Run(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"description": { | |
"name": "localstack", | |
"replicas": 1, | |
"runInfo": { | |
"type": "docker", | |
"args": null, | |
"build": false, | |
"project": null, | |
"workingDirectory": null, | |
"volumeMappings": [], | |
"image": "localstack/localstack:1.0", | |
"executable": null | |
}, | |
"bindings": [ | |
{ | |
"name": null, | |
"connectionString": null, | |
"autoAssignPort": false, | |
"port": 4566, | |
"containerPort": 4566, | |
"host": null, | |
"protocol": "http" | |
} | |
], | |
"configuration": [] | |
}, | |
"serviceSource": "configuration", | |
"serviceType": "container", | |
"restarts": 0, | |
"status": { | |
"projectFilePath": null, | |
"executablePath": null, | |
"args": null, | |
"workingDirectory": null | |
}, | |
"replicas": { | |
"localstack_484a8c4a-e": { | |
"dockerCommand": "run -d -e \"PORT=4566\" -e \"PROXY_PORT=4566:4566\" -e \"SERVICE__LOCALSTACK__PROTOCOL=http\" -e \"LOCALSTACK_SERVICE_PROTOCOL=http\" -e \"SERVICE__LOCALSTACK__PORT=4566\" -e \"LOCALSTACK_SERVICE_PORT=4566\" -e \"SERVICE__LOCALSTACK__HOST=host.docker.internal\" -e \"LOCALSTACK_SERVICE_HOST=host.docker.internal\" -e \"SERVICE__WEB__PROTOCOL=http\" -e \"WEB_SERVICE_PROTOCOL=http\" -e \"SERVICE__WEB__PORT=53344\" -e \"WEB_SERVICE_PORT=53344\" -e \"SERVICE__WEB__HOST=host.docker.internal\" -e \"WEB_SERVICE_HOST=host.docker.internal\" -e \"APP_INSTANCE=localstack_484a8c4a-e\" -e \"CONTAINER_HOST=host.docker.internal\" -p 4566:4566 --name localstack_484a8c4a-e --restart=unless-stopped --network tye_network_e331aa9d-6 --network-alias localstack localstack/localstack:1.0 ", | |
"containerId": "fda1d74b2b28", | |
"dockerNetwork": "tye_network_e331aa9d-6", | |
"dockerNetworkAlias": "localstack", | |
"name": "localstack_484a8c4a-e", | |
"ports": [ | |
4566 | |
], | |
"exitCode": null, | |
"pid": null, | |
"environment": { | |
"PORT": "4566", | |
"PROXY_PORT": "4566:4566", | |
"SERVICE__LOCALSTACK__PROTOCOL": "http", | |
"LOCALSTACK_SERVICE_PROTOCOL": "http", | |
"SERVICE__LOCALSTACK__PORT": "4566", | |
"LOCALSTACK_SERVICE_PORT": "4566", | |
"SERVICE__LOCALSTACK__HOST": "host.docker.internal", | |
"LOCALSTACK_SERVICE_HOST": "host.docker.internal", | |
"SERVICE__WEB__PROTOCOL": "http", | |
"WEB_SERVICE_PROTOCOL": "http", | |
"SERVICE__WEB__PORT": "53344", | |
"WEB_SERVICE_PORT": "53344", | |
"SERVICE__WEB__HOST": "host.docker.internal", | |
"WEB_SERVICE_HOST": "host.docker.internal", | |
"APP_INSTANCE": "localstack_484a8c4a-e", | |
"CONTAINER_HOST": "host.docker.internal" | |
}, | |
"state": "ready" | |
} | |
} | |
}, | |
{ | |
"description": { | |
"name": "web", | |
"replicas": 1, | |
"runInfo": { | |
"type": "project", | |
"args": null, | |
"build": true, | |
"project": "C:\\Users\\RenatoGolia\\Development\\Tests\\LocalStackTye\\web\\web.csproj", | |
"workingDirectory": null, | |
"volumeMappings": null, | |
"image": null, | |
"executable": null | |
}, | |
"bindings": [ | |
{ | |
"name": null, | |
"connectionString": null, | |
"autoAssignPort": false, | |
"port": 53344, | |
"containerPort": 80, | |
"host": null, | |
"protocol": "http" | |
} | |
], | |
"configuration": [] | |
}, | |
"serviceSource": "configuration", | |
"serviceType": "project", | |
"restarts": 3, | |
"status": { | |
"projectFilePath": "C:\\Users\\RenatoGolia\\Development\\Tests\\LocalStackTye\\web\\web.csproj", | |
"executablePath": "C:\\Users\\RenatoGolia\\Development\\Tests\\LocalStackTye\\web\\bin\\Debug\\net6.0\\web.exe", | |
"args": "", | |
"workingDirectory": "C:\\Users\\RenatoGolia\\Development\\Tests\\LocalStackTye\\web" | |
}, | |
"replicas": { | |
"web_682375b9-7": { | |
"dockerCommand": null, | |
"containerId": null, | |
"dockerNetwork": null, | |
"dockerNetworkAlias": null, | |
"name": "web_682375b9-7", | |
"ports": [ | |
53344 | |
], | |
"exitCode": -1, | |
"pid": 8032, | |
"environment": { | |
"DOTNET_ENVIRONMENT": "Development", | |
"ASPNETCORE_ENVIRONMENT": "Development", | |
"DOTNET_LOGGING__CONSOLE__DISABLECOLORS": "true", | |
"ASPNETCORE_LOGGING__CONSOLE__DISABLECOLORS": "true", | |
"DOTNET_ROOT": "C:\\Program Files\\dotnet", | |
"DOTNET_MULTILEVEL_LOOKUP": "0", | |
"PATH": "...", | |
"SERVICE__WEB__PROTOCOL": "http", | |
"WEB_SERVICE_PROTOCOL": "http", | |
"SERVICE__WEB__PORT": "53344", | |
"WEB_SERVICE_PORT": "53344", | |
"SERVICE__WEB__HOST": "localhost", | |
"WEB_SERVICE_HOST": "localhost", | |
"SERVICE__LOCALSTACK__PROTOCOL": "http", | |
"LOCALSTACK_SERVICE_PROTOCOL": "http", | |
"SERVICE__LOCALSTACK__PORT": "4566", | |
"LOCALSTACK_SERVICE_PORT": "4566", | |
"SERVICE__LOCALSTACK__HOST": "localhost", | |
"LOCALSTACK_SERVICE_HOST": "localhost", | |
"ASPNETCORE_URLS": "http://localhost:53344", | |
"PORT": "53344", | |
"APP_INSTANCE": "web_682375b9-7", | |
"DOTNET_WATCH": "1", | |
"DOTNET_WATCH_ITERATION": "4" | |
}, | |
"state": "ready" | |
} | |
} | |
} | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: localstack-tye | |
services: | |
- name: localstack | |
image: localstack/localstack:1.0 | |
bindings: | |
- protocol: http | |
containerPort: 4566 | |
port: 4566 | |
- name: web | |
project: ./web/web.csproj | |
bindings: | |
- protocol: http |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment