Welcome to the AWS Docs SDK Examples. Here, you'll find examples of how to use the various SDKs that AWS provides for interacting with its services.
These examples appear in the AWS documentation. For more information on getting started with the SDKs for AWS, see Tools to Build on AWS.
To use the examples in this documentation, you must have an AWS account. For more information about creating an account, see AWS Free Tier.
AWS SDKs must be configured with the AWS Access Key ID, AWS Secret Key. In some cases, you need a Session ID.
We recommend using the AWS Command Line Interface (AWS CLI) to complete the configuration. Most AWS SDKs use the configuration created by the AWS CLI. To configure the AWS CLI, use the following command:
aws configure
The preceding command will create or update the file $HOME/.aws/credentials
, which is used by the SDKs where applicable.
For more information, see Configuration and credential file settings in the AWS Command Line Interface User Guide.
Generally, the AWS SDKs look for configuration information in the following places, in this order:
$HOME/.aws/credentials
, in the default profile$HOME/.aws/credentials
, in the profile defined by the AWS_PROFILE
environment variableAWS_ACCESS_KEY_ID
, AWS_SECRET_ACCESS_KEY
, and (if defined,) AWS_SESSION_TOKEN
environment variables.aws.accessKeyId
and aws.secretKey
AWSBasicCredentials
in the Java V2 SDKIf you are unsure, see the documentation for the specific SDK that you're using.
Running these code examples might result in charges to your AWS account. Many examples involve services that are charged on a per-use basis, such as Amazon Simple Email Service (Amazon SES). Other examples might create resources that have long-term costs with services such as Amazon Simple Storage Service Glacier (Amazon S3 Glacier). For more information, see AWS Pricing.
Some examples modify or delete resources, such as AWS Identity and Access Management (IAM) users and Amazon S3 bucket contents or previous versions. It is your responsibility to do the following:
- Be aware of the resources that these examples create or delete
- Be aware of the costs that might be charged to your account as a result
- Back up your important data
Each SDK, and its respective examples, has one of the following support statuses:
Do not use preview examples in any type of production environment. SDKs that are in preview might not be stable or consistent, and their respective SDK examples might not be up-to-date or fully tested.
Examples for SDKs that are no longer maintained are not likely to be current and might not follow current best practices. These examples are retained for reference purposes.
This repo contains top-level folders of code examples for each SDK language.
For example, the cpp
folder is for the AWS SDK for C++, and the python
folder is for the AWS SDK for Python (Boto3).
Preview SDK paths are subject to change.
The README file in each SDK language folder explains how to build and run the examples in that folder.
Within each SDK language folder, the example_code folder contains examples organized by AWS service. Each AWS service folder is named for its corresponding AWS CLI command. or example, the s3 folder contains Amazon S3 examples. For a list of AWS service commands, see Available services in the AWS CLI Command Reference.
The code examples are organized by AWS SDK or AWS programming tool. The following list shows some of the top-level folders:
Code examples for previous AWS SDK versions are archived in this repository but are no longer maintained. These include the following:
As AWS SDK major version numbers increment, this repository will more consistently reflect the version numbers in these folders. For example, imagine that the AWS SDK for Ruby moves to a version 4. A new rubyv4 folder is added. In this scenario, if AWS officially announces that version 3 of the AWS SDK for Ruby is no longer supported, then the previous ruby folder is deleted.
Other top-level folders include the following:
If you plan to contribute examples for use in the documentation, see the Guidelines for contributing.
Note that the AWS documentation team prefers to produce code examples that cover broader scenarios and use cases, versus simple code snippets that cover only individual API calls.
scripts/
folderThe scripts folder contains scripts that the AWS documentation team uses internally to build the code examples into various AWS documentation sets.
We have changed the default branch for this repo from master to main.
If the parent branch of your fork or branch is master, the following instructions tell you how to change the parent branch to main.
To show the parent branch, where BRANCH is the name of your branch:
To change the parent branch for your branch to main, navigate to the root of your branch and enter the following commands, where BRANCH is the name of your branch:
git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a
git remote update --prune
GitHub will notify you when a parent branch has changed. To change your fork's default branch to main:
If you have any questions, or if you experience an issue when retargeting your branch or fork, create a new GitHub issue and include as much detail as possible.
All content in this repository, unless otherwise stated, is Copyright © Amazon Web Services, Inc. or its affiliates. All rights reserved.
Except where otherwise noted, all examples in this collection are licensed under the Apache
license, version 2.0 (the "License"). The full
license text is provided in the LICENSE
file accompanying this repository.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。