aws-cloudformation / aws-cloudformation/cloudformation-coverage-roadmap
Allow conditions passed as parameters to be used in modules
- Dominant language
- No language data
- Stars
- 1.1k
- Forks
- 62
- PR merge metrics
- No merged PRs in 30d
Description
### Name of the resource
Other
### Resource name
_No response_
### Description
Currently, one cannot pass a condition from a top level module to a custom module for usage in a module's lower level condition. Below I present the condition for which this occurs:
Top Level file:
```yaml
AWSTemplateFormatVersion: "2010-09-09"
Parameters:
Var1:
Type: String
Default: ''
Var2:
Type: String
Default: ''
Conditions:
BothVarsFilled: !And
- !Not
- !Equals
- !Ref Var1
- ''
- !Not
- !Equals
- !Ref Var2
- ''
Resources:
MyModule:
Type: "CUSTOM::Test::Test::MODULE"
Properties:
AreBothVarsFilled: !If [BothVarsFilled, true, false]
```
`CUSTOM::Test::Test::MODULE`:
```yaml
AreBothVarsFilled:
Type: String
AllowedValues:
- true
- false
Description: Boolean parameter validating whether both vars are filled.
Conditions:
BothVarsFilledCond: !Equals
- !Ref AreBothVarsFilled
- true
Resources:
NewResource:
Type: ...
Condition: BothVarsFilledCond
Properties:
...
```
In this case, currently one receives the following error message when deploying a stack:
```
CloudFormation failed to preprocess the stack: Template error: Fn::If cannot be preprocessed
```
This occurs because the module condition is utilizing the condition from the top level as a parameter.
### Other Details
Likely the same issue experienced by: https://github.com/aws-cloudformation/cloudformation-coverage-roadmap/issues/1257
Contributor guide
Research direction
Start by reproducing the deployment with the top-level YAML template and the CUSTOM::Test::Test::MODULE definition, focusing on the Fn::If preprocessing failure. Done means a condition passed as a module parameter can be used by the module's lower-level Condition without producing the reported error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, yaml
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100