本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
AWSIAM 证书
AWS通过本地存储的访问密钥对您的AWS账户进行 IAM 证书身份验证。
以下部分介绍如何设置 IAM 证书以从中对您的AWS账户进行身份验证AWS Toolkit for Visual Studio Code。
重要
在设置 IAM 证书以对您的AWS账户进行身份验证之前,请注意:
如果您已经通过其他AWS服务(例如AWS CLI)设置了 IAM 证书,则AWS Toolkit for Visual Studio Code会自动检测这些证书并将其在 VS Code 中可用。
AWS建议使用 am ent y y y y y y y y 证 有关AWS IAM 最佳实践的更多信息,请参阅Identity and A ccess ManagemAWS en t 用户指南的 IAM 安全最佳实践部分。
为了避免安全风险,在开发专用软件或处理真实数据时,请勿使用 IAM 用户进行身份验证。改为使用联合身份提供商,例如 IAM Identity Center? 在AWS IAM Identity Center (successor to AWS Single Sign-On)用户指南中。
创建 IAM 用户
在设置使用您的AWS账户AWS Toolkit for Visual Studio Code进行身份验证之前,您需要在 AWSSDK 和工具参考指南的 “使用长期证书进行身份验证” 主题中完成步骤 1:创建 IAM 用户和步骤 2:获取访问密钥。
注意
步骤 3:更新 S AWSDK 和工具参考指南中的共享凭证文件是可选的。
如果您完成了步骤 3,则AWS Toolkit for Visual Studio Code会在下述从创建共享证证文件AWS Toolkit for Visual Studio Code期间自动检测您的证书。
如果您尚未完成步骤 3,则将AWS Toolkit for Visual Studio Code引导您完成创建过程,credentials file
如下从创建共享证证文件AWS Toolkit for Visual Studio Code所述。
从创建共享证证文件AWS Toolkit for Visual Studio Code
您的共享配置文件和共享凭证文件存储了您的AWS账户的配置和凭证信息。有关共享配置和凭据的更多信息,请参阅配置设置存储在哪里? AWS Command Line Interface用户指南中的部分。
通过创建共享证证文件AWS Toolkit for Visual Studio Code
在 VS Code 中,通过展开主菜单上的 “视图” 并选择 “命令面板” 来打开命令面板。
注意
您也可以使用以下组合键打开命令面板:
Windows:
Ctrl+Shift+P
macOS:
Shift+Command+P
在命令面板
AWS Create Credentials Profile
中输入搜索字段并选择它以继续。在 “创建新的AWS凭据配置文件” 对话框中,通过提供所需信息来完成提示。
注意
要完成此步骤并使用您的AWS账户进行身份验证,您需要有效的访问密钥 ID 和私有访问密钥。
完成 “创建新的AWS凭据配置文件” 对话框中的步骤后,您可以通过在系统文件中找到共享凭据文件来验证该文件的创建。
添加额外凭证文件
您可以向配置文件中添加多个证书。为此,请打开命令面板并选择 AWSToolkit 创建凭据配置文件。这将打开凭证文件。在此页面上,您可以添加新数据块,如以下示例中所示:
# Amazon Web Services Credentials File used by AWS CLI, SDKs, and tools # This file was created by the AWS Toolkit for Visual Studio Code extension. # # Your AWS credentials are represented by access keys associated with IAM users. # For information about how to create and manage AWS access keys for a user, see: # https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html # # This credential file can store multiple access keys by placing each one in a # named "profile". For information about how to change the access keys in a # profile or to add a new profile with a different access key, see: # https://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.html #
[Profile1_Name]
# The access key and secret key pair identify your account and grant access to AWS. aws_access_key_id =AKIAIOSFODNN7EXAMPLE
# Treat your secret key like a password. Never share your secret key with anyone. Do # not post it in online forums, or store it in a source control system. If your secret # key is ever disclosed, immediately use IAM to delete the access key and secret key # and create a new key pair. Then, update this file with the replacement key details. aws_secret_access_key =wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
[Profile2_Name]
aws_access_key_id =AKIAI44QH8DHBEXAMPLE
aws_secret_access_key =je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY