Using !ImportValue in SQS event not working

Hi,

I’m using SST for building/maintaining the infrastructure/services that I’m using in AWS. In SST I’ve create a new SQS queue;

 const sqsBijenkorf = new sqs.Queue(this, 'Bijenkorf Queue');
// Output values
new CfnOutput(this, "BijenkorfSQSTopicName", {
  value: sqsBijenkorf.queueName,
  exportName: app.logicalPrefixedName("BijenkorfSQSTopicName"),
});

new CfnOutput(this, "BijenkorfSQSTopicArn", {
  value: sqsBijenkorf.queueArn,
  exportName: app.logicalPrefixedName("BijenkorfSQSTopicArn"),
});  

When I want to embed this in my serverless application within the function with the following code I’m getting an error;

custom:
  # pythonRequirements:
  #   dockerizePip: non-linux
  # Our stage is based on what is passed in when running serverless
  # commands. Or falls back to what we have set in the provider section.
  stage: ${opt:stage, self:provider.stage}
  # Name of the SST app that's deploying our infrastructure
  sstApp: ${self:custom.stage}-webshop-scraper-infra

    functions:
  saveProductResponse:
    timeout: 60
    handler: bijenkorf/src/save_product_response.store_response
  saveProductDetailResponse:
    handler: bijenkorf/src/save_product_detail_response.store_response
    events:
      - sqs: !ImportValue '${self:custom.sstApp}-BijenkorfSQSTopicArn'

Type Error ----------------------------------------------

TypeError: Cannot read property ‘Fn::GetAtt’ of undefined
at C:\Users\kompier\AppData\Roaming\npm\node_modules\serverless\lib\plugins\aws\package\compile\events\sqs.js:61:33
at C:\Users\kompier\AppData\Roaming\npm\node_modules\serverless\lib\plugins\aws\package\compile\events\sqs.js:70:15
at Array.forEach ()
at C:\Users\kompier\AppData\Roaming\npm\node_modules\serverless\lib\plugins\aws\package\compile\events\sqs.js:44:28
at Array.forEach ()
at AwsCompileSQSEvents.compileSQSEvents (C:\Users\kompier\AppData\Roaming\npm\node_modules\serverless\lib\plugins\aws\package\compile\events\sqs.js:34:47) at PluginManager.invoke (C:\Users\kompier\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:544:20)
at async PluginManager.spawn (C:\Users\kompier\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:566:5)
at async Object.before:deploy:deploy [as hook] (C:\Users\kompier\AppData\Roaming\npm\node_modules\serverless\lib\plugins\deploy.js:65:13)
at async PluginManager.invoke (C:\Users\kompier\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:544:9)

Your Environment Information ---------------------------
Operating System: win32
Node Version: 14.2.0
Framework Version: 2.31.0
Plugin Version: 4.5.2
SDK Version: 4.2.2
Components Version: 3.7.7

Can anyone help me on this?

Thanks,
Patrick

Hi Patrick,

I was wondering if you had found the solution to this as I’m hitting the same issue.

Regards,
Matthew

Ok I figured out the problem, the sqs definition needs to look like this :

events:
- sqs:
arn: !ImportValue ‘${self:custom.sstApp}-BijenkorfSQSTopicArn’