From 8e9411b7d60bbf37029f11fbed3187c32f160f84 Mon Sep 17 00:00:00 2001 From: Dmitry Kolesnikov Date: Sun, 29 Sep 2024 20:10:57 +0300 Subject: [PATCH] fix attach existing queue to stack --- broker/eventsqs/awscdk.go | 4 ++-- broker/eventsqs/examples/serverless/main.go | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/broker/eventsqs/awscdk.go b/broker/eventsqs/awscdk.go index 433b591..a693bc9 100644 --- a/broker/eventsqs/awscdk.go +++ b/broker/eventsqs/awscdk.go @@ -90,10 +90,10 @@ func (broker *Broker) NewQueue(props *awssqs.QueueProps) awssqs.IQueue { return broker.Queue } -func (broker *Broker) AddQueue(queueName string) awssqs.IQueue { +func (broker *Broker) AddQueue(queueArn *string) awssqs.IQueue { broker.Queue = awssqs.Queue_FromQueueAttributes(broker.Construct, jsii.String("Bus"), &awssqs.QueueAttributes{ - QueueName: jsii.String(queueName), + QueueArn: queueArn, }, ) diff --git a/broker/eventsqs/examples/serverless/main.go b/broker/eventsqs/examples/serverless/main.go index 81d77ac..d740ed4 100644 --- a/broker/eventsqs/examples/serverless/main.go +++ b/broker/eventsqs/examples/serverless/main.go @@ -29,13 +29,22 @@ func main() { ) broker := eventsqs.NewBroker(stack, jsii.String("Broker"), nil) - broker.NewQueue(nil) + broker.AddQueue( + stack.FormatArn( + &awscdk.ArnComponents{ + Service: jsii.String("sqs"), + Account: awscdk.Aws_ACCOUNT_ID(), + Region: awscdk.Aws_REGION(), + Resource: jsii.String("swarm-test"), + }, + ), + ) broker.NewSink( &eventsqs.SinkProps{ Function: &scud.FunctionGoProps{ - SourceCodeModule: "github.com/fogfish/swarm", - SourceCodeLambda: "examples/eventsqs/dequeue", + SourceCodeModule: "github.com/fogfish/swarm/broker/eventsqs", + SourceCodeLambda: "examples/dequeue/typed", }, }, )