AWS Security Token Service

2026/12/01 - AWS Security Token Service - 3 new1 updated api methods

Changes  Adds support for agent and workload identity (preview). AWS services can attest workloads and obtain verified identities for them from AWS STS. These identities are carried into role sessions, can be used to request JWT-SVIDs and X.509-SVIDs, and can be referenced in IAM policy conditions.

GetCertificate (new) Link ¶

Returns an X.509 SPIFFE Verifiable Identity Document (X509-SVID) for the workload identity of the calling session. Your workload can use the certificate to prove its identity to peers, for example in mutual TLS (mTLS). The X.509 signer of the workload identity provider that issued the workload identity of the session signs the certificate in the Amazon Web Services Region that you send the request to.

You can call GetCertificate only with temporary credentials for a role session that has a workload identity, and the workload identity provider must use the SPIFFE naming scheme. You can't call it with long-term IAM user credentials or with federated user credentials from GetFederationToken. Amazon Web Services STS denies the request if the calling session doesn't have a workload identity. Amazon Web Services STS also denies the request if the workload identity template or provider of the session no longer exists.

Amazon Web Services STS takes the identity in the certificate from the calling session, not from the request. Amazon Web Services STS uses only the public key from the certificate signing request (CSR) that you provide. The certificate chain in the response can include the root certificate authority (CA) certificate, so don't use it as a source of trust anchors. To verify certificates that Amazon Web Services STS issues, get trust anchors only from GetTrustBundles.

To call GetCertificate, you must have permission for the sts:GetCertificate action. Because Amazon Web Services STS issues the certificate on your behalf, you must also have permission for the acm-pca:IssueCertificate and acm-pca:GetCertificate actions on the certificate authority (CA) that the signer of the workload identity provider uses.

Amazon Web Services STS returns some errors from Amazon Web Services Private CA to you. If Amazon Web Services Private CA denies the request, the request fails with an access denied error. Check your permissions on the CA. If the account that owns the CA has exceeded its Amazon Web Services Private CA quota for issuing certificates, the request fails with a throttling error. Check the quotas for Amazon Web Services Private CA in that account.

See also: AWS API Documentation

Request Syntax

client.get_certificate(
    CertificateSigningRequest='string',
    MaxDurationSeconds=123
)
type CertificateSigningRequest:

string

param CertificateSigningRequest:

[REQUIRED]

A PEM-encoded PKCS #10 certificate signing request (CSR) that contains the public key for the certificate. The CSR must be signed with the matching private key.

Amazon Web Services STS uses only the public key from the CSR. Amazon Web Services STS ignores the subject, subject alternative names (SANs), and requested extensions in the CSR. The signing algorithm of the certificate is set by the signer of the workload identity provider, not by the CSR.

The CSR can be up to 32,768 characters long. If the CSR is blank, can't be parsed, has a signature that doesn't verify, or uses a key type or key size that the signer doesn't support, the request fails with MalformedCertificateSigningRequestException.

type MaxDurationSeconds:

integer

param MaxDurationSeconds:

The time, in seconds, that the certificate is valid. The value can range from 3,600 seconds (1 hour) to 43,200 seconds (12 hours). If you don't specify a value, the certificate is valid for 43,200 seconds (12 hours).

The expiration of the calling session doesn't limit this value. The certificate can remain valid after the session that requested it expires. This differs from GetWebIdentityToken, which rejects a token duration that ends after the calling session expires.

rtype:

dict

returns:

Response Syntax

{
    'Certificate': 'string',
    'CertificateChain': 'string',
    'NotBefore': datetime(2015, 1, 1),
    'NotAfter': datetime(2015, 1, 1),
    'Subject': 'string'
}

Response Structure

  • (dict) --

    Contains the response to a successful GetCertificate request.

    • Certificate (string) --

      The issued X.509 certificate (X509-SVID), PEM-encoded. The certificate has an empty subject distinguished name (DN) and one URI subject alternative name (SAN) that contains the SPIFFE ID of the workload. You can use the certificate for both client and server authentication.

    • CertificateChain (string) --

      The PEM-encoded certificate chain that links the certificate to the root certificate authority (CA), in the same format that Amazon Web Services Private CA returns. The chain can include the root CA certificate. Don't use the chain as a source of trust anchors. To get the trust anchors for the provider, call GetTrustBundles.

    • NotBefore (datetime) --

      The date and time, in UTC, when the certificate becomes valid. To allow for differences between clocks, Amazon Web Services STS sets this to five minutes before it issues the certificate.

    • NotAfter (datetime) --

      The date and time, in UTC, when the certificate expires. This is MaxDurationSeconds after Amazon Web Services STS issued the certificate, or 12 hours if you didn't specify MaxDurationSeconds.

    • Subject (string) --

      The SPIFFE ID of the workload, for example spiffe://example.org/payments/checkout. This is the same value as the URI subject alternative name (SAN) of the certificate, and comes from the calling session.

GetTrustBundles (new) Link ¶

Returns the trust bundles for a workload identity provider. Relying parties use a trust bundle to verify the X509-SVIDs and JWT-SVIDs of the workloads of that provider. For more information, see GetCertificate and GetWebIdentityToken.

A trust bundle contains the public keys that the provider currently publishes. Amazon Web Services STS publishes the key of a new signer before the signer starts signing. After a signer stops signing, Amazon Web Services STS continues to publish its key for at least as long as any certificate or token that it signed is valid. Get the trust bundle again at the interval in its spiffe_refresh_hint value, and trust every key that it contains. If the provider has no signers, the trust bundle contains no keys.

You can get the trust bundles for a provider that your account owns. For a provider that an organization owns, you can get its trust bundles from any account in that organization. If you specify a provider that doesn't exist or that is outside that scope, the request fails with ResourceNotFoundException.

You can call GetTrustBundles with long-term or temporary credentials. You must have permission for the sts:GetTrustBundles action. The action doesn't support resource-level permissions.

See also: AWS API Documentation

Request Syntax

client.get_trust_bundles(
    ProviderArn='string'
)
type ProviderArn:

string

param ProviderArn:

[REQUIRED]

The Amazon Resource Name (ARN) of the workload identity provider. The ARN of a provider that an account owns contains the account ID, and the ARN of a provider that an organization owns contains the organization ID in place of the account ID. For example:

  • arn:aws:iam::444455556666:workload-identity-provider/provider-id

  • arn:aws:iam::o-a1b2c3d4e5:workload-identity-provider/provider-id

If the value isn't a valid workload identity provider ARN, the request fails with a validation error.

rtype:

dict

returns:

Response Syntax

{
    'TrustBundles': [
        {
            'TrustDomain': 'string',
            'Bundle': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    Contains the response to a successful GetTrustBundles request.

    • TrustBundles (list) --

      The trust bundles for the provider, one for each trust domain. Currently, this list contains one trust bundle, for the trust domain of the provider.

      • (dict) --

        A SPIFFE trust bundle and the trust domain that it belongs to.

        • TrustDomain (string) --

          The SPIFFE trust domain that the trust bundle is for, for example example.org. The SPIFFE IDs of workloads in this trust domain begin with spiffe:// followed by the trust domain.

        • Bundle (string) --

          The SPIFFE trust bundle for the trust domain, as a JSON document. The document is a JSON Web Key (JWK) Set, as defined in RFC 7517, with the following members:

          • spiffe_refresh_hint – How often, in seconds, to get the trust bundle again.

          • keys – The public keys for the trust domain. A key with a use value of x509-svid verifies X509-SVIDs, and its x5c member contains the root certificate authority (CA) certificate. A key with a use value of jwt-svid verifies JWT-SVIDs, and its kid member matches the kid header of the JWT-SVIDs that it signs.

          For more information, see SPIFFE Trust Domain and Bundle.

IssueWorkloadIdentityContext (new) Link ¶

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.

See also: AWS API Documentation

Request Syntax

client.issue_workload_identity_context(
    WorkloadIdentityTemplateArn='string',
    AttestationDocument='string',
    TargetRoleArn='string',
    DurationSeconds=123,
    SessionDurationSeconds=123
)
type WorkloadIdentityTemplateArn:

string

param WorkloadIdentityTemplateArn:

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.

type AttestationDocument:

string

param AttestationDocument:

[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.

type TargetRoleArn:

string

param 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 DurationSeconds:

integer

param 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 SessionDurationSeconds:

integer

param SessionDurationSeconds:

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.

rtype:

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.

GetWebIdentityToken (updated) Link ¶
Changes (request)
{'TokenType': 'AWSIdentity | JWT_SVID'}

Returns a signed JSON Web Token (JWT) that represents the calling Amazon Web Services identity or, if you set SubjectMode to OriginIdentity, the human user or workload on whose behalf the calling session acts. The returned JWT can be used to authenticate with external services that support OIDC discovery. The token is signed by Amazon Web Services STS and can be publicly verified using the verification keys published at the issuer's JWKS endpoint.

For a token of type AWSIdentity (the default), the sub (subject) claim contains the identity that SubjectMode selects. Whichever subject mode you use, the principal_id claim under the https://sts.amazonaws.com/ namespace contains the ARN of the principal that requested the token, when that principal has an ARN. For a role session, this is the ARN of the role.

If you set TokenType to JWT_SVID, Amazon Web Services STS instead returns a JWT SPIFFE Verifiable Identity Document (JWT-SVID) for the workload identity of the calling session. You can request a JWT-SVID only with temporary credentials for a role session that has a workload identity, and the workload identity provider must use the SPIFFE naming scheme. Amazon Web Services STS sets the sub claim to the SPIFFE ID of the workload and the iss claim from the workload identity provider, and signs the token with the JWT signer of the provider.

A JWT-SVID contains only the sub, aud, iss, iat, exp, and jti claims. You must specify exactly one audience for a JWT-SVID, and you can't specify Tags.

The iss claim of a JWT-SVID identifies a public issuer endpoint that publishes OpenID Connect (OIDC) discovery metadata and a JSON Web Key Set (JWKS) for the provider. Services that verify the token (relying parties) can verify a JWT-SVID through standard OIDC discovery from the iss value, in the same way as a token of type AWSIdentity. They can also verify it with the trust bundle that GetTrustBundles returns.

TokenType is mutually exclusive with SubjectMode and Scope. If you specify TokenType, with either value, you can't also specify SubjectMode or Scope.

See also: AWS API Documentation

Request Syntax

client.get_web_identity_token(
    Audience=[
        'string',
    ],
    DurationSeconds=123,
    SigningAlgorithm='string',
    Scope='string',
    SubjectMode='AWSIdentity'|'OriginIdentity',
    Tags=[
        {
            'Key': 'string',
            'Value': 'string'
        },
    ],
    TokenType='AWSIdentity'|'JWT_SVID'
)
type Audience:

list

param Audience:

[REQUIRED]

The intended recipient of the web identity token. This value populates the aud claim in the JWT and should identify the service or application that will validate and use the token. The external service should verify this claim to ensure the token was intended for their use.

If you set TokenType to JWT_SVID, you must specify exactly one audience.

  • (string) --

type DurationSeconds:

integer

param DurationSeconds:

The duration, in seconds, for which the JSON Web Token (JWT) will remain valid. The value can range from 60 seconds (1 minute) to 3600 seconds (1 hour). If not specified, the default duration is 300 seconds (5 minutes). The token is designed to be short-lived and should be used for proof of identity, then exchanged for credentials or short-lived tokens in the external service.

The token can't remain valid after the calling session expires. If the requested duration ends after the calling session expires, Amazon Web Services STS rejects the request with SessionDurationEscalationException. This applies to both token types. A certificate from GetCertificate, in contrast, can remain valid after the session that requested it expires.

type SigningAlgorithm:

string

param SigningAlgorithm:

[REQUIRED]

The cryptographic algorithm to use for signing the JSON Web Token (JWT). Valid values are RS256 (RSA with SHA-256) and ES384 (ECDSA using P-384 curve with SHA-384). You can use either algorithm with both token types, AWSIdentity and JWT_SVID.

type Scope:

string

param Scope:

One or more OAuth 2.0 scope values to include in the JSON Web Token (JWT). Amazon Web Services STS copies the value exactly as you send it into the top-level scope claim of the token. If you don't specify Scope, the token doesn't include a scope claim.

Separate multiple values with a single space, as defined in RFC 6749, section 3.3 on the IETF website. Don't begin or end Scope with a space. Each scope value can contain printable ASCII characters except spaces, double quotation marks ( "), commas ( ,), and backslashes ( \).

You can't repeat a scope value. Scope values are case sensitive. This means that read and READ are separate values.

Scope and TokenType are mutually exclusive. If you specify both, Amazon Web Services STS rejects the request with a validation error, whichever value of TokenType you specify.

You can specify Scope only when SubjectMode is OriginIdentity and you request exactly one audience. To specify Scope, the calling principal must have permission for the sts:SetWebIdentityTokenScope action in addition to sts:GetWebIdentityToken. You can use the multivalued sts:IdentityTokenScope condition key in a policy to control which scope values a principal can request.

type SubjectMode:

string

param SubjectMode:

Specifies which identity STS puts in the sub (subject) claim of the JSON Web Token (JWT). Valid values are AWSIdentity and OriginIdentity. If you don't specify a value, Amazon Web Services STS uses AWSIdentity.

SubjectMode and TokenType are mutually exclusive. If you specify both, Amazon Web Services STS rejects the request with a validation error, whichever value of TokenType you specify.

  • AWSIdentity – The sub claim contains the ARN of the calling Amazon Web Services principal.

  • OriginIdentity – The sub claim contains the value of the aws:OriginIdentity/Subject key in the trusted identity propagation context of the calling session. For example, this can identify the human user or workload on whose behalf the calling session acts. Amazon Web Services STS also adds a subject_mode claim to the token. To use OriginIdentity, the trusted identity propagation context of the calling session must contain the aws:OriginIdentity/Subject key and either the aws:OriginIdentity/Issuer key or the aws:OriginIdentity/FederatedProviderArn key. If it doesn't, or if the subject is blank, Amazon Web Services STS rejects the request with a validation error. Amazon Web Services STS denies the request if the subject begins with the text arn:, in any combination of uppercase and lowercase letters. Amazon Web Services STS also denies the request if the subject begins or ends with a space, or contains a control, format, or separator character other than a space.

You can use the sts:SubjectMode condition key in a policy to control which subject modes a principal can request.

type Tags:

list

param Tags:

An optional list of tags to include in the JSON Web Token (JWT). These tags are added as custom claims to the JWT and can be used by the downstream service for authorization decisions.

You can't specify Tags if you set TokenType to JWT_SVID.

  • (dict) --

    You can pass custom key-value pair attributes when you assume a role or federate a user. These are called session tags. You can then use the session tags to control access to resources. For more information, see Tagging Amazon Web Services STS Sessions in the IAM User Guide.

    • Key (string) -- [REQUIRED]

      The key for a session tag.

      You can pass up to 50 session tags. The plain text session tag keys can’t exceed 128 characters. For these and additional limits, see IAM and STS Character Limits in the IAM User Guide.

    • Value (string) -- [REQUIRED]

      The value for a session tag.

      You can pass up to 50 session tags. The plain text session tag values can’t exceed 256 characters. For these and additional limits, see IAM and STS Character Limits in the IAM User Guide.

type TokenType:

string

param TokenType:

The type of token to return. Valid values are AWSIdentity and JWT_SVID. If you don't specify a value, Amazon Web Services STS uses AWSIdentity. Each value returns the following type of token:

AWSIdentity

A JSON Web Token (JWT) that represents the calling Amazon Web Services identity. You can verify it with the keys at the issuer's JSON Web Key Set (JWKS) endpoint.

JWT_SVID

A JWT SPIFFE Verifiable Identity Document (JWT-SVID) for the workload identity of the calling session. You can request a JWT-SVID only with temporary credentials for a role session that has a workload identity, and the workload identity provider must use the SPIFFE naming scheme. Amazon Web Services STS sets the sub claim to the SPIFFE ID of the workload and the iss claim from the workload identity provider. You can't set either value in the request. You can verify a JWT-SVID through OIDC discovery from its iss claim, or with the trust bundle that GetTrustBundles returns.

With JWT_SVID, you must specify exactly one audience, and you can't specify Tags.

TokenType is mutually exclusive with SubjectMode and Scope. If you specify TokenType, with either value, and also specify SubjectMode or Scope, Amazon Web Services STS rejects the request with a validation error.

You can use the sts:TokenType condition key in a policy to control which token types a principal can request.

rtype:

dict

returns:

Response Syntax

{
    'WebIdentityToken': 'string',
    'Expiration': datetime(2015, 1, 1)
}

Response Structure

  • (dict) --

    • WebIdentityToken (string) --

      A signed JSON Web Token (JWT) that represents the caller's Amazon Web Services identity or, if you set SubjectMode to OriginIdentity, the human user or workload on whose behalf the calling session acts. The token contains standard JWT claims such as subject, audience, expiration time, and additional identity attributes added by STS as custom claims. These can include the principal_id claim, which contains the ARN of the principal that requested the token, whichever subject mode you use. You can also add your own custom claims to the token by passing tags as request parameters to the GetWebIdentityToken API. The token is signed using the specified signing algorithm and can be verified using the verification keys available at the issuer's JWKS endpoint.

      If you set TokenType to JWT_SVID, the token is a SPIFFE JWT-SVID instead. A JWT-SVID contains only the sub (the SPIFFE ID of the workload), aud, iss, iat, exp, and jti claims. You can verify it through OIDC discovery from its iss claim, or with the trust bundle that GetTrustBundles returns.

    • Expiration (datetime) --

      The date and time when the web identity token expires, in UTC. The expiration is determined by adding the DurationSeconds value to the time the token was issued. After this time, the token should no longer be considered valid.