pulumiverse / pulumi-grafana

Pulumi provider for Grafana

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`org_id` kwarg is ignored when creating `RuleGroup` resources

codyhydrolix opened this issue · comments

When specifying an org_id as an attribute for a RuleGroup resource, it is ignored and the rule group is always created in the org with id 1. Example (leaving the rule definitions empty for brevity):

import lbrlabs_pulumi_grafana as grafana
from pulumi import ResourceOptions

provider = grafana.Provider(
    "provider",
    auth="user:pwd",
    url="https://my.grafana.net",
)
opts = ResourceOptions(provider=provider)

org_id = "3"

folder = grafana.Folder(
    "example",
    grafana.FolderArgs(title="example", org_id=org_id),
    opts=opts,
)

grafana.RuleGroup(
    "example",
    grafana.RuleGroupArgs(
        folder_uid=folder.uid,
        interval_seconds=60,
        rules=[],
        name="example rules",
        org_id=org_id,
    ),
    opts=opts,
)

When I run this, the folder will get created in the correct org (id=3), but no rule groups show up even though pulumi thinks it has created them. If I look at the outputs for the RuleGroup resource, I see the "orgId": "1", and when I re-run the pulumi up command, the diff shows:

+-grafana:index/ruleGroup:RuleGroup: (replace)
        [id=ea7ab555-d6f9-4fcb-8482-d9842b47f9a1;example]
        [urn=urn:pulumi:cody-test::monitoring::monitoring:grafana:GrafanaHDX$grafana:index/ruleGroup:RuleGroup::example]
        [provider=urn:pulumi:cody-test::monitoring::monitoring:grafana:GrafanaHDX$pulumi:providers:grafana::cody-grafana-provider::a062207a-261a-4b8c-8ffb-3c0922b4c0d0]
      ~ orgId    : "1" => "3"

I have to hardcode the folder_uid to an id of a folder I created manually in orgId 1, but then I can see that alerts do actually get created there.

If I change the provider to use the org_id attribute as such:

provider = grafana.Provider(
    "provider",
    auth="user:pwd",
    url="https://my.grafana.net",
    org_id=3,
)

And then don't pass org_id in the RuleGroup args, things work as expected and the alerts get created in the correct org. However I get these deprecation warnings:

    warning: org_id is deprecated: Use the `org_id` attributes on resources instead.
    warning: org_id is deprecated: Use the `org_id` attributes on resources instead.
    warning: provider config warning: Use the `org_id` attributes on resources instead.
    warning: provider config warning: Use the `org_id` attributes on resources instead.

Expected Behavior:
I should be able to set org_id as a kwarg when creating a RuleGroup (like the deprecation warning suggests) and have the rules get created in the correct org

@codyhydrolix Can you retry with version v0.4.0 (or later) and report if it solves your problem?