Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
If you are interested in working on this issue or have submitted a pull request, please leave a comment
Tell us about your request
What do you want us to build?
The ability for conditions to work using a dynamic element within the template.
Tell us about the problem you are trying to solve. What are you trying to do, and why is it hard?
I was writing a template where I needed to decide whether to create a resource based on whether there was an existing resource already in the account with the same name. In this case it was an IAM role however it could be anything.
Whilst conditions can be used to determine whether to create a resource, these can only be influenced by parameter values which are static for the template. When operating at scale using Stack Sets across many accounts it is impractical to alter the parameter value for each individual account.
I know CloudFormation does not have the ability to determine whether something exists, (that in itself could be another feature request), however it does have the ability to use Custom Resources that can do this check for you. However, a custom resource with a bool value indicating whether something exists or not cannot be used to influence the evaluation of a Condition. This is because conditions currently do not allow inputs from the Resources section.
Are you currently working around this issue?
I create a horrible hack where I would check to see whether something existed using a custom resource then would return an alternative name if it did and then use this name for the resource so as to not clash with the existing resource. This results in a useless resource being created.
What is the expected behavior with this new feature
Conditions that can be influenced by the output from a resource, or some other way of dynamically determining whether something should be created or not.
Additional context
Everyone who I talk to about this problem says use Terraform however this is not the answer when you already have a large deployment of CloudFormation and wish to have the server side state advantages and integration that CloudFormation brings.
Community Note
Tell us about your request
What do you want us to build? The ability for conditions to work using a dynamic element within the template.
Tell us about the problem you are trying to solve. What are you trying to do, and why is it hard?
I was writing a template where I needed to decide whether to create a resource based on whether there was an existing resource already in the account with the same name. In this case it was an IAM role however it could be anything.
Whilst conditions can be used to determine whether to create a resource, these can only be influenced by parameter values which are static for the template. When operating at scale using Stack Sets across many accounts it is impractical to alter the parameter value for each individual account.
I know CloudFormation does not have the ability to determine whether something exists, (that in itself could be another feature request), however it does have the ability to use Custom Resources that can do this check for you. However, a custom resource with a bool value indicating whether something exists or not cannot be used to influence the evaluation of a Condition. This is because conditions currently do not allow inputs from the Resources section.
Are you currently working around this issue?
I create a horrible hack where I would check to see whether something existed using a custom resource then would return an alternative name if it did and then use this name for the resource so as to not clash with the existing resource. This results in a useless resource being created.
What is the expected behavior with this new feature
Conditions that can be influenced by the output from a resource, or some other way of dynamically determining whether something should be created or not.
Additional context
Everyone who I talk to about this problem says use Terraform however this is not the answer when you already have a large deployment of CloudFormation and wish to have the server side state advantages and integration that CloudFormation brings.