pulumi-digitalocean icon indicating copy to clipboard operation
pulumi-digitalocean copied to clipboard

Unable to create DatabaseFirewall for DatabaseReplica

Open UnP1u9 opened this issue 2 years ago • 2 comments

What happened?

When I create DatabaseFirewall for DatabaseReplica, I get a "404 page not found" error,

Steps to reproduce

  1. Create a MySQL cluster
  2. Create DatabaseReplica
  3. Create DatabaseFirewall and point cluster_id to mysql_read_replica.id.

Expected Behavior

Create a Firewall in the Database with the given rules.

Actual Behavior

Get 404 Error.

clusterId shown when previewing the pulumi run: "[UUID]/replicas/mysql-dev-read-replica"

Versions used

No response

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

UnP1u9 avatar Jul 20 '22 11:07 UnP1u9

Hi @UnP1u9 - thanks for opening the issue. Could you share a small repro code snippet? Could you also share any additional details from the error?

viveklak avatar Jul 21 '22 20:07 viveklak

Added a snippet code here, hope this helps

https://github.com/UnP1u9/pulumi-do-test

Pulumi Up command Details ===> [urn=urn:pulumi:infra::infra::digitalocean:index/databaseFirewall:DatabaseFirewall::db-fw-ro] [provider=urn:pulumi:infra::infra::pulumi:providers:digitalocean::default_4_12_0::[MASKED_UUID]] clusterId : "[MASKED_UUID]/replicas/mysql-read-replica" rules : []

ERROR ===>
digitalocean:index:DatabaseFirewall (db-fw-ro): error: 1 error occurred: * Error creating DatabaseFirewall: PUT https://api.digitalocean.com/v2/databases/[MASKED_UUID]/replicas/mysql-sales-read-replica/firewall: 404 (request "[MASKED_REQ_ID]") 404 page not found

UnP1u9 avatar Jul 23 '22 07:07 UnP1u9

You need to use the uuid property to make it work:

db_fw_ro = do.DatabaseFirewall("db-fw-ro",
                            cluster_id=mysql_read_replica.uuid, # <= uuid, not id

A full example that I used to validate:

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

const mysql_cluster = new digitalocean.DatabaseCluster("mysql", {
    name:"mysql",
    engine:"mysql",
    nodeCount: 1,
    region: "nyc3",
    size: "db-s-1vcpu-1gb",
    version: "8",
});

const mysql_read_replica = new digitalocean.DatabaseReplica("mysql-read-replica", {
  name:"mysql-read-replica",
  clusterId: mysql_cluster.id,
  size: "db-s-1vcpu-1gb",
  region: "nyc3",
});

const db_fw = new digitalocean.DatabaseFirewall("db-fw", {
  clusterId:mysql_cluster.id,
  rules:[{
      type: "ip_addr",
      value: "8.8.8.8",
  }],
});

const db_fw_ro = new digitalocean.DatabaseFirewall("db-fw-ro", {
  clusterId: mysql_read_replica.uuid,
  rules:[{
      type: "ip_addr",
      value:"8.8.8.8",
  }],
});

Our docs are showing the use of uuid correctly, so I'll go ahead and close the issue.

mikhailshilkov avatar Nov 30 '23 15:11 mikhailshilkov