

# IssueWorkloadIdentityContext

Issues a workload identity context for a workload that an AWS service runs for you. The service passes the context to [AssumeRole](API_AssumeRole.md) in `ProvidedContexts` to get temporary security credentials for the workload. The resulting role session has the workload identity. If the workload identity provider uses the SPIFFE naming scheme, your workload can then call [GetCertificate](API_GetCertificate.md), or [GetWebIdentityToken](API_GetWebIdentityToken.md) with a `TokenType` of `JWT_SVID`.

 AWS services that run workloads call this operation with their own service credentials. You don't call it yourself. The service describes the workload in an attestation document, and names a workload identity template in `WorkloadIdentityTemplateArn`. AWS STS builds the identity of the workload from the template and the attested values.

The service must also name the account and the resource that it acts for, which AWS STS makes available as the `aws:SourceAccount` and `aws:SourceArn` condition keys. For a template that an account owns, the source account must be that account. For one that an organization owns, the source account must be a member of that organization.

 AWS STS issues the context only if the template has an attestation policy, and that policy allows the calling service to issue it for the attested values. The attestation policy sees each attested value as a condition key whose name begins with `aws:WorkloadAttestation/aws/`. If the policy doesn't allow the request, or the template doesn't exist, the request fails with `AccessDenied`.

A context can be redeemed only by the service that requested it, with the same source account and source ARN, only for the role in `TargetRoleArn`, and only until `Expiration`. The role session that `AssumeRole` returns ends no later than `SessionExpiration`. The trust policy of the role must allow the `sts:AssumeRole` action for the calling service.

**Note**  
The `IssueWorkloadIdentityContext` API is not available on the AWS STS global endpoint or in every partition. Send requests to an AWS STS endpoint in an AWS Region where the API is available.

## Request Parameters
<a name="API_IssueWorkloadIdentityContext_RequestParameters"></a>

 For information about the parameters that are common to all actions, see [Common Parameters](CommonParameters.md).

 ** AttestationDocument **   
The facts that the calling service attests about the workload, as a JSON object. The keys and value types that the document can contain are set for each calling service. The document must be a single JSON object of up to 2,048 characters, with at least one key. Each value is a non-empty string of printable characters.  
 AWS STS records the attestation document in the AWS CloudTrail event for the request, so don't put secrets in it. If the document isn't valid, the request fails with `InvalidAttestationDocumentException`.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 2048.  
Required: Yes

 ** DurationSeconds **   
The time, in seconds, during which the calling service can pass the context to `AssumeRole`. The value can range from 60 seconds (1 minute) to 300 seconds (5 minutes). If you don't specify a value, the value is 60 seconds.  
Type: Integer  
Valid Range: Minimum value of 60. Maximum value of 300.  
Required: No

 ** SessionDurationSeconds **   
The longest time, in seconds, that a role session from this context can last, counted from when AWS STS issues the context. The value can range from 900 seconds (15 minutes) to 43,200 seconds (12 hours). The role session that `AssumeRole` returns ends at the earlier of this time and the session duration that the `AssumeRole` request sets.  
If you don't specify a value, the context doesn't limit the session duration.  
Type: Integer  
Valid Range: Minimum value of 900. Maximum value of 43200.  
Required: No

 ** TargetRoleArn **   
The Amazon Resource Name (ARN) of the role that the calling service assumes with the context. The role must be in the account that owns the template. For a template that an organization owns, the role must be in the source account. If the role doesn't exist or is in another account, the request fails with `AccessDenied`.  
If you don't specify a role, the response contains only the `Subject` and the `ProviderArn`, with no context assertion to pass to `AssumeRole`.  
Type: String  
Length Constraints: Minimum length of 20. Maximum length of 2048.  
Pattern: `[\u0009\u000A\u000D\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFD\u10000-\u10FFFF]+`   
Required: No

 ** WorkloadIdentityTemplateArn **   
The Amazon Resource Name (ARN) of the workload identity template that AWS STS uses to build the identity of the workload from the attested values. The ARN of a template that an organization owns contains the organization ID in place of the account ID.  
If you don't specify a template, the request fails with a validation error.  
Type: String  
Length Constraints: Minimum length of 20. Maximum length of 2048.  
Pattern: `arn:[^:]+:iam::(\d{12}|o-[a-z0-9]{10,32}):workload-identity-template/[\w+=,.@/-]+`   
Required: No

## Response Elements
<a name="API_IssueWorkloadIdentityContext_ResponseElements"></a>

The following elements are returned by the service.

 ** Audience **   
The AWS service principal that can pass the context to `AssumeRole`. This is the service principal of the caller. Present only if the request specified `TargetRoleArn`.  
Type: String  
Length Constraints: Minimum length of 1. Maximum length of 255.

 ** Expiration **   
The date and time, in UTC, after which `AssumeRole` no longer accepts the context. Present only if the request specified `TargetRoleArn`.  
Type: Timestamp

 ** ProvidedContext **   
The context to pass to [AssumeRole](API_AssumeRole.md) in `ProvidedContexts`. `ProviderArn` is the ARN of the workload identity provider that issued the context. `ContextAssertion` is the signed and encrypted context. It is present only if the request specified `TargetRoleArn`.  
Pass the context as the only entry in `ProvidedContexts`. Treat the context assertion like a credential until it expires.  
Type: [ProvidedContext](API_ProvidedContext.md) object

 ** SessionExpiration **   
The latest date and time, in UTC, at which a role session from this context can end. Present only if the request specified both `TargetRoleArn` and `SessionDurationSeconds`.  
Type: Timestamp

 ** Subject **   
The identifier of the workload, up to 256 characters. For a workload identity provider that uses the SPIFFE naming scheme, this is the SPIFFE ID of the workload, for example `spiffe://example.org/payments/checkout`. A role session from this context carries this value as the identity of the workload.  
Type: String

## Errors
<a name="API_IssueWorkloadIdentityContext_Errors"></a>

For information about the errors that are common to all actions, see [Common Error Types](CommonErrors.md).

 ** InvalidAttestationDocument **   
 AWS STS can't use the attestation document in the request. The `reason` member says why. Correct the attestation document and then retry the request.    
 ** reason **   
Why AWS STS can't use the attestation document. The value is one of the following:  
+  `providerNotFound` – AWS STS has no attestation rules for the calling service, so the calling service can't attest workloads.
+  `cannotParse` – The document is empty or isn't a single JSON object.
+  `tooLarge` – The document is longer than 2,048 characters. This reason is also returned when the context assertion built from the document is too large to pass to `AssumeRole`.
+  `invalidKey` – A key isn't in a valid format.
+  `unexpectedAttestation` – The document contains a key that the calling service can't attest.
+  `invalidValue` – The document has no keys, or a value is empty, isn't of the type that the key expects, or contains characters that aren't allowed.
+  `duplicateKey` – Two keys are the same when you ignore case. This reason is also returned when the document repeats a key that the workload identity template uses.
+  `unresolvedTemplateVariable` – The workload identity template uses an attested value that the document doesn't contain.
HTTP Status Code: 400

 ** InvalidWorkloadIdentityConfiguration **   
 AWS STS can't issue a workload identity context because the workload identity template or workload identity provider has a configuration that AWS STS can't use, or that doesn't work with the values in the request. The `reason` member says why. Ask the administrator of the resource to correct it, and then retry the request.    
 ** reason **   
Why AWS STS can't issue the context. The value is one of the following:  
+  `unrenderableTemplate` – AWS STS can't build a valid workload identifier. For example, the template uses a condition key that isn't available for the request or that has more than one value, a value isn't a valid path segment, or the domain of the workload identity provider isn't a valid trust domain.
+  `identifierTooLarge` – The workload identifier is longer than 256 characters.
+  `caseOnlyDuplicateTagKeys` – The template has tag keys that differ only in case.
+  `unsupportedTagKeyCharacters` – A tag key on the template contains a character that AWS STS doesn't support.
HTTP Status Code: 400

## Examples
<a name="API_IssueWorkloadIdentityContext_Examples"></a>

### Example
<a name="API_IssueWorkloadIdentityContext_Example_1"></a>

This example illustrates one usage of IssueWorkloadIdentityContext.

#### Sample Request
<a name="API_IssueWorkloadIdentityContext_Example_1_Request"></a>

```
               aws sts issue-workload-identity-context \
               --workload-identity-template-arn arn:aws:iam::444455556666:workload-identity-template/checkout \
               --attestation-document '{"ClusterName":"prod-cluster","Namespace":"payments","ServiceAccount":"checkout"}' \
               --target-role-arn arn:aws:iam::444455556666:role/checkout-role \
               --duration-seconds 60 \
               --session-duration-seconds 3600
```

#### Sample Response
<a name="API_IssueWorkloadIdentityContext_Example_1_Response"></a>

```
               {
                   "ProvidedContext": {
                       "ProviderArn": "arn:aws:iam::444455556666:workload-identity-provider/provider-id",
                       "ContextAssertion": "AQoDYXdzEXAMPLE..."
                   },
                   "Subject": "spiffe://example.org/payments/checkout",
                   "Audience": "eks.amazonaws.com",
                   "Expiration": "2026-11-27T18:01:00+00:00",
                   "SessionExpiration": "2026-11-27T19:00:00+00:00"
               }
```

## See Also
<a name="API_IssueWorkloadIdentityContext_SeeAlso"></a>

For more information about using this API in one of the language-specific AWS SDKs, see the following:
+  [AWS Command Line Interface V2](https://docs.aws.amazon.com/goto/cli2/sts-2011-06-15/IssueWorkloadIdentityContext) 
+  [AWS SDK for .NET V4](https://docs.aws.amazon.com/goto/DotNetSDKV4/sts-2011-06-15/IssueWorkloadIdentityContext) 
+  [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/sts-2011-06-15/IssueWorkloadIdentityContext) 
+  [AWS SDK for Go v2](https://docs.aws.amazon.com/goto/SdkForGoV2/sts-2011-06-15/IssueWorkloadIdentityContext) 
+  [AWS SDK for Java V2](https://docs.aws.amazon.com/goto/SdkForJavaV2/sts-2011-06-15/IssueWorkloadIdentityContext) 
+  [AWS SDK for JavaScript V3](https://docs.aws.amazon.com/goto/SdkForJavaScriptV3/sts-2011-06-15/IssueWorkloadIdentityContext) 
+  [AWS SDK for Kotlin](https://docs.aws.amazon.com/goto/SdkForKotlin/sts-2011-06-15/IssueWorkloadIdentityContext) 
+  [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/sts-2011-06-15/IssueWorkloadIdentityContext) 
+  [AWS SDK for Python (Boto3)](https://docs.aws.amazon.com/goto/boto3/sts-2011-06-15/IssueWorkloadIdentityContext) 
+  [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/sts-2011-06-15/IssueWorkloadIdentityContext) 