pulumi-aws icon indicating copy to clipboard operation
pulumi-aws copied to clipboard

Directly importing a type leads to exception

Open joeduffy opened this issue 5 years ago • 8 comments

If I try to do this

import { Table } from "@pulumi/aws/dynamodb";
new Table(...);

rather than this

import * as aws from "@pulumi/aws";
new aws.dynamodb.Table(...);

I receive the following error

Running program '...' failed with an unhandled exception:
    TypeError: Class extends value undefined is not a constructor or null
        at Object.<anonymous> (.../node_modules/@pulumi/cloudwatch/eventRuleMixins.ts:70:55)
        at Module._compile (module.js:573:30)
        at Object.Module._extensions..js (module.js:584:10)
        at Module.load (module.js:507:32)
        at tryModuleLoad (module.js:470:12)
        at Function.Module._load (module.js:462:3)
        at Module.require (module.js:517:17)
        at require (internal/module.js:11:18)
        at Object.<anonymous> (.../node_modules/@pulumi/cloudwatch/cloudwatchMixins.ts:16:1)
        at Module._compile (module.js:573:30)

I assume this is an import ordering issue and might not be something we can fix. If it is fixable, however, that would be nice, as the former import style is preferable sometimes.

joeduffy avatar Oct 16 '19 22:10 joeduffy

I think this may be easy to fix. The main issue is that we generate our index.ts in these cloud providers such that they import their own directory files in alphabetical order. This can be highly problematic with ordering.

I solved this in Azure (where it actually was blocking us) by making all the mixins called zMixins.ts so they would be mixed in at the end, after all the normal code had loaded. I think that should fix the issue here.

CyrusNajmabadi avatar Oct 17 '19 00:10 CyrusNajmabadi

Great! Not super urgent, obviously, but probably a nice thing to fix eventually.

joeduffy avatar Oct 17 '19 01:10 joeduffy

Had this same issue importing aws.s3.Bucket.

nickcaballero avatar Aug 30 '21 20:08 nickcaballero

Had this same issue importing aws.cloudwatch.LogGroup

kxtran avatar Feb 04 '22 15:02 kxtran

I have the same problem with aws.cloudwatch.LogGroup.

Figured out temporary fix which is probably better than importing * from aws package:

import { cloudwatch } from "@pulumi/aws";
new cloudwatch.LogGroup(...)

Dysproz avatar Feb 04 '22 15:02 Dysproz

Any updates on this? I am also having this issue.

andrewdibiasio6 avatar Mar 25 '22 14:03 andrewdibiasio6

Actively working on this. Blocked for the moment b/c we need to update the pulumi-terraform-bridge > 3.26.1.

jkodroff avatar Aug 10 '22 14:08 jkodroff

Very annoying issue that has been around for almost three years now. Any plans of fixing it?

mdipirro avatar Aug 29 '22 14:08 mdipirro

+1, still an issue on pulumi v3.43.1 with "@pulumi/aws": "5.17.0"

jwarwick-delfi avatar Oct 19 '22 17:10 jwarwick-delfi