C# SQS request on local with LocalStack. https://github.com/localstack/localstack
This file contains 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
# see: https://github.com/localstack/localstack/blob/master/docker-compose.yml | |
# you don't need env and volumes on ↑ sample. | |
services: | |
localstack: | |
image: localstack/localstack:1.4.0 | |
ports: | |
- "127.0.0.1:4566:4566" # LocalStack Gateway | |
- "127.0.0.1:4510-4559:4510-4559" # external services port range | |
volumes: | |
- "./sqs.sh:/docker-entrypoint-initaws.d/sqs.sh" |
This file contains 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; | |
// using Amazon.Runtime; | |
// using Amazon.SQS; | |
// using Amazon.SQS.Model; | |
// using System.Threading.Tasks; | |
async Task Main() | |
{ | |
// for LocalStack | |
var credentials = new Amazon.Runtime.BasicAWSCredentials("test", "test"); | |
var client = new Amazon.SQS.AmazonSQSClient(credentials, new AmazonSQSConfig | |
{ | |
AuthenticationRegion = "ap-northeast-1", | |
ServiceURL = "http://localhost:4566" | |
}); | |
// create your queue.... | |
// list queue name | |
var queues = await client.ListQueuesAsync(new ListQueuesRequest()); | |
queues.Dump(); | |
/* | |
QueueUrls List<String> (6 items)••• | |
http://localhost:4566/000000000000/foo-queue | |
http://localhost:4566/000000000000/foo-deadletter-queue | |
*/ | |
// get queue url | |
var queue = await client.GetQueueUrlAsync("foo-queue"); | |
queue.Dump(); | |
/* | |
QueueUrl http://localhost:4566/000000000000/foo-queue | |
*/ | |
} |
This file contains 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
#!/bin/bash | |
set -eo pipefail | |
# NOTE: use awslocal to access localstack service. | |
region=ap-northeast-1 | |
queues=("foo-queue" "foo-deadletter-queue") | |
# create queues | |
for i in "${!queues[@]}"; do | |
awslocal sqs create-queue --queue-name "${queues[i]}" --region "${region}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment