npm 错误:运行程序“”时出现未处理的异常

iswrvxsc  于 2022-11-24  发布在  其他
关注(0)|答案(1)|浏览(222)

出现以下错误:

error: Running program '/builds/infra/gcp/gke' failed with an unhandled exception:
TSError: ⨯ Unable to compile TypeScript:
iam.ts(12,34): error TS2694: Namespace '"/builds/infra/gcp/gke/node_modules/@pulumi/gcp/index"' has no exported member 'serviceAccount'.
iam.ts(20,28): error TS2339: Property 'serviceAccount' does not exist on type 'typeof import("/builds/infra/gcp/gke/node_modules/@pulumi/gcp/index")'.

这也是sa的代码:

export class GServiceAccount extends pulumi.ComponentResource {
    public readonly account: gcp.serviceAccount.Account;

    constructor(
        name: string,
        args: GServiceAccountArgs,
        opts?: pulumi.ResourceOptions
    ) {
        super("nakhoda:GServiceAccount", name, {}, opts);
        const sa = new gcp.serviceAccount.Account(
            name,
            {
                accountId: name
            },
            { parent: this }
        );
        this.account = sa;

        args.roles.map(
            r =>
                new gcp.projects.IAMMember(
                    `${name}:${r}`,
                    {
                        member: pulumi.interpolate`serviceAccount:${sa.email}`,
                        project: "nk-gke01-london",
                        role: r
                    },
                    { parent: this }
                )
        );
        this.registerOutputs({
            account: this.account
        });
    }
}

serviceAccount存在于GKE中,所以我不确定它为什么失败,可能是npm包的问题,或者是它找不到它?

  • 检查了官方文件
  • 在谷歌上检查类似问题,找不到任何东西
  • 已验证SA是否存在且正在工作
szqfcxe2

szqfcxe21#

我在Pulumi的一个旧更改日志中发现了以下内容:

* Upgrade to pulumi-terraform-bridge v2.6.0.
--
280 | **PLEASE NOTE**
281 | There is a *breaking change* in the `serviceAccount` module name:
282 | * Go `serviceAccount` is now `serviceaccount`
283 | * NodeJS `serviceAccount` is now `serviceaccount`
284 | * Python `service_account` is now `serviceaccount`

serviceAccount更改为serviceaccount,现在可以工作。

相关问题