I'm having a compile-time error that just started ...
# general
s
I'm having a compile-time error that just started happening after I destroyed my stack and tried to recreate:
Invoke of 'aws:sqs/getQueue:getQueue' failed: undefined (undefined)
Copy code
const queue = new aws.sqs.Queue( `${ config.namespace }_${ resourceName }` );

// get the queue's url
const queueUrl = pulumi.output( aws.sqs.getQueue( {
    name: queue.name,
} ) ).apply( v => v.url );

// get the queue's arn
const queueArn = pulumi.output( aws.sqs.getQueue( {
    name: queue.name,
} ) ).apply( v => v.arn );

module.exports = () => queue;
module.exports.arn = queueArn;
module.exports.url = queueUrl;
I suspect my outputs may have worked before when the Queue existed
I confirmed that everything works if I disable those apply commands and the resources that depend on them, then deploy the queue, then re-enable and deploy everything else. My CICD will require it to work in one operation... is there a way I can get that to compile correctly or somehow override that error?
@gentle-diamond-70147 This is a bit of a showstopper for us going to production, any ideas or places I should look?
g
Invoke of 'aws:sqs/getQueue:getQueue' failed: undefined (undefined)
sounds like a runtime error?
Are you getting a compile time error?
For the runtime error, I believe this is because the
getQueue
call fails if it doesn't find the resource and in this case from a destroyed stack it can't find the queue because it hasn't been created yet.
for the arn you should be able to just do
module.exports.arn = queue.arn;
without having to do the
apply
call
strange that the queue doesn't return the url, I'm guessing that's an AWS "nuance"
s
So right now I'm commenting out everything but the queue and deploying that, then I can deploy everything else. That won't really work with CICD of course, unless we design a 2 step deployment
My other resources explicitly depend on that queue
g
Sure, understood. I'm looking to see if there's a different way to achieve what you need.
For the arn, you don't need the apply. Unfortunately it looks like we have to work around the AWS API to get the URL.
s
Many thanks. I'm destroying right now then will try without the apply.
g
Oh... the queue id is the url.
Copy code
const queue = new aws.sqs.Queue( `${ config.namespace }_${ resourceName }` );

module.exports = () => queue;
module.exports.arn = queue.arn;
module.exports.url = queue.id;
that's all you need
Copy code
Updating (dev):

     Type                 Name                      Status
 +   pulumi:pulumi:Stack  aws-ts-sqs-undefined-dev  created
 +   └─ aws:sqs:Queue     asdf                      created

Outputs:
    arn: "arn:aws:sqs:us-east-1:052848974346:asdf-3b44fa5"
    url: "<https://sqs.us-east-1.amazonaws.com/052848974346/asdf-3b44fa5>"
👍 1
s
Confirmed that all worked, thanks for your help!
👍 1