[Core] support complex types in Fn.conditionIf #24381
Replies: 11 comments
-
I am dealing with a similar issue. Code before the change:
Code after the change:
Template before the change:
Template after the change:
Notice that the template after the change incorrectly uses |
Beta Was this translation helpful? Give feedback.
-
We don't support this and I don't see us supporting it anytime soon. |
Beta Was this translation helpful? Give feedback.
-
I will reopen this issue for reference but I will reiterate that the happy path for CDK is writing |
Beta Was this translation helpful? Give feedback.
-
@rix0rrr Thanks for reconsidering. A reminder that the use case presented in the ticket description is using Cfn* resources to generate a CloudFormation template final deliverable and the suggested happy path of doing |
Beta Was this translation helpful? Give feedback.
-
+1 for the use-case to generate standalone CFN templates. I had to use the same sort of workaround for conditionals on the FSx Lustre resource configuration block. Red line is desired. |
Beta Was this translation helpful? Give feedback.
-
@bollig what is the workaround mechanism here? I want to set |
Beta Was this translation helpful? Give feedback.
-
See
https://github.com/aws-samples/no-tears-cluster/blob/31d881b9a7fc864bf01538fb05266978cb8562c6/pcluster/pcluster_stack.py#L140
for the working solution and full context.
Cheers,
-E
On Wed, Jun 9, 2021 at 5:07 AM Martynas Jusevičius ***@***.***> wrote:
@bollig <https://github.com/bollig> what is the workaround mechanism here?
I want to set NetworkLoadBalancedEc2Service.domainZone() if HostedZone is
provided, but not sure how to do it with Fn.conditionIf() since it
provides a string and not an object :/
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#8396 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABNWQXKL3JY2ZZCX76LJHTTR44MRANCNFSM4NTNH76A>
.
--
-Evan Bollig
***@***.***
***@***.***
|
Beta Was this translation helpful? Give feedback.
-
@rix0rrr Any chance of getting this one addressed? We are also using CDK to generate CloudFormation templates to be manually deployed in other environments so using This seems to be a valid use case. |
Beta Was this translation helpful? Give feedback.
-
@rix0rrr We are having the same problem with DynamoDB. Depending on the input parameter value, we need to set sse_specification. It generates the cloudformation yaml file, but the output is camelCase yaml attributes, and it errors out. sse_specification = cdk.Fn.condition_if(
"NotEncryptedSearchTable",
aws_dynamodb.CfnTable.SSESpecificationProperty(
sse_enabled = False
),
aws_dynamodb.CfnTable.SSESpecificationProperty(
sse_enabled = True,
kms_master_key_id=inputParams.EncryptionKeyArn,
sse_type="KMS"
)
) Here is the yaml output, which is invalid. SSESpecification:
Fn::If:
- NotEncryptedSearchTable
- sseEnabled: false
- kmsMasterKeyId:
Ref: EncryptionKeyArn
sseEnabled: true
sseType: KMS |
Beta Was this translation helpful? Give feedback.
-
@rix0rrr Can we get an official decision on the validity of this use case? Is using |
Beta Was this translation helpful? Give feedback.
-
Thank you for submitting this feature request! After closer examination of the issue by CDK product and development team, there are no plans to implement this in the near feature. I am moving this to a GitHub discussion so the information in this thread can continue to be accessible, and people can find the helpful workaround posted here. |
Beta Was this translation helpful? Give feedback.
-
I am using the CDK to output a raw CloudFormation template as a final deliverable and am using primarily Cfn* resource constructs. We have a CfnPipeline object where I want to conditionally add a stage depending on a CfnParameter value. I have the following code:
Which produces the following output in my CloudFormation template:
The keys of the CfnPipeline.StageDeclarationProperty and its children (CfnPipeline.ActionDeclarationProperty and CfnPipeline.ActionTypeIdProperty) are printed in camelCase, making for invalid CloudFormation objects on submission. I've also tried by wrapping the conditional statement in core.Token.as_any() with the same result.
I have resorted to using the following code:
which fixes my issue and proves that my conditional is valid in CloudFormation, but it feels messy and like the Cfn* properties should be supported in conditionals (IResolvable?).
Feels like this is a bug, but might be a feature request -- perhaps something is missing in the translation layer between nodejs and the Python API? If I'm supposed to be using the API differently, please advise.
Reproduction Steps
Run the above code patterns and inspect the cloudformation template in cdk.out
Error Log
CloudFormation complains of invalid object syntax.
Environment
Other
https://github.com/ordinaryexperts/aws-marketplace-oe-patterns-drupal/blob/f0201c49583a553832d72267ba07850b1bbe4aca/cdk/drupal/drupal_stack.py#L1870
This is 🐛 Bug Report
Beta Was this translation helpful? Give feedback.
All reactions