

There are more AWS SDK examples available in the [AWS Doc SDK Examples](https://github.com/awsdocs/aws-doc-sdk-examples) GitHub repo.

# Code examples for AWS STS using AWS SDKs
<a name="sts_code_examples"></a>

The following code examples show you how to use AWS Security Token Service with an AWS software development kit (SDK).

*Actions* are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.

*Scenarios* are code examples that show you how to accomplish specific tasks by calling multiple functions within a service or combined with other AWS services.

**More resources**
+  **[AWS STS User Guide](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html)** – More information about AWS STS.
+ **[AWS STS API Reference](https://docs.aws.amazon.com/STS/latest/APIReference/welcome.html)** – Details about all available AWS STS actions.
+ **[AWS Developer Center](https://aws.amazon.com/developer/code-examples/?awsf.sdk-code-examples-product=product%23iam)** – Code examples that you can filter by category or full-text search.
+ **[AWS SDK Examples](https://github.com/awsdocs/aws-doc-sdk-examples)** – GitHub repo with complete code in preferred languages. Includes instructions for setting up and running the code.

**Contents**
+ [Basics](sts_code_examples_basics.md)
  + [Actions](sts_code_examples_actions.md)
    + [`AssumeRole`](sts_example_sts_AssumeRole_section.md)
    + [`AssumeRoleWithWebIdentity`](sts_example_sts_AssumeRoleWithWebIdentity_section.md)
    + [`DecodeAuthorizationMessage`](sts_example_sts_DecodeAuthorizationMessage_section.md)
    + [`GetFederationToken`](sts_example_sts_GetFederationToken_section.md)
    + [`GetSessionToken`](sts_example_sts_GetSessionToken_section.md)
+ [Scenarios](sts_code_examples_scenarios.md)
  + [Assume an IAM role that requires an MFA token](sts_example_sts_Scenario_AssumeRoleMfa_section.md)
  + [Configure Amazon ECS Service Connect](sts_example_ecs_ServiceConnect_085_section.md)
  + [Construct a URL for federated users](sts_example_sts_Scenario_ConstructFederatedUrl_section.md)
  + [Create a REST API with Lambda proxy integration](sts_example_api_gateway_GettingStarted_087_section.md)
  + [Create an Amazon ECS Linux task for the Fargate launch type](sts_example_ecs_GettingStarted_086_section.md)
  + [Creating a CloudWatch dashboard with function name as a variable](sts_example_cloudwatch_GettingStarted_031_section.md)
  + [Creating an Amazon ECS service for the EC2 launch type](sts_example_ecs_GettingStarted_018_section.md)
  + [Creating an Amazon Managed Grafana workspace](sts_example_iam_GettingStarted_044_section.md)
  + [Get a session token that requires an MFA token](sts_example_sts_Scenario_SessionTokenMfa_section.md)
  + [Getting started with Amazon ECR](sts_example_ecr_GettingStarted_078_section.md)
  + [Getting started with Amazon EKS](sts_example_eks_GettingStarted_034_section.md)
  + [Getting started with Amazon MSK](sts_example_ec2_GettingStarted_057_section.md)
  + [Getting started with Amazon OpenSearch Service](sts_example_opensearch_GettingStarted_016_section.md)
  + [Getting started with Amazon SageMaker Feature Store](sts_example_iam_GettingStarted_028_section.md)
  + [Getting started with Config](sts_example_config_service_GettingStarted_053_section.md)
  + [Getting started with End User Messaging Push](sts_example_pinpoint_GettingStarted_049_section.md)
  + [Getting started with IoT Core](sts_example_iot_GettingStarted_063_section.md)
  + [Getting started with WAF](sts_example_wafv2_GettingStarted_052_section.md)
  + [Moving hardcoded secrets to Secrets Manager](sts_example_secrets_manager_GettingStarted_073_section.md)
  + [Run CPU stress tests on EC2 instances using FIS](sts_example_iam_GettingStarted_069_section.md)
  + [Setting up Systems Manager](sts_example_iam_GettingStarted_046_section.md)