-
Notifications
You must be signed in to change notification settings - Fork 877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Pulumi to AWS OIDC Configuration Example #1507
Conversation
from pulumi_aws import iam | ||
import requests | ||
import subprocess | ||
import OpenSSL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the TLS provider to generate certs: https://www.pulumi.com/registry/packages/tls/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The steps that use OpenSSL are obtaining Pulumi's OIDC IdP certificate chain and using that to produce its thumbprint (it's not creating a new one). It wasn't clear to me how pulumi_tls would recreate this process, so happy to pair with you on this!
aws-py-oidc-provider/__main__.py
Outdated
import OpenSSL | ||
import json | ||
|
||
audience = "" # Provide the name of your Pulumi Organization |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use config.require()
: https://www.pulumi.com/docs/reference/pkg/python/pulumi/#pulumi.Config.require
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a built-in way to retrieve the org associated with the stack? Or do users have to explicitly configure that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a built-in way to retrieve the organization, project, and stack name. I've done this in Go many times, but in Python I think you need to use pulumi.get_organization
. I'll try to find a link.
base_url = 'api.pulumi.com/oidc' | ||
|
||
# Obtain the OIDC IdP URL and form the configuration document URL | ||
print("Forming configuration document URL...") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably don't want print
statements because they will print even if you run the program a second time and nothing changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a Pulumi-specific way of doing this to where it doesn't print if there's been no changes? I tried with pulumi.log.info()
and it still does it. I don't want to remove the statements because I think the indicators are helpful for users.
configuration_url = f'{oidc_idp_url}/.well-known/openid-configuration' | ||
|
||
# Locate "jwks_uri" and extract the domain name | ||
print("Extracting domain name from jwks_uri...") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be modeled as a resource using the Command provider: https://www.pulumi.com/registry/packages/command/api-docs/local/command/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand the ask here. Can we sync on this and the TLS comment?
Suggest using "Pulumi Cloud" in the docs and |
This example will create an automated way to deploy the OIDC configuration between Pulumi and AWS.
Will resolve #3481