AWS (IAM Roles)
The AWS integration allows content running on Posit Connect to assume an AWS Identity and Access Management (IAM) role and receive temporary AWS credentials. Viewer and Service Account integrations deliver credentials produced by the AWS Security Token Service (STS). Workload Identity integrations deliver a token file that the AWS SDK exchanges for credentials.
| Component part | Value |
|---|---|
| Provider registration | An IAM OpenID Connect (OIDC) identity provider and an IAM role. Viewer integrations and Workload Identity integrations with an external token source also require an external OAuth application. |
| Authentication types | Viewer, Service Account, Workload Identity |
| Configuration | All types: auth_type, role_arn. See the authentication type sections for source-specific fields. |
| Credential delivery | Viewer and Service Account: AWS STS credentials. Workload Identity: token file. |
| Content compatibility | Viewer: interactive only. Service Account and Workload Identity: interactive and rendered. |
All three authentication types are built on the same AWS API call, AssumeRoleWithWebIdentity. What differs is who issues the OIDC token, who calls STS, and whose identity the resulting role session represents. The Credential delivery page documents each mechanism step by step. This page covers the configuration each one requires.
Provider registration
Performed by an AWS administrator. Viewer integrations and Workload Identity integrations with an external token source also require an identity provider administrator.
Setting up an identity provider
Viewer integration
To enable Viewer authentication type AWS integrations, perform the following steps to setup an external identity provider:
- In your identity provider’s administrator console, create a new OIDC application (sometimes called a “client”)
- Configure the application (varies across identity providers):
- Select “Authorization Code” as the OAuth 2.0 grant type
- Configure the redirect URL (callback URL):
https://connect.example.org/__oauth__/integrations/callback(Replaceconnect.example.orgwith the address of the Connect server)- The administrator must configure a
redirect_urifor the OIDC application. This is what allows Connect to obtain temporary access tokens, ID tokens, and refresh tokens.
- The administrator must configure a
- Enable PKCE (Proof Key for Code Exchange) support
- Add the required OIDC scopes:
openid(mandatory for OIDC)offline_access(for refresh tokens)
- Set the client type as “Confidential” if you want to use a client secret
- Ensure the provider supports the standard OIDC claims in the ID token:
sub(subject identifier)iss(issuer)aud(audience)
- Note the following OIDC endpoints and credentials:
- Client ID
- Client Secret
- Authorization Endpoint URI
- Token Endpoint URI
- OIDC issuer URL
- Some common examples of OIDC issuer URLs include:
- Entra:
https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0 - Okta:
https://<org-id>.okta.com/oauth2/defaultorhttps://<org-id>.okta.com
- Entra:
- Some common examples of OIDC issuer URLs include:
Service account integration
For this integration authentication type, Connect acts as the identity provider by signing content session tokens with RSA keys managed by Connect itself. This process allows Connect to use workload identity federation to integrate with AWS.
AWS requires that identity providers are OIDC-compliant. To meet this requirement, Connect exposes the following public endpoints:
https://<connect-server-address>/.well-known/openid-configuration- Provides metadata necessary for OIDC discovery
https://<connect-server-address>/openid/v1/jwks- Provides list of public keys that can be used by external systems like AWS to validate content session tokens
Please note that this means that these routes needs to be made accessible to the AWS STS service in order to exchange credentials. Work with your network administrator to configure Connect properly for this use case.
Content session tokens are generated and injected into content when it starts up, so there are no extra steps to make this token available to publishers. For long-running content, Connect periodically refreshes the content session token and writes it to a file in the job directory. The Applications.ContentSessionTokenRefreshInterval configuration setting controls the refresh interval.
Note the following OIDC information managed by Connect:
- OIDC issuer URL
- The value of
IdentityProvider.Issuerif configured, otherwisehttps://<connect-server-address>/
- The value of
- Client ID or Audience
connect-content
Setting up AWS IAM
Your AWS administrator must configure an AWS IAM OIDC identity provider and an IAM role. Using the OIDC information for the selected token issuer, follow these steps to configure AWS.
- Add the IAM OIDC identity provider in AWS:
- In the AWS IAM console, go to Identity providers.
- Select Add provider, and then select OpenID Connect.
- Enter the OIDC issuer URL.
- Enter the audience value required by AWS for the OIDC provider. See AWS web identity federation condition keys for the claim mapping.
- Select Add provider.
- Create an IAM role for OIDC:
- In the IAM console, create a role.
- Choose Web identity as the trusted entity type.
- Select the OIDC identity provider that you created.
- Configure the audience value to match the provider audience.
- Add the required AWS permissions to the role.
- Note the role Amazon Resource Name (ARN) for later configuration.
- Configure the trust relationship:
- Edit the role’s trust relationship.
- Add conditions for the claims that identify the intended token and subject.
- See AWS web identity federation condition keys for supported claims and condition keys.
- Note the role ARN and AWS region. For Viewer and Service Account integrations, also note the STS region and configured maximum session duration.
For OAuth application administrators who prefer to use the same OAuth application for both Posit Connect and Posit Workbench, simply register the Workbench redirect URL (https://workbench.example.org/oauth_redirect_callback) in addition to the Connect redirect URL.
Granting access to AWS Secrets Manager
Content can use an AWS integration to read secrets from AWS Secrets Manager. Connect does not need any additional configuration. The role’s permissions policy determines which secrets content can read.
Attach a permissions policy like the following to the role, replacing the placeholders with your values:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "secretsmanager:GetSecretValue",
"Resource": "arn:aws:secretsmanager:<region>:<account-id>:secret:<secret-name-prefix>*"
}
]
}Scope the Resource to the specific secrets, or a shared name prefix such as connect/, that content needs. Avoid granting access to every secret in the account.
Secrets Manager appends six random characters to every secret name to form its ARN, such as connect/db-password-AbCdEf. A Resource that ends with the exact secret name does not match that ARN. AWS then denies the request with an AccessDeniedException error stating that no identity-based policy allows the secretsmanager:GetSecretValue action.
To grant access to a single secret, end the Resource with -??????, such as arn:aws:secretsmanager:<region>:<account-id>:secret:connect/db-password-??????. Each ? matches one of the six random characters. Because the pattern does not depend on those characters, you can grant access to a secret before you create it. Be aware that if you delete the secret and create a new one with the same name, the role can also read the new secret. To limit the role to one specific secret, use the full ARN of the secret, including its six characters, and update the policy if you recreate the secret.
To grant access to every secret whose name starts with a prefix, end the Resource with *, as in the policy above. This pattern also matches secrets that you create later with that prefix. See Example: Wildcards in the AWS documentation.
If a customer-managed AWS Key Management Service (KMS) key encrypts the secret, the role also needs permission to use that key. See Permissions for the KMS key in the AWS documentation.
Every piece of content associated with an integration can read every secret the role allows. To give different content access to different secrets, create a separate role and integration for each group of secrets. To control which publishers can associate each integration with their content, use access control lists.
Transfer information to Connect administrator
The administrator of the identity provider and AWS shares the following information with the Connect administrator:
| Field | Description |
|---|---|
client_id |
Unique identifier for the OIDC application. |
client_secret |
Secret identifier for the OIDC application. Not required for Public Viewer integrations. |
authorization_uri |
The URI for the authorization endpoint. Can also be obtained from the Authorization Server Metadata Endpoint. |
token_uri |
The URI for the token endpoint. Can also be obtained from the Authorization Server Metadata Endpoint. |
token_endpoint_auth_method |
Determines how parameters are passed to the OIDC application. |
scopes |
For Viewer integrations, the permissions requested by Connect. At minimum, include offline_access and openid to retrieve an ID and refresh token. |
external_scopes |
For an external Workload Identity token source, the optional scopes requested through the client credentials grant. |
issuer |
For an external Workload Identity token source, the literal iss claim to enter in the Connect Issuer field. |
audience |
For an external Workload Identity token source, the literal aud claim to enter in the Connect Token Audience field. |
token_endpoint_audience |
For external Workload Identity, an optional audience form parameter sent to the token endpoint. It does not set the token’s aud claim. |
role_arn |
The AWS IAM Role ARN that the integration will allow content to assume. |
region |
The AWS region where the role is assumed for Workload Identity integrations. |
sts_region |
The region used by the AWS Security Token Service to retrieve temporary credentials. |
session_duration |
The duration that the credentials will be valid. The maximum duration is set in the AWS IAM dashboard. |
For external Workload Identity token sources, Connect sends the optional external_scopes value through the client credentials grant.
Authentication types
This integration supports the Viewer, Service Account, and Workload Identity authentication types. See the documentation on supported authentication types for general definitions, and the table below for what is specific to AWS.
| Authentication type | Identity in AWS | OIDC token issued by | AssumeRoleWithWebIdentity called by |
Secret stored in Connect |
|---|---|---|---|---|
| Viewer | The content viewer | The external identity provider | Connect | Client secret (Confidential mode) |
| Service Account | The content item | Connect | Connect | None |
| Workload Identity | The token subject | Connect or an external provider | The AWS SDK in the content process | External token source only |
The role session name differs per authentication type, so AWS CloudTrail attribution does too. Viewer sessions carry the globally unique identifier (GUID) of the viewer, and Service Account sessions carry the GUID of the content item. For Workload Identity, the AWS SDK controls role session attribution.
Workload identity
The Workload Identity authentication type uses AWS Web Identity Federation. Connect writes a short-lived token to a file, and the AWS SDK assumes the configured IAM role. Connect can issue the token or request a web identity token from an external identity provider with the OAuth client credentials grant. The external provider mode stores a client secret in Connect.
When Connect issues the token, AWS must reach the Connect server to verify the token signature.
The AWS administrator configures the IAM OIDC identity provider and role trust policy as described in Setting up AWS IAM. The OIDC provider uses the Connect issuer URL, which is the value of IdentityProvider.Issuer if configured, otherwise the value of Server.Address with a trailing slash (e.g., https://connect.example.org/). Connect issues tokens with the sts.amazonaws.com audience and the connect subject, so the role trust policy must validate those claims:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::<account-id>:oidc-provider/connect.example.org"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"connect.example.org:aud": "sts.amazonaws.com",
"connect.example.org:sub": "connect"
}
}
}
]
}The Connect administrator supplies the IAM role ARN and the AWS region where the role is assumed.
External identity provider token source
Configure the external identity provider to issue a signed JSON Web Token (JWT) through the OAuth client credentials grant. The token response must include a positive expires_in value so Connect can refresh the token before it expires. Connect does not use the JWT exp claim to determine the refresh schedule. Connect writes the returned access_token value to the token file. AWS STS checks the JWT signature and claims against the OIDC provider configuration and role trust policy. Connect does not compare the external token’s iss or aud claims with the values in the Issuer and Token Audience fields.
The /verify endpoint retrieves a token from the external provider and exchanges it with AWS STS for temporary credentials. Connect discards the credentials and returns success only after both exchanges succeed.
Register the exact iss claim as the AWS IAM OIDC provider URL, and enter that value in the Connect Issuer field. Enter the literal JWT aud claim in the Connect Token Audience field.
When the token has an azp claim, AWS uses its value as the OIDC provider audience and for the issuer’s :aud condition key. The issuer’s :oaud condition key maps to the literal JWT aud claim. When the token has no azp claim, AWS uses JWT aud as the provider audience and for the issuer’s :aud condition key.
See AWS web identity federation condition keys for the claim mapping. Use a :sub condition to restrict the role to a stable subject when the provider supplies one.
Connect requests a new token with the configured client ID, secret, and optional scopes whenever the token file needs a refresh. If the provider requires an audience request parameter, set token_endpoint_audience in the integration configuration. This parameter does not set or validate the JWT aud claim. The AWS SDK reads the token from AWS_WEB_IDENTITY_TOKEN_FILE and calls STS.
Content can read and reuse the external bearer token from the token file. Use a token audience and claims that limit where the token can be used.
Microsoft Entra ID
Use the Microsoft identity platform OAuth 2.0 client credentials flow with the v2 token endpoint: https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token. Connect sends scope, not the legacy resource parameter.
Register a client application and a resource application in Entra. Use the client application’s ID and secret for client_id and client_secret. Set external_scopes to the resource application’s Application ID URI followed by /.default. Leave token_endpoint_audience blank because the /.default scope selects the resource.
Configure the resource application to issue the token format required by your integration. A v2 access token uses the resource application’s client ID as aud and the calling application’s client ID as azp. Enter the exact iss claim in the Connect Issuer field and the literal aud claim in the Connect Token Audience field.
When azp is present, register the calling application’s client ID as the AWS OIDC provider audience and use it in the issuer’s :aud trust condition. Use the resource application’s client ID in the issuer’s :oaud trust condition. Decode an issued token to confirm the claim values before configuring AWS.
The recommended v2 issuer is https://login.microsoftonline.com/<tenant-id>/v2.0; use the exact issuer from the token instead. For claim definitions, see Microsoft Entra access token claims. For AWS provider and trust policy claim mapping, see AWS web identity federation condition keys.
Connect configuration
Performed by a Connect administrator.
Create the integration in Connect
Using the information from the AWS administrator, the Posit Connect administrator creates an integration through the dashboard’s System > Integrations settings. Once the integration has been created in Connect, it is available for use by all publishers. See Access control lists for information on customizing access to specific users or groups.
Alternatively, create a Confidential AWS integration using posit connect api and the Connect Server API.
Before running these commands, sign in with posit connect login as described in Publishing from the command line. Use a Connect administrator account.
Terminal
posit connect api v1/oauth/integrations -X POST \
-H "Content-Type: application/json" --input - <<'JSON'
{
"template": "aws",
"name": "AWS integration",
"description": "A helpful description for publishers to use when choosing an integration for their content.",
"config": {
"auth_type": "Viewer",
"auth_mode": "Confidential",
"client_id": "<client-id>",
"client_secret": "<client-secret>",
"authorization_uri": "<authorization-endpoint>",
"token_uri": "<token-endpoint>",
"scopes": "offline_access openid profile email",
"role_arn": "<role-arn>",
"sts_region": "us-east-1",
"session_duration": "3600"
}
}
JSON
# {"guid": "<oauth-integration-guid>", ... }OAuth/OIDC integrations in Connect use the PKCE (Proof Key for Code Exchange) extension for the authorization code flow by default. PKCE is required in the upcoming OAuth 2.1 specification, and is recommended in all cases to protect against authorization code injection attacks. If necessary, PKCE can be disabled by creating an AWS Viewer integration with "use_pkce": false in the config map, but this is not recommended.
Create a workload identity integration
Select the Workload Identity authentication type in the AWS integration form. Keep Workload Identity Token Source set to Connect, or select External Provider and provide the OAuth client credentials and token claims. The example below shows the equivalent request using posit connect api and the Connect Server API.
Terminal
posit connect api v1/oauth/integrations -X POST \
-H "Content-Type: application/json" --input - <<'JSON'
{
"template": "aws",
"name": "AWS Workload Identity",
"description": "AWS workload identity integration for non-interactive content.",
"config": {
"auth_type": "Workload Identity",
"role_arn": "<role-arn>",
"region": "us-east-1"
}
}
JSON
# {"guid": "<oauth-integration-guid>", ... }For an external identity provider, use the following configuration:
config.json
{
"auth_type": "Workload Identity",
"workload_identity_token_source": "External Provider",
"token_uri": "https://login.example.com/oauth2/v2.0/token",
"client_id": "<client-id>",
"client_secret": "<client-secret>",
"token_endpoint_auth_method": "client_secret_post",
"external_scopes": "api://aws/.default",
"issuer": "https://login.example.com/<tenant-id>/v2.0",
"audience": "api://aws",
"role_arn": "<role-arn>",
"region": "us-east-1"
}Credential delivery
Credential delivery depends on the authentication type:
- Viewer and Service Account: Content requests credentials from the Connect credential exchange endpoint using the
urn:ietf:params:aws:token-type:credentialsrequested token type. Connect performs the STS role assumption and returns the credentials, base64-encoded and serialized. - Workload Identity: Connect writes a web identity token to a file and sets
AWS_ROLE_ARN,AWS_DEFAULT_REGION,AWS_STS_REGIONAL_ENDPOINTS, andAWS_WEB_IDENTITY_TOKEN_FILEin the content environment. It refreshes the token file for the life of the process. The AWS SDK does the rest with no code changes.
Viewer and Service Account credentials are valid for session_duration seconds, bounded by the maximum session duration of the IAM role. Each exchange performs a fresh STS call. Content must request new credentials as expiration approaches.
Viewer and Service Account tokens are not exposed to content. Workload Identity tokens are available to content through AWS_WEB_IDENTITY_TOKEN_FILE. See AWS STS credentials for the full mechanism, including what is recorded and what is not.
Publisher usage
Before an integration works in content, a publisher must associate it with that content. See Adding integrations to deployed content in the Connect User Guide for the steps. A publisher can also request the association from manifest.json. See Automatically associating integrations.
Once the integration is configured, publishers can use it in their content. See the following cookbook recipes and how-to guides for examples:
Viewer integrations:
Service account integrations:
Workload identity integrations:
Workload Identity integrations work with AWS SDKs out of the box and require no code changes to authenticate correctly.
AWS Secrets Manager:
