Roelant
Roelant

Reputation: 5119

Cloudformation dependencies on shared resource

Situation:

We have Service A and Service B that are deployed in the same AWS account. They both expect another stack with datalake D (Athena) to be deployed in this account.

Should the cloudformation template of Service A and Service B depend on the Datalake D? And if so, how would you do that? Or should they just assume it exists and only manage their downstream resources?

It feels you should reference it because if we move Service A to another account, one might forget this dependency. On the other hand, we don't want both Service A and B to deploy the stack since it is only needed once.

Upvotes: 0

Views: 719

Answers (1)

Marcin
Marcin

Reputation: 238995

Assuming that A, B and D are all stacks to be created in the same region and account, you could use cross-stack references to interlink D with A and B.

In this solution, the stack D would export its outputs. For example:

Outputs:
  OutputFromD:
    Value: <a-value-to-be-exported>
    Export:
      Name: <export-name>

Then, where you need the OutputFromD in A and B, you would use ImportValue. For example, in A and B:

Resources:

  SomeResource:
    Properties:
      SomeProperty: !ImportValue <export-name>

Upvotes: 2

Related Questions