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

Deleted DatabaseInstance causes User and Database dependents to fail to refresh #268

Open AaronFriel opened 4 years ago

AaronFriel commented 4 years ago

Suppose I have a DatabaseInstance Foo, and it contains a user (bar of course) and a database (quux of course).

If someone manually deletes Foo from the Google Cloud Console, the stack is now in a stuck state, because trying to redeploy it using pulumi up --refresh results in this error:

246  ~  gcp:sql:DatabaseInstance foo refresh 
247  ~  gcp:sql:User bar refreshing error: Preview failed: refreshing
  urn:pulumi:[stack]::[project]::gcp:sql/user:User::bar: Error reading SQL User
  "bar" in instance "foo": googleapi: Error 400: Invalid request: Invalid
  request since instance is not running., invalid
248  ~  gcp:sql:Database quux refreshing error: Preview failed: refreshing
  urn:pulumi:[stack]::[project]::gcp:sql/database:Database::quux: Error reading
  SQLDatabase "foo:quux": googleapi: Error 400: Invalid request: Invalid request
  since instance is not running., invalid
mikhailshilkov commented 1 year ago

Tracked upstream in https://github.com/hashicorp/terraform-provider-google/issues/7810

rshade commented 1 week ago

Repro:

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

// Create a new SQL Database Instance
const instance = new gcp.sql.DatabaseInstance("my-instance", {
    name: "my-instance",
    region: "us-central1",
    databaseVersion: "MYSQL_8_0",
    settings: {
        tier: "db-f1-micro",
    },
});

// Create a new SQL Database
const database = new gcp.sql.Database("my-database", {
    name: "my-database",
    instance: instance.name,
    charset: "utf8",
    collation: "utf8_general_ci",
});

// Create a new SQL User
const user = new gcp.sql.User("my-user", {
    name: "my-user",
    instance: instance.name,
    password: "my-password",
});
rshade commented 1 week ago

It looks like this is still a problem in terraform:


tf refresh
google_sql_database_instance.myinstance: Refreshing state... [id=my-instance]
google_sql_database.my_database: Refreshing state... [id=projects/pulumi-ce-team/instances/my-instance/databases/my-database]
google_sql_user.my_user: Refreshing state... [id=my-user//my-instance]
╷
│ Error: googleapi: Error 404: The Cloud SQL instance does not exist., instanceDoesNotExist
│
│   with google_sql_database.my_database,
│   on main.tf line 18, in resource "google_sql_database" "my_database":
│   18: resource "google_sql_database" "my_database" {
│
╵
╷
│ Error: googleapi: Error 404: The Cloud SQL instance does not exist., instanceDoesNotExist
│
│   with google_sql_user.my_user,
│   on main.tf line 26, in resource "google_sql_user" "my_user":
│   26: resource "google_sql_user" "my_user" {
│```