我得到以下错误:
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包的问题,或者它找不到它?
- 查看官方文档
- 在google上检查类似问题,但找不到任何
- 验证SA在那里并且工作
我在一个旧的CHANGELOGS中发现了这个从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
,现在可以工作了。