3

I'm using Serverless Framework and have multiple services which are attempting to use the same SQS queue. I can successfully make the resource in the first service but the second one is missing the lambda trigger when deployed to AWS. Hardcoding the ARN ID will successfully make the trigger so I can only assume I have something wrong with my syntax/indentation, but it's very similar to how I'm exporting/importing my API Gateway details and I'm just not seeing it.

I have an SQS Queue set up and exported from my first service like this:

resources:
  - Resources:
      InitializeAuthenticationQueue:
        Type: "AWS::SQS::Queue"
        Properties:
          QueueName: "InitializeAuthenticationQueue"
  - Outputs:
      InitializeAuthenticationQueueArnId:
        Value:
          Fn::GetAtt:
            - InitializeAuthenticationQueue
            - Arn
        Export:
          Name: ${self:provider.stage}-InitializeAuthenticationQueueQueueArnId

In my second service I am attempting to use the SQS ARN ID as a trigger for a function, like this:

functions:
  authenticationIntialize:
    handler: myHandlerFile.myHandler
    events:
      - sqs:
        arn:
          'Fn::ImportValue': ${self:provider.stage}-InitializeAuthenticationQueueArnId

I've also tried this to see if I have my indentation wrong:

functions:
  authenticationIntialize:
    handler: myHandlerFile.myHandler
    events:
      - sqs:
          arn:
            'Fn::ImportValue': ${self:provider.stage}-InitializeAuthenticationQueueArnId

Feel like I'm missing something obvious on this one, but I've been stuck on it way too long. Anyone able to help me spot the obvious?

jProg2015
  • 1,098
  • 10
  • 40

1 Answers1

1

What errors do you get? What does the generated .serverless/cloudformation-template-update-stack.json have for the export and import values?

I usually find it easier to use the internal Serverless CloudFormation property reference. So where you are trying to import the SQS ARN do this:

${cf:STACK_NAME.InitializeAuthenticationQueueArnId}

where STACK_NAME is the name of the CloudFormation stack generated by the Serverless deployment this has the SQS ARN output. Using this method the way you reference the value to import is via the CloudFormation key and not the export name (which is admittedly confusing)

Brian Winant
  • 2,915
  • 15
  • 17