I'm trying to pass my GitHub token from a secret e...
# general
c
I'm trying to pass my GitHub token from a secret exposed by another stack:
Copy code
github = pulumi.StackReference(f"github-{environment}")
github_token = secrets.github("token")
os.environ['GITHUB_TOKEN'] = github_token
Is there any way to force the output to resolve before a github resource is requested?
b
if you pass it as a provider option, it'll resolve in the correct order: https://www.pulumi.com/docs/reference/pkg/github/provider/#token_python
you can also set the
os.environ
inside an
.apply
but there's no guarantee the token will be set before the resources are created
i would strongly recommend using an explicit provider
c
How do I create an explicit github provider with Python?
provider = github.NewProvider(...)
or something else?
found it:
mygithubprovider = github.Provider(...)
thanks @billowy-army-68599
@billowy-army-68599 How do I use the explicit provider?
Copy code
webhook = github.RepositoryWebhook(f"bootstrap-webhook-{environment}",
        repository='pulumi-bootstrap',
        configuration=github.RepositoryWebhookConfigurationArgs(
            url=apigw.api_endpoint,
            content_type="json",
            insecure_ssl=False,
        ),
        active=True,
        events=["pull_request"],
        __opts__=pulumi.ResourceOptions(provider=mygithubprovider))
I'm getting an error when running my stack:
_internal_init() got an unexpected keyword argument '__opts__'
b
opts=pulumi.ResourceOptions(provider=mygithubprovider))
shouldwork