Skip to content

set_security_token_service_preferences async

set_security_token_service_preferences(
    global_endpoint_token_version: globalEndpointTokenVersion,
    *,
    config_overrides: Optional[AsyncIAMClientConfig] = None,
) -> None

Sets the specified version of the global endpoint token as the token version used for the Amazon Web Services account.

By default, Security Token Service (STS) is available as a global service, and all STS requests go to a single endpoint at https://sts.amazonaws.com. Amazon Web Services recommends using Regional STS endpoints to reduce latency, build in redundancy, and increase session token availability. For information about Regional endpoints for STS, see Security Token Service endpoints and quotas in the Amazon Web Services General Reference.

If you make an STS call to the global endpoint, the resulting session tokens might be valid in some Regions but not others. It depends on the version that is set in this operation. Version 1 tokens are valid only in Amazon Web Services Regions that are available by default. These tokens do not work in manually enabled Regions, such as Asia Pacific (Hong Kong). Version 2 tokens are valid in all Regions. However, version 2 tokens are longer and might affect systems where you temporarily store tokens. For information, see Activating and deactivating STS in an Amazon Web Services Region in the IAM User Guide.

To view the current session token version, see the GlobalEndpointTokenVersion entry in the response of the GetAccountSummary operation.

Parameters:

  • global_endpoint_token_version (globalEndpointTokenVersion) –

    The version of the global endpoint token. Version 1 tokens are valid only in Amazon Web Services Regions that are available by default. These tokens do not work in manually enabled Regions, such as Asia Pacific (Hong Kong). Version 2 tokens are valid in all Regions. However, version 2 tokens are longer and might affect systems where you temporarily store tokens.

    For information, see Activating and deactivating STS in an Amazon Web Services Region in the IAM User Guide.

Raises:

Examples:

To delete an access key for an IAM user The following command sets the STS global endpoint token to version 2. Version 2 tokens are valid in all Regions.

>>> await client.set_security_token_service_preferences(global_endpoint_token_version='v2Token')
Source code in docs_src/capo_iam/_services/async_iam.py
async def set_security_token_service_preferences(
    self,
    global_endpoint_token_version: "capo_iam.types.global_endpoint_token_version.globalEndpointTokenVersion",
    *,
    config_overrides: Optional[AsyncIAMClientConfig] = None,
) -> None:
    """<p>Sets the specified version of the global endpoint token as the token version used for the Amazon Web Services account.</p> <p>By default, Security Token Service (STS) is available as a global service, and all STS requests go to a single endpoint at <code>https://sts.amazonaws.com</code>. Amazon Web Services recommends using Regional STS endpoints to reduce latency, build in redundancy, and increase session token availability. For information about Regional endpoints for STS, see <a href="https://docs.aws.amazon.com/general/latest/gr/sts.html">Security Token Service endpoints and quotas</a> in the <i>Amazon Web Services General Reference</i>.</p> <p>If you make an STS call to the global endpoint, the resulting session tokens might be valid in some Regions but not others. It depends on the version that is set in this operation. Version 1 tokens are valid only in Amazon Web Services Regions that are available by default. These tokens do not work in manually enabled Regions, such as Asia Pacific (Hong Kong). Version 2 tokens are valid in all Regions. However, version 2 tokens are longer and might affect systems where you temporarily store tokens. For information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html">Activating and deactivating STS in an Amazon Web Services Region</a> in the <i>IAM User Guide</i>.</p> <p>To view the current session token version, see the <code>GlobalEndpointTokenVersion</code> entry in the response of the <a href="https://docs.aws.amazon.com/IAM/latest/APIReference/API_GetAccountSummary.html">GetAccountSummary</a> operation.</p>

    Args:
        global_endpoint_token_version: <p>The version of the global endpoint token. Version 1 tokens are valid only in Amazon Web Services Regions that are available by default. These tokens do not work in manually enabled Regions, such as Asia Pacific (Hong Kong). Version 2 tokens are valid in all Regions. However, version 2 tokens are longer and might affect systems where you temporarily store tokens.</p> <p>For information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html">Activating and deactivating STS in an Amazon Web Services Region</a> in the <i>IAM User Guide</i>.</p>

    Raises:
        capo_iam.errors.service_failure_exception.ServiceFailureException: <p>The request processing has failed because of an unknown error, exception or failure.</p>
        capo_iam.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To delete an access key for an IAM user
        The following command sets the STS global endpoint token to version 2. Version 2 tokens are valid in all Regions.

        >>> await client.set_security_token_service_preferences(global_endpoint_token_version='v2Token')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_iam.types.set_security_token_service_preferences_request.SetSecurityTokenServicePreferencesRequest]",
    ) -> AsyncOperationResponse[None]:
        import capo_iam._operations.aws_identity_management_v20100508.set_security_token_service_preferences

        (
            output,
            http_response,
        ) = await capo_iam._operations.aws_identity_management_v20100508.set_security_token_service_preferences.async_set_security_token_service_preferences(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("SetSecurityTokenServicePreferences")
    )
    input_: capo_iam.types.set_security_token_service_preferences_request.SetSecurityTokenServicePreferencesRequest = {
        "global_endpoint_token_version": global_endpoint_token_version
    }

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output