Pulumi GCP MemoryStore Redis缓存内部服务器错误13

Pulumi GCP MemoryStore Redis Cache Internal Server Error 13

我这里有一个奇怪的场景。

我的 Pulumi 打字稿代码中的以下行第一次总是失败:

const redisCache = new gcp.redis.Instance("my-redis-cache", {
            name: "my-metadata-cache",
            tier: "BASIC",
            memorySizeGb: 1,
            authorizedNetwork: pulumi.interpolate`projects/someprojectid/global/networks/default`,
            connectMode: "PRIVATE_SERVICE_ACCESS",
            redisVersion: "REDIS_6_X",
            displayName: "My Metadata Cache",
            project: someprojectid,
        }, defaultResourceOptions);

**

error: 1 error occurred: * Error waiting to create Instance: Error waiting for Creating Instance: Error code 13, message: an internal error has occurred

**

奇怪的是,当我再次运行pulumi起来的时候,就成功了。有没有其他人遇到过这个?有什么线索吗?

好的,事实证明这是一个使用代码野兽的案例。一旦我开始隔离问题,事情就变得更加清晰了。对于那些偶然发现这个代码的人,这里有一个完整的工作代码。

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
 
export interface CacheComponentResourceArgs {
              projectId : pulumi.Input<string>;
              projectNumber: pulumi.Input<string>;
}
 
export class CacheComponentResource extends pulumi.ComponentResource {
              constructor(name: string, resourceArgs: CacheComponentResourceArgs, opts?: pulumi.ResourceOptions) {
                           const inputs: pulumi.Inputs = {
                                         options: opts,
                           };
                           super("ekahaa:abstracta:Cache", name, inputs, opts);
                           
                           const serviceNetworkingAccessService = new gcp.projects.Service("service-nw-" + name , {
                                         disableDependentServices: true,
                                         project: resourceArgs.projectId,
                                         service: "servicenetworking.googleapis.com",
                           }, {
                                         parent : this
                           });
 
 
                           const redisService = new gcp.projects.Service("redis-service-" + name, {
                                         disableDependentServices: true,
                                         project: resourceArgs.projectId,
                                         service: "redis.googleapis.com",
                           }, {
                                         parent : this
                           });
 
                           const defaultGlobalAddress = new gcp.compute.GlobalAddress("default-ip-range-" + name, {
                                         name: "default-ip-range",
                                         purpose: "VPC_PEERING",
                                         prefixLength: 16,
                                         project: resourceArgs.projectId,
                                         addressType: "INTERNAL",
                                         network: pulumi.interpolate`projects/${resourceArgs.projectId}/global/networks/default`
                           }, {
                                         parent : this,
                                         dependsOn: [ redisService]
                           });
 
                           const privateServiceConnection = new gcp.servicenetworking.Connection("servicenetworking-" + name, {
                                         service: "servicenetworking.googleapis.com",
                                         network: pulumi.interpolate`projects/${resourceArgs.projectId}/global/networks/default`,
                                         reservedPeeringRanges: [defaultGlobalAddress.name],
                           }, {
                                         parent : this,
                                         dependsOn: [ defaultGlobalAddress]
                           });
 
 
                           const iamBindingRedis2 = new gcp.projects.IAMBinding("iamredis2-" + name, {
                                         members: [
                                                       pulumi.interpolate`serviceAccount:service-${resourceArgs.projectNumber}@service-networking.iam.gserviceaccount.com`
                                         ],
                                         role: "roles/servicenetworking.serviceAgent",
                                         project: resourceArgs.projectId
                           }, { 
                           parent : this,
                           dependsOn: [privateServiceConnection] 
                           });
 
                           const redisCache = new gcp.redis.Instance(name, {
                                         name: name,
                                         tier: "BASIC",
                                         memorySizeGb: 1,
                                         authorizedNetwork: pulumi.interpolate`projects/${resourceArgs.projectId}/global/networks/default`,
                                         connectMode: "PRIVATE_SERVICE_ACCESS",
                                         redisVersion: "REDIS_6_X",
                                         displayName: "Abstracta Metadata Cache",
                                         project: resourceArgs.projectId,
                           }, {
                                         parent : this,
                                         dependsOn : [redisService,serviceNetworkingAccessService,iamBindingRedis2]
                           });
                           
                           this.registerOutputs({
                                         redisCache : redisCache
                           });
 
              }
}
 
let suffix = "20211018-002";
let org_name = `org-redis-demo-${suffix}`;
let projectId = `redis-demo-${suffix}` ;
 
const myGcpProject = new gcp.organizations.Project('ab-' + org_name, {
              orgId: gcpOrgId,
              projectId: projectId,
              billingAccount: billingAccountId,
              name: 'ab-' + org_name,
});
 
const myGcpProjectIAM = new gcp.projects.IAMBinding("iam-001", {
              members: [
                           "user:vikram.vasudevan@ekahaa.com",
],
              role: "roles/owner",
              project: myGcpProject.projectId
});
 
const cacheComponentResource = new CacheComponentResource("my-cache", {
              projectId : myGcpProject.projectId,
              projectNumber : myGcpProject.number
}, {
              dependsOn : [myGcpProjectIAM]
});