cdklabs/cdk-import

Support arrays

tenjaa opened this issue · 1 comments

Hi :)
We have a few private resources which I want to generate L1 constructs for.
For some of them I get always the same error:

Unsupported type {"type":"array","items":{"type":"string"}} for read-only property (attribute) PRIVATE::PRIVATE::Shared.Subnets

The properties of the schema look like this:

  "properties": {
    "Id": {
      "description": "unique identifier",
      "type": "string"
    },
    "VpcId": {
      "description": "id of the vpc",
      "type": "string"
    },
    "Subnets": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },

Therefore for me it looks like arrays are not supported yet.
Is that assumption correct? Could it be implemented?

edit: Looking at

it looks like it should work.. Any hints on how to debug this better?

edit2: Found it!
Adding && def.type !== 'array' to

if (def.type !== 'string' && def.type !== 'number') {
solves it for me.
It gets properly resolved via this.attrSubnets = cdk.Token.asList(this.getAtt('Subnets'));

What do you think about fixing that? Did I miss something?

Hi @madeline-k I saw you merging my other pull request.
Could you have a quick look at this one too? A fix is already included :)