1
votes

I have two CloudFormation templates: the first template has with my Lambda functions and, the second, an SQS queue.

In the first template, I export the Lambda ARN and, in the second, I export the SQS queue URL and ARN.

Also, in the first template, I import the SQS queue URL and ARN to pass the value to the Lambda code and give permission to Lambda to send a message to SQS, respectively. In the second template, I import the Lambda ARN to give permission to Lambda to send a message to that SQS queue.

My concern is about the circular dependency between import/export values that was created with this configuration. At the moment of the deploy, there were no errors, but I'm wondering if this is a bad configuration or not.

1
Are they required to be in separate stacks? Because what you are describing does not seem ideal.Gary Holiday

1 Answers

1
votes

If you are using exports/imports the only way this can work at all is with conditions on the resources using the imports, and running at least of the stacks twice. That’s not ideal, and it will also take two steps to delete the stacks (you can’t delete a stack if another stack imports an export from that stack).

The better solution here is to put all the dependencies in one stack (better yet, put it all in one stack if you can). In your case you could create the SQS queue and export it’s info and do all the dependent resources in the lambda stack.