Skip to content

Commit

Permalink
Update __main__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
toriancrane authored Oct 18, 2023
1 parent 6ce8c10 commit cac6a77
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions azure-py-oidc-provider-pulumi-cloud/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import pulumi_azuread as azuread
from pulumi_azure import core
import yaml
import random

number = random.randint(1000,9999)

issuer = "https://api.pulumi.com/oidc"

Expand All @@ -17,19 +20,19 @@
tenant_id = azure_config.tenant_id

# Create an Azure Resource Group (if necessary)
resource_group = resources.ResourceGroup('resourceGroup')
resource_group = resources.ResourceGroup(f'resourceGroup-{number}')

# Create an Azure AD Application
application = azuread.Application(
'oidc-app-registration',
f'pulumi-oidc-app-reg-{number}',
display_name='pulumi-environments-oidc-app',
sign_in_audience='AzureADMyOrg',
)

# Creates Federated Credentials
federated_identity_credential = azuread.ApplicationFederatedIdentityCredential("federatedIdentityCredential",
application_object_id=application.object_id,
display_name="pulumi-environments-oidc-fic",
display_name=f"pulumi-env-oidc-fic-{number}",
description="Federated credentials for Pulumi ESC",
audiences=[audience],
issuer=issuer,
Expand Down Expand Up @@ -62,4 +65,4 @@ def print_yaml(args):
yaml_string = yaml.dump(yaml_structure, sort_keys=False)
print(yaml_string)

pulumi.Output.all(application.application_id, tenant_id, az_subscription).apply(print_yaml)
pulumi.Output.all(application.application_id, tenant_id, az_subscription).apply(print_yaml)

0 comments on commit cac6a77

Please sign in to comment.