pulumi / pulumi-gcp

A Google Cloud Platform (GCP) Pulumi resource package, providing multi-language access to GCP
Apache License 2.0
183 stars 53 forks source link

Error 409 whenever I try to deploy DatabaseInstance #428

Open martaver opened 4 years ago

martaver commented 4 years ago

Trying to deploy the following DatabaseInstance to our gcp account. Simple enough:

const instance = new gcp.sql.DatabaseInstance(
  'cluster-sql',
  {
    databaseVersion: 'POSTGRES_12',
    settings: {
      tier: 'db-f1-micro',
      activationPolicy: 'ALWAYS',
      availabilityType: 'REGIONAL',
      diskType: 'PD_SSD',
    },
  },
  {
    dependsOn: [sqlService, sqlAdminService],
  }
);

No matter what I do, I always get this result:

  gcp:sql:DatabaseInstance (cluster-sql):
    error: Error, failed to create instance cluster-sql-fe97a22: googleapi: Error 409: The Cloud SQL instance already exists. When you delete an instance, you cannot reuse the name of the deleted instance until one week from the deletion date., instanceAlreadyExists

Any idea what's missing here?

martaver commented 4 years ago

The instance name gets generated randomly each time, and I get the same error even I specify a unique name for the instance. No idea why its trying to delete the instance when it's performing a create operation.

martaver commented 4 years ago

Got it. It was the lack of a root password.

This is kind of an unfortunate error message for an otherwise simple 'missing required field' error...

Perhaps we can improve it?

mnlumi commented 1 year ago

I'm self assigning this issue so that I can retest to verify if this has been resolved or is still outstanding.

rshade commented 3 days ago

I just tested the following code and it works:

const instance = new gcp.sql.DatabaseInstance(
    'cluster-sql',
    {
        databaseVersion: 'POSTGRES_12',
        region: "us-west1",
        settings: {
            tier: 'db-f1-micro',
            activationPolicy: 'ALWAYS',
            availabilityType: 'REGIONAL',
            diskType: 'PD_SSD',

        },
    },
);
    pulumi:pulumi:Stack           pu_gcp_268-dev
 +   ├─ gcp:sql:DatabaseInstance   cluster-sql     create

Resources:
    + 1 to create

Updating (dev)

     Type                          Name            Status
     pulumi:pulumi:Stack           pu_gcp_268-dev
 +   ├─ gcp:sql:DatabaseInstance   cluster-sql     created (761s)

Resources:
    + 1 created

Duration: 14m9s

I did have to set a region, but got the error below:

  gcp:sql:DatabaseInstance (cluster-sql):
    error:   sdk-v2/provider2.go:520: sdk.helper_schema: Cannot determine region: set in this resource, or set provider-level 'region' or 'zone'.: provider=google-beta@8.8.0
    error: 1 error occurred:
        * Cannot determine region: set in this resource, or set provider-level 'region' or 'zone'.

@martaver are you still getting the error?