Skip to content
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

Closed
wants to merge 12 commits into from

Conversation

toriancrane
Copy link
Contributor

@toriancrane toriancrane commented Oct 10, 2023

This example will create an automated way to deploy the OIDC configuration between Pulumi and AWS.

Will resolve #3481

from pulumi_aws import iam
import requests
import subprocess
import OpenSSL
Copy link
Member

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/

Copy link
Contributor Author

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!

import OpenSSL
import json

audience = "" # Provide the name of your Pulumi Organization
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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?

Copy link
Contributor

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...")
Copy link
Member

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.

Copy link
Contributor Author

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...")
Copy link
Member

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/

Copy link
Contributor Author

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?

@jkodroff
Copy link
Member

Suggest using "Pulumi Cloud" in the docs and pulumi-cloud in the code/for the example name.

@toriancrane toriancrane deleted the torian/aws-py-oidc-provider branch October 11, 2023 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Content Enhancement - Add Pulumi-AWS OIDC Example for Pulumi ESC
3 participants