https://pulumi.com logo
#typescript
Title
# typescript
w

worried-queen-62794

12/16/2020, 11:27 AM
Any idea why I am getting this error?
Copy code
Diagnostics:
  pulumi:pulumi:Stack (auth-prod):
    error: Running program '/Users/jason/source/tlayen-infrastructure/security/auth' failed with an unhandled exception:
    TypeError: Class constructor ComponentResource cannot be invoked without 'new'
        at new UserRole (/Users/jason/source/tlayen-infrastructure/modules/pulumix-aws/dist/index.js:77:28)
I am calling `new`:
Copy code
const administratorUserRole = new UserRole("Administrator", {
    accountId: accountId
}, opts);
All my other ComponentResources work fine.
b

brave-planet-10645

12/16/2020, 11:51 AM
Can you show your
UserRole
code? (happy to take this out of slack if there is sensitive information there)
l

little-cartoon-10569

12/16/2020, 7:24 PM
Seems that error often has something to do with ES5/ES6 mismatches? https://stackoverflow.com/a/50203532/3195526
w

worried-queen-62794

12/16/2020, 8:05 PM
The UserRole looks like:
Copy code
export class UserRole extends pulumi.ComponentResource {
    role: aws.iam.Role;
    assumeRolePolicy: aws.iam.Policy;

    constructor(name: string, args: UserRoleArgs, opts?: pulumi.InvokeOptions) {
        super("allfiguredout:auth:UserRole", name, {}, opts);

        const childOpts = { ...opts, parent: this };

        this.role = new aws.iam.Role(name, {
            path: "/user/",
            assumeRolePolicy: accountAssumeRolePolicy(args.accountId),
            tags: tags()
        }, childOpts);

        this.assumeRolePolicy = new aws.iam.Policy(`Assume${name}Role`, {
            description: `Allows access to assume the ${name} role.`,
            policy: assumeRolePolicy(this.role.arn)
        }, childOpts);

        this.registerOutputs();
    }
}
Ah yeah ok so using
es6
target fixes it.
Strange how the others worked. I would have thought they would have the same issue.
5 Views