I was wondering if there’s been movement on this i...
# esc
b
I was wondering if there’s been movement on this item https://github.com/pulumi/pulumi/issues/14509. TLDR: Using OIDC from ESC within IaC you are currently unable to lock down roles to specific environments as the subject is “wrong”
Removed OIDC from my environments for now
r
We've made some progress here...
You can customize the OIDC token subject claim now https://www.pulumi.com/docs/pulumi-cloud/oidc/aws/#subject-customization
p
As Komal mentioned, we recommend using Subject Customization. We created that option as an alternate solution. a. Instead of the default subject if you use
pulumi.user.login
and/or
pulumi.organization.login
subject attributes, you can ensure the subject claims are consistent across Pulumi IaC operations (
pulumi up/refresh/destroy
) and esc commands (like
esc open
,
esc run
). Example subject claims based on your definition: i.
pulumi:environments:pulumi.organization.login:{ORGANIZATION_NAME}
ii.
pulumi:environments:pulumi.organization.login:{ORGANIZATION_NAME}:pulumi.user.login:{USER_LOGIN}
b. If you use the
currentEnvironment.name
and
rootEnvironment.name
subject attributes with Pulumi IaC Operations, you will still have the subject as
pulumi:environments:org:contoso:env:<yaml>
. However, for esc commands, you will have the subject as per your definition: (For example:
pulumi:environments:pulumi.organization.login:{ORGANIZATION_NAME}:currentEnvironment.name:<CURRENT_ENVIRONMENT_NAME>
)
Although to your point, locking roles to specific environment names when using ESC with IaC does get challenging.
b
I think there is still a tricky issue if I understand correctly. As these are both user controlled fields
r
I think there is still a tricky issue if I understand correctly. As these are both user controlled fields
They are not, these values are provided by the environment.
b
User controlled as in a member in the org can create a new environment setting the role and the name to use
And if I have an admin role locked to an env of say admin-env a user can create another environment and set those same strings and assume that role
Now I could make those strings near impossible to guess so I suppose I could leverage it that way
p
You can't set those strings in ESC. These are pre-defined keys that will be evaluated when opening the environment.
r
I think(?) Matt means the strings for the admin role arn
b
Oh I see it isn’t an override it is a list of keys to append
Ok I think I have the same issue with trying to lock it down though since it will be <yaml> regardless of the the env it is
p
Ok I think I have the same issue with trying to lock it down though since it will be <yaml> regardless of the the env it is
Yeah, if you are thinking of locking down using env name when using IaC, then it gets tricky.
b
Yep
Use case that I was attempting was multiple envs that are oidc connections to a few different accounts, create multiple providers (one for each) and then perform magic in a deployment. Not a big deal, I will use the oidc on the deployment for ones where it’s one to one
And if I really really want to I could use the oidc and do some assume role magic in a deployment
r
Definitely appreciate you raising this, it's an ongoing conversation on how best to solve this going forward.
a
Hi @brash-gigabyte-81569 I got late to the conversation. The problem with that is that by default it lacks of a root env (the one in IaC importing the first env) to define the subject. You can customize the subject using the
currentEnvironment.name
and
rootEnvironment.name
subject attributes which will resolve to a proper name when used from a stored environment: • current env is the name of the environment using the provider • root env is the name of the "rootest" environment (the one being imported from Iac) Using the example of the issue, you can create a new
prod_keys
environment
Copy code
values:
  azure:
    login:
      fn::open::azure-login:
        subjectAttributes:
          - currentEnvironment.name
        clientId: your-client-id
        tenantId: you-tenant-id
        subscriptionId: your-subscription-id # without the `/subscriptions/` prefix
        oidc: true
and from the IaC env
Copy code
imports:
- prod_keys
The subject in that case should be
pulumi:environments:pulumi.organization.login:{ORGANIZATION_NAME}:currentEnvironment.name:prod_keys
(you can then use RBAC to limit who can open that imported environment)