From 6a5266fbaf291318fc7cdbf583aa8f77ee418183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Fri, 28 Jun 2019 11:13:22 +0200 Subject: [PATCH] fix(code): make CfnResource#_toCloudFormation null-safe The `CfnResource#_toCloudFormation` method creates a `PostResolveToken` with a post-processor that was not ready to handle the absence of `Properties` on the resolved value. It is however possible that `Properties` are missing when an object is created with the default configuration (e.g: by `new sqs.CfnQueue(this, 'Queue');`). This change makes the post-processor function correctly handle `undefined` in this case. Related #3093 --- packages/@aws-cdk/core/lib/cfn-resource.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/core/lib/cfn-resource.ts b/packages/@aws-cdk/core/lib/cfn-resource.ts index edb7d3f87a8ea..c4db697d6dccf 100644 --- a/packages/@aws-cdk/core/lib/cfn-resource.ts +++ b/packages/@aws-cdk/core/lib/cfn-resource.ts @@ -230,7 +230,7 @@ export class CfnResource extends CfnRefElement { Metadata: ignoreEmpty(this.cfnOptions.metadata), Condition: this.cfnOptions.condition && this.cfnOptions.condition.logicalId }, props => { - props.Properties = this.renderProperties(props.Properties); + props.Properties = props.Properties && this.renderProperties(props.Properties); return deepMerge(props, this.rawOverrides); }) }