cdk8s-team / cdk8s-cli

Apache License 2.0
38 stars 23 forks source link

Upbound AWS provider CRDs cannot be imported #2344

Open ivanfoo opened 9 months ago

ivanfoo commented 9 months ago

Description of the bug:

We are using CDK8S to generate all the components of our kubernetes applications, including AWS resources. We detected that the CRDs of the official crossplane AWS provider cannot be imported. However, the CRDs from the community provider can be imported just fine.

Reproduction Steps:

Using the CLI

cdk8s import https://raw.githubusercontent.com/upbound/provider-aws/main/package/crds/route53.aws.upbound.io_records.yaml

Using the cdk8s.yaml config file

language: python
imports:
  - k8s@1.26.0
  - https://raw.githubusercontent.com/upbound/provider-aws/main/package/crds/route53.aws.upbound.io_records.yaml

Error Log:

Importing resources, this may take a few moments...
route53.aws.upbound.io
  route53.aws.upbound.io/record
NOTE: Temp directory retained due to an error: /tmp/temp-fPgnPj
Error: jsii compilation failed with non-zero exit code: 1
  | [2023-11-20T22:43:38.110] [ERROR] jsii/compiler - Compilation errors prevented the JSII assembly from being created
  | warning JSII6: A "peerDependency" on "constructs" at "10.3.0" means you should take a "devDependency" on "constructs" at "10.3.0" (found "undefined")
  | warning JSII6: A "peerDependency" on "cdk8s" at "2.68.7" means you should take a "devDependency" on "cdk8s" at "2.68.7" (found "undefined")
  | warning JSII3: There is no "README.md" file. It is required in order to generate valid PyPI (Python) packages.
  | io.upbound.aws.route53.ts:84:67 - error TS2315: Type 'Record' is not generic.
  | 84 export function toJson_RecordProps(obj: RecordProps | undefined): Record<string, any> | undefined {
  |                                                                      ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:154:65 - error TS2315: Type 'Record' is not generic.
  | 154 export function toJson_RecordSpec(obj: RecordSpec | undefined): Record<string, any> | undefined {
  |                                                                     ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:332:87 - error TS2315: Type 'Record' is not generic.
  | 332 export function toJson_RecordSpecForProvider(obj: RecordSpecForProvider | undefined): Record<string, any> | undefined {
  |                                                                                           ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:464:89 - error TS2315: Type 'Record' is not generic.
  | 464 export function toJson_RecordSpecInitProvider(obj: RecordSpecInitProvider | undefined): Record<string, any> | undefined {
  |                                                                                             ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:532:99 - error TS2315: Type 'Record' is not generic.
  | 532 export function toJson_RecordSpecProviderConfigRef(obj: RecordSpecProviderConfigRef | undefined): Record<string, any> | undefined {
  |                                                                                                       ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:576:117 - error TS2315: Type 'Record' is not generic.
  | 576 export function toJson_RecordSpecPublishConnectionDetailsTo(obj: RecordSpecPublishConnectionDetailsTo | undefined): Record<string, any> | undefined {
  |                                                                                                                         ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:614:117 - error TS2315: Type 'Record' is not generic.
  | 614 export function toJson_RecordSpecWriteConnectionSecretToRef(obj: RecordSpecWriteConnectionSecretToRef | undefined): Record<string, any> | undefined {
  |                                                                                                                         ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:656:97 - error TS2315: Type 'Record' is not generic.
  | 656 export function toJson_RecordSpecForProviderAlias(obj: RecordSpecForProviderAlias | undefined): Record<string, any> | undefined {
  |                                                                                                     ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:692:121 - error TS2315: Type 'Record' is not generic.
  | 692 export function toJson_RecordSpecForProviderCidrRoutingPolicy(obj: RecordSpecForProviderCidrRoutingPolicy | undefined): Record<string, any> | undefined {
  |                                                                                                                             ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:720:129 - error TS2315: Type 'Record' is not generic.
  | 720 export function toJson_RecordSpecForProviderFailoverRoutingPolicy(obj: RecordSpecForProviderFailoverRoutingPolicy | undefined): Record<string, any> | undefined {
  |                                                                                                                                     ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:761:135 - error TS2315: Type 'Record' is not generic.
  | 761 export function toJson_RecordSpecForProviderGeolocationRoutingPolicy(obj: RecordSpecForProviderGeolocationRoutingPolicy | undefined): Record<string, any> | undefined {
  |                                                                                                                                           ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:799:119 - error TS2315: Type 'Record' is not generic.
  | 799 export function toJson_RecordSpecForProviderHealthCheckIdRef(obj: RecordSpecForProviderHealthCheckIdRef | undefined): Record<string, any> | undefined {
  |                                                                                                                           ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:843:129 - error TS2315: Type 'Record' is not generic.
  | 843 export function toJson_RecordSpecForProviderHealthCheckIdSelector(obj: RecordSpecForProviderHealthCheckIdSelector | undefined): Record<string, any> | undefined {
  |                                                                                                                                     ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:872:127 - error TS2315: Type 'Record' is not generic.
  | 872 export function toJson_RecordSpecForProviderLatencyRoutingPolicy(obj: RecordSpecForProviderLatencyRoutingPolicy | undefined): Record<string, any> | undefined {
  |                                                                                                                                   ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:899:129 - error TS2315: Type 'Record' is not generic.
  | 899 export function toJson_RecordSpecForProviderWeightedRoutingPolicy(obj: RecordSpecForProviderWeightedRoutingPolicy | undefined): Record<string, any> | undefined {
  |                                                                                                                                     ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:935:105 - error TS2315: Type 'Record' is not generic.
  | 935 export function toJson_RecordSpecForProviderZoneIdRef(obj: RecordSpecForProviderZoneIdRef | undefined): Record<string, any> | undefined {
  |                                                                                                             ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:979:115 - error TS2315: Type 'Record' is not generic.
  | 979 export function toJson_RecordSpecForProviderZoneIdSelector(obj: RecordSpecForProviderZoneIdSelector | undefined): Record<string, any> | undefined {
  |                                                                                                                       ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:1022:99 - error TS2315: Type 'Record' is not generic.
  | 1022 export function toJson_RecordSpecInitProviderAlias(obj: RecordSpecInitProviderAlias | undefined): Record<string, any> | undefined {
  |                                                                                                        ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:1058:123 - error TS2315: Type 'Record' is not generic.
  | 1058 export function toJson_RecordSpecInitProviderCidrRoutingPolicy(obj: RecordSpecInitProviderCidrRoutingPolicy | undefined): Record<string, any> | undefined {
  |                                                                                                                                ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:1086:131 - error TS2315: Type 'Record' is not generic.
  | 1086 export function toJson_RecordSpecInitProviderFailoverRoutingPolicy(obj: RecordSpecInitProviderFailoverRoutingPolicy | undefined): Record<string, any> | undefined {
  |                                                                                                                                        ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:1127:137 - error TS2315: Type 'Record' is not generic.
  | 1127 export function toJson_RecordSpecInitProviderGeolocationRoutingPolicy(obj: RecordSpecInitProviderGeolocationRoutingPolicy | undefined): Record<string, any> | undefined {
  |                                                                                                                                              ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:1156:131 - error TS2315: Type 'Record' is not generic.
  | 1156 export function toJson_RecordSpecInitProviderWeightedRoutingPolicy(obj: RecordSpecInitProviderWeightedRoutingPolicy | undefined): Record<string, any> | undefined {
  |                                                                                                                                        ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:1192:111 - error TS2315: Type 'Record' is not generic.
  | 1192 export function toJson_RecordSpecProviderConfigRefPolicy(obj: RecordSpecProviderConfigRefPolicy | undefined): Record<string, any> | undefined {
  |                                                                                                                    ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:1229:135 - error TS2315: Type 'Record' is not generic.
  | 1229 export function toJson_RecordSpecPublishConnectionDetailsToConfigRef(obj: RecordSpecPublishConnectionDetailsToConfigRef | undefined): Record<string, any> | undefined {
  |                                                                                                                                            ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:1273:133 - error TS2315: Type 'Record' is not generic.
  | 1273 export function toJson_RecordSpecPublishConnectionDetailsToMetadata(obj: RecordSpecPublishConnectionDetailsToMetadata | undefined): Record<string, any> | undefined {
  |                                                                                                                                          ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:1311:131 - error TS2315: Type 'Record' is not generic.
  | 1311 export function toJson_RecordSpecForProviderHealthCheckIdRefPolicy(obj: RecordSpecForProviderHealthCheckIdRefPolicy | undefined): Record<string, any> | undefined {
  |                                                                                                                                        ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:1348:141 - error TS2315: Type 'Record' is not generic.
  | 1348 export function toJson_RecordSpecForProviderHealthCheckIdSelectorPolicy(obj: RecordSpecForProviderHealthCheckIdSelectorPolicy | undefined): Record<string, any> | undefined {
  |                                                                                                                                                  ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:1385:117 - error TS2315: Type 'Record' is not generic.
  | 1385 export function toJson_RecordSpecForProviderZoneIdRefPolicy(obj: RecordSpecForProviderZoneIdRefPolicy | undefined): Record<string, any> | undefined {
  |                                                                                                                          ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:1422:127 - error TS2315: Type 'Record' is not generic.
  | 1422 export function toJson_RecordSpecForProviderZoneIdSelectorPolicy(obj: RecordSpecForProviderZoneIdSelectorPolicy | undefined): Record<string, any> | undefined {
  |                                                                                                                                    ~~~~~~~~~~~~~~~~~~~
  | io.upbound.aws.route53.ts:1483:147 - error TS2315: Type 'Record' is not generic.
  | 1483 export function toJson_RecordSpecPublishConnectionDetailsToConfigRefPolicy(obj: RecordSpecPublishConnectionDetailsToConfigRefPolicy | undefined): Record<string, any> | undefined {
  |                                                                                                                                                        ~~~~~~~~~~~~~~~~~~~
  +----------------------------------------------------------------------------------
  | Command: /usr/local/lib/node_modules/cdk8s-cli/node_modules/jsii-srcmak/node_modules/jsii/bin/jsii --silence-warnings reserved-word
  | Workdir: /tmp/temp-fPgnPj
  +----------------------------------------------------------------------------------
    at newError (/usr/local/lib/node_modules/cdk8s-cli/node_modules/jsii-srcmak/lib/util.js:62:20)
    at ChildProcess.<anonymous> (/usr/local/lib/node_modules/cdk8s-cli/node_modules/jsii-srcmak/lib/util.js:79:29)
    at Object.onceWrapper (node:events:629:26)
    at ChildProcess.emit (node:events:514:28)
    at ChildProcess._handle.onexit (node:internal/child_process:294:12)

Environment:

We are running the import command process inside a container with:

Other:

I can use the crossplane community provider CRDs, but not the official upbound ones.

cdk8s import https://raw.githubusercontent.com/crossplane/provider-aws/master/package/crds/route53.aws.crossplane.io_resourcerecordsets.yaml

Importing resources, this may take a few moments...
route53.aws.crossplane.io
  route53.aws.crossplane.io/resourcerecordset

This is :bug: Bug Report

iliapolo commented 3 months ago

This happens because the CR is named Record, which conflicts with the built-in TypeScript Record. We could potentially use globalThis.Record instead. Need to research whether or not this works across the board.

In the meantime this can be worked around by providing a class name prefix to the import command:

cdk8s import --class-prefix Route53 https://raw.githubusercontent.com/upbound/provider-aws/main/package/crds/route53.aws.upbound.io_records.yaml