Configuring OpenID Connect for AWS with Pulumi Deployments
This document outlines the steps required to configure Pulumi Deployments to use OpenID Connect to authenticate with AWS. OIDC in AWS uses a web identity provider to assume an IAM role. Access to the IAM role is authorized using a trust policy that validates the contents of the OIDC token issued by Pulumi Cloud.
Create the identity provider
- In the navigation pane of the IAM console, choose Identity providers, and then choose Add provider.
- In the Provider type section, click the radio button next to OpenID Connect.
- For the Provider URL, provide the following URL:
https://api.pulumi.com/oidc
- For the Audience field, enter the name of your Pulumi organization. Then click Add provider.
Configure the IAM role and trust policy
Once you have created the identity provider, you will see a notification at the top of your screen prompting you to assign an IAM role.
- Click the Assign role button.
- Select the Create a new role option, then click Next.
- On the IAM Create role page, ensure the Web identity radio button is selected.
- In the Web identity section:
- Select
api.pulumi.com/oidc
under Identity provider. - Select the name of your Pulumi organization under Audience. Then click Next.
- Select
- On the Add permissions page, select the permissions that you want to grant to your Pulumi deployments.
AdministratorAccess
will be required most of the time as most AWS workloads require creating IAM resources, which in turn require full admin access. Then click Next. - Provide a name and optional description for the IAM role. Then click Create role.
Make a note of the IAM role’s ARN; it will be necessary to enable OIDC for your deployment.
For more granular access control, edit the trust policy of your IAM role with Token claims. The sub
claim can be customized as shown below.
In the following example, the role may only be assumed by stacks within the Core
project of the contoso
organization:
"Condition": {
"StringEquals": {
"api.pulumi.com/oidc:aud": "contoso"
},
"StringLike": {
"api.pulumi.com/oidc:sub": "pulumi:deploy:org:contoso:project:Core:*"
}
}
Configure OIDC via the Pulumi console
- Navigate to your stack in the Pulumi Console.
- Open the stack’s “Settings” tab.
- Choose the “Deploy” panel.
- Under the “OpenID Connect” header, toggle “Enable AWS Integration”.
- Enter the ARN of the IAM role created above in the “Role ARN” field.
- Enter a name for the assumed role session in the “Session Name” field.
- If you would like to use additional policies to further constrain the session’s capabilities, enter the policies’ ARNs separated by commas in the “Policy ARNs” field.
- If you would like to constrain the duration of the assumed role session, enter a duration in the form “XhYmZs” in the “Session Duration” field.
- Click the “Save deployment configuration” button.
With this configuration, each deployment of this stack will attempt to exchange the deployment’s OIDC token for AWS credentials using the specified IAM role prior to running any pre-commands or Pulumi operations. The fetched credentials are published in the AWS_ACCESS_KEY_ID
, AWS_SECRET_ACCESS_KEY
, and AWS_SESSION_TOKEN
environment variables. The raw OIDC token is also available for advanced scenarios in the PULUMI_OIDC_TOKEN
environment variable and the /mnt/pulumi/pulumi.oidc
file.
Thank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.