How does Pulumi's lifecycle differ from Terraform'...
# package-authoring
s
How does Pulumi's lifecycle differ from Terraform's? this line: https://github.com/joneshf/terraform-provider-openwrt/blob/552dbb4ca0eb4767f0b72e6139a8baa9c446fb01/openwrt/internal/lucirpcglue/resource.go#L100
Copy code
id := d.getId(model).ValueString()
This Terraform native provider seems to retrieve the
id
just after the resource was created, when using Terraform only (on
terraform apply
) whereas Pulumi (wrapping the same terraform provider) seems to want to read the state of the world before the resource gets created, and so it blows up with:
Copy code
error: openwrt:index/dhcpHost:DhcpHost resource 'testing' has a problem: Missing required property 'id': Name of the section. This name is only used when interacting with UCI directly.
I'm not sure who's wrong and who's right here. Is this a bug in the Pulumi Terraform Bridge, or a non-conventional design in the underlying terraform provider?
this terraform code works:
Copy code
terraform {
  required_providers {
    openwrt = {
      source  = "joneshf/openwrt"
    }
  }
}

provider "openwrt" {
  hostname = "192.168.1.1"
  username = "root"
  password = var.openwrt_password
}

data "openwrt_system_system" "this" {
  id = "cfg01e48a"
}

resource "openwrt_dhcp_host" "testing" {
  id = "blah"
  ip   = "192.168.1.202"
  mac  = "12:34:56:78:90:ab"
  name = "testing"
}
yet, the equivalent pulumi-wrapped version fails:
Copy code
import * as pulumi from "@pulumi/pulumi";
import * as openwrt from "@deposition-cloud/pulumi-openwrt"

const openWrtProvider = new openwrt.Provider('openwrt', {
  hostname: '192.168.1.1',
  username: 'root',
  scheme: 'http',
  password: process.env.ROUTER_PASSWORD
})

const system = openwrt.getSystemSystem({
  id: "cfg01e48a"
}, {
  provider: openWrtProvider
} )

const ip = new openwrt.DhcpHost('testing', {
  ip: '192.168.1.201',
  mac: '12:23:34:45:56:67',
  name: 'pulumi-openwrt-host'
}, {
  id: "blah2",
  provider: openWrtProvider
})

export const out = {
  system
}
fails with:
Copy code
Diagnostics:
  openwrt:index:DhcpHost (testing):
    error: problem getting dhcp. section: could not find section dhcp.
...because the resource to-be has yet tobe created on `pulumi up`(?)