-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use Condition
(or condition.ref
) in FnOr
#1457
Comments
We've generally avoided Conditions so far, since we prefer expressing conditions in the CDK app. I'm assuming you're using CDK to generate reusable templates that will be deployed by someone else? Will look into the code. |
I think the idea was to use const hasManagedPolicies = new cdk.Condition(this, "HasManagedPolicies", {
expression: new cdk.FnOr(
useManagedPolicyARN.ref,
useEcr.ref
)
}); Does that not work? |
Yep, this is me evaluating CDK as "a tool to synthesize templates" rather than "a tool to manage AWS". We're not big users of conditions anyway, but nice to have coverage. That example unfortunately doesn't work - |
Got it. Will file this as a bug then. |
Condition
(or condition.ref
) in FnOr
Change `conditionXx` methods to accept an interface `IConditionExpression` instead of concrete class and implement this interface by the `Condition` construct. This enables chaining conditions like so: const cond1, cond2, cond, cond4 = new cdk.Condition(...) Fn.conditionOr(cond1, cond2, Fn.conditionAnd(cond3, cond4)) Fixes #1457
Change `conditionXx` methods to accept an interface `IConditionExpression` instead of concrete class and implement this interface by the `Condition` construct. This enables chaining conditions like so: const cond1, cond2, cond, cond4 = new cdk.Condition(...) Fn.conditionOr(cond1, cond2, Fn.conditionAnd(cond3, cond4)) Fixes #1457
eg:
or even:
It feels like I should be able to do this:
But the
cdk.Condition
class does not match the type definition of the predicate functions (which requireFnCondition
.After some mucking around, I found the following workaround, but it relies on
Fn
simply re-emitting exactly what it's passed:This applies to referring to Conditions within
FnOr
and so forth within resources as well.What is the correct way to express this in CDK?
The text was updated successfully, but these errors were encountered: