pulumi / pulumi-onelogin

Apache License 2.0
1 stars 2 forks source link

Provider configuration values, clientId, clientSecret, etc do not work (due to an upstream TF provider issue) #206

Open MitchellGerdisch opened 8 months ago

MitchellGerdisch commented 8 months ago

What happened?

Although this issue is due to an upstream TF provider issue as per: https://github.com/onelogin/terraform-provider-onelogin/issues/112

I wanted to capture the issue along with a work-around until the upstream provider is fixed and folded into the Pulumi provider.

As per the docs page: https://www.pulumi.com/registry/packages/onelogin/installation-configuration/ Setting the clientId and clientSecret, etc as either config or environment variables enables the provider to talk to OneLogin. This is not the case - as per the above upstream issue.

There is a work-around (in Python, at least - I have not confirmed this works in other languages):

import pulumi
import pulumi_onelogin as onelogin
import requests

onelogin_config = pulumi.Config("onelogin")
onelogin_client_id = onelogin_config.require("clientId")
onelogin_client_secret = onelogin_config.require("clientSecret")
onelogin_auth_url = onelogin_config.require("url") # https://<your_domain>.onelogin.com/auth/oauth2/v2/token

onelogin_oauth = requests.post(onelogin_auth_url, 
                               auth=(onelogin_client_id, onelogin_client_secret),
                               json={
                                       "grant_type": "client_credentials"
                               }
)
response = onelogin_oauth.json()

onelogin_provider = onelogin.Provider("onelogin_provider",
                                      apikey_auth=response["access_token"])

role = onelogin.Role("testrole",
  name="testrole",
  opts=pulumi.ResourceOptions(provider=onelogin_provider)
)

Example

See above.

Output of pulumi about

CLI
Version 3.100.0 Go Version go1.21.5 Go Compiler gc

Plugins NAME VERSION onelogin 0.6.0 python unknown

Host
OS darwin Version 13.5 Arch x86_64

This project is written in python: executable='/Users/mitch/Downloads/pequod-user-management-work/pequod-demo-management/user-management/onelogin-access/venv/bin/python3' version='3.11.3'

Current Stack: pequod/onelogin-access/demo-mgmt

TYPE URN pulumi:pulumi:Stack urn:pulumi:demo-mgmt::onelogin-access::pulumi:pulumi:Stack::onelogin-access-demo-mgmt pulumi:providers:onelogin urn:pulumi:demo-mgmt::onelogin-access::pulumi:providers:onelogin::onelogin_provider onelogin:index/role:Role urn:pulumi:demo-mgmt::onelogin-access::onelogin:index/role:Role::testrole

Found no pending operations associated with pequod/demo-mgmt

Backend
Name pulumi.com

Dependencies: NAME VERSION pip 22.3.1 pulumi-onelogin 0.6.0 requests 2.31.0 setuptools 65.5.0

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).

iwahbe commented 8 months ago

@MitchellGerdisch Thanks for documenting this!