STS / Client / issue_workload_identity_context

issue_workload_identity_context

STS.Client.issue_workload_identity_context(**kwargs)

Issues a workload identity context for a workload that an Amazon Web Services service runs for you. The service passes the context to AssumeRole 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, or GetWebIdentityToken with a TokenType of JWT_SVID.

Amazon Web Services 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. Amazon Web Services 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 Amazon Web Services 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.

Amazon Web Services 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 STS global endpoint or in every partition. Send requests to an STS endpoint in an Amazon Web Services Region where the API is available.

See also: AWS API Documentation

Request Syntax

response = client.issue_workload_identity_context(
    WorkloadIdentityTemplateArn='string',
    AttestationDocument='string',
    TargetRoleArn='string',
    DurationSeconds=123,
    SessionDurationSeconds=123
)
Parameters:
  • WorkloadIdentityTemplateArn (string) –

    The Amazon Resource Name (ARN) of the workload identity template that Amazon Web Services 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.

  • AttestationDocument (string) –

    [REQUIRED]

    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.

    Amazon Web Services STS records the attestation document in the CloudTrail event for the request, so don’t put secrets in it. If the document isn’t valid, the request fails with InvalidAttestationDocumentException.

  • TargetRoleArn (string) –

    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.

  • DurationSeconds (integer) – 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.

  • SessionDurationSeconds (integer) –

    The longest time, in seconds, that a role session from this context can last, counted from when Amazon Web Services 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.

Return type:

dict

Returns:

Response Syntax

{
    'ProvidedContext': {
        'ProviderArn': 'string',
        'ContextAssertion': 'string'
    },
    'Subject': 'string',
    'Audience': 'string',
    'Expiration': datetime(2015, 1, 1),
    'SessionExpiration': datetime(2015, 1, 1)
}

Response Structure

  • (dict) –

    Contains the response to a successful IssueWorkloadIdentityContext request.

    • ProvidedContext (dict) –

      The context to pass to AssumeRole 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.

      • ProviderArn (string) –

        The context provider ARN from which the trusted context assertion was generated.

      • ContextAssertion (string) –

        The signed and encrypted trusted context assertion generated by the context provider. The trusted context assertion is signed and encrypted by Amazon Web Services STS.

    • Subject (string) –

      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.

    • Audience (string) –

      The Amazon Web Services service principal that can pass the context to AssumeRole. This is the service principal of the caller. Present only if the request specified TargetRoleArn.

    • Expiration (datetime) –

      The date and time, in UTC, after which AssumeRole no longer accepts the context. Present only if the request specified TargetRoleArn.

    • SessionExpiration (datetime) –

      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.

Exceptions