This message was deleted.
# google-cloud
s
This message was deleted.
b
can you share your code?
b
The code is very easy:
Copy code
import * as gcp from '@pulumi/gcp';
import * as pulumi from '@pulumi/pulumi';
import { ManagedDatabaseInfo } from '../schema';

export class AppDatabaseManaged extends pulumi.ComponentResource {
  public readonly uri: pulumi.Output<string>;

  constructor(args: ManagedDatabaseInfo, opts?: pulumi.ResourceOptions) {
    super('sys:app:Database-managed', args.name, args, opts);

    const user = new gcp.sql.User(
      `${args.name}-user`,
      {
        instance: 'app-dev',
        name: args.user.name,
        password: args.user.password,
        project: args.project,
      },
      {
        parent: this,
        customTimeouts: { create: '45s', update: '45s', delete: '45s' },
      },
    );

    const db = new gcp.sql.Database(
      `${args.name}-pgdatabase`,
      {
        instance: 'app-dev',
        name: args.name,
        project: args.project,
      },
      {
        parent: this,
        customTimeouts: { create: '45s', update: '45s', delete: '45s' },
      },
    );

    this.uri = pulumi.output(
    pulumi.interpolate`postgresql://${user.name}:${user.password}@${args.publicIpAddress}:5432/${db.name}`,
    );
  }
}
b
there’s no dependency between the database and user, add a
dependsOn
so that the user gets created after the database: https://www.pulumi.com/docs/intro/concepts/resources/options/dependson/
b
I tried using the depenbdsOn but nothing changed, consider by official doc, seems necessary to use the deletion policy abandon if there are other objects (users i.e.) belonging to the database because the GCP API cannot perform the delete. For me is unbelievable to have su a limitation
b
There’s not much we can do about the Google cloud API limitations
b
So are you confirming that I cannot delete databases and I have to leave it there for manual deletion?
b
I can’t confirm that, it’s a Google cloud limitation. If the dependon didn’t help
b
OK, I just want some official pulumi answer on how to properly create and delete those resources via pulumi.