5
votes

Building a CloudFormation stack template, I have a setup constellation where upon instantiation I want to reference either the name of another CloudFormation stack or a non-CloudFormation-managed database as a parameter.

Is there a way to represent this constellation in my template? I.e. "Parameter DatabaseHost is mandatory if Parameter DatabaseStack is blank"?

1
I don't believe so. You could make both optional, but add commentary that the user must provide one or the other. Or have two templates. - jarmod
thank your for checking. I had hoped to not need two templates but since I'm using a Ruby DSL, it might be the best approach since I can just as well share some Ruby code and avoid the duplication that would come from having two completely separate JSON-based stacks. Feel free to post this as an answer, too. - milgner

1 Answers

2
votes

I'm not aware of a native option in CloudFormation to make one template parameter conditional on a second template parameter.

Possible workarounds might be:

  • make both optional, and tell user to supply one of them
  • use two templates, one for each of the two use cases
  • programmatically generate your template after asking the user for parameters