Skip to content

Commit d85c294

Browse files
committed
fix: #3630 Due to skipping of attributes, we need to render certain blocks better
This is a side-effect of our effort to reduce provider size from blowing up. We use a skip list to ignore a very small number of attributes that are known to bloat the size of the provider significantly. This doesn't cause a problem for our JSON synthesis, since it doesn't care too much about types, but the HCL synthesis is more sensitive. This commit, while not fixing the problem, will do two things. First, it tries its best to output the attribute contents, and secondly, lets the user know this is a problem and one that they might want to fix either manually, or just use JSON output
1 parent b541c70 commit d85c294

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

packages/cdktf/lib/hcl/render.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,25 @@ ${renderAttributes(value)}
671671
if (classType === "number" || classType === "boolean") {
672672
return `${name} = ${value}`;
673673
}
674+
675+
// Not sure why we're here, but there's either a bug in the provider
676+
// or we have skipped the attribute to reduce the size of our provider
677+
// In either case, we should try to not output [object Object] here
678+
// and try a best approximation. Though, it would not work for
679+
// blocks
680+
if (typeof value === "object") {
681+
return `
682+
# Warning: The following attribute is of an unexpected type. Either there's a problem with the provider
683+
# or CDKTF has chosen to skip generating a detailed type for this because it increases the size of the provider library significantly.
684+
# Please check if this resource is included in our skip list:
685+
# https://github.com/hashicorp/terraform-cdk/blob/main/packages/%40cdktf/provider-generator/lib/get/generator/skipped-attributes.ts
686+
# and if not, please check with the provider authors to see if the provider schema is accurate.
687+
#
688+
# We understand this is not ideal, so we suggest using JSON synthesis instead of HCL synthesis for this particular case.
689+
690+
${name} = ${renderFuzzyJsonExpression(value)}
691+
`;
692+
}
674693
}
675694

676695
if (type === "any") {

0 commit comments

Comments
 (0)