AWS IAM证书 - AWS 适用于 VS Code 的工具包

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

AWS IAM证书

AWS IAM通过本地存储的访问密钥对您的 AWS 账户进行凭证身份验证。

有关如何进行身份验证以及如何将 AWS 工具包与现有 AWS IAM凭据连接的详细信息,请参阅本用户指南中的 Connect to AWS主题。

以下各节介绍如何设置IAM凭据以使用您的 AWS 账户进行身份验证 AWS Toolkit for Visual Studio Code。

重要

在设置IAM凭据以使用您的 AWS 账户进行身份验证之前,请注意:

  • 如果您已经通过其他 AWS 服务(例如 AWS CLI)设置了IAM凭证,则 AWS Toolkit for Visual Studio Code 会自动检测这些凭据并在 VS Code 中提供这些凭证。

  • AWS 建议使用IAM身份中心身份验证。有关 AWS IAM最佳做法的更多信息,请参阅《Identity and A ccess Managem AWS ent 用户指南》IAM部分中的安全最佳实践

  • 为避免安全风险,在开发专用软件或处理真实数据时,请勿使用IAM用户进行身份验证。取而代之的是,使用与身份提供商的联合,例如什么是IAM身份中心? 在《AWS IAM Identity Center 用户指南》中。

创建IAM用户

在将设置为使用您的 AWS 账户 AWS Toolkit for Visual Studio Code 进行身份验证之前,您需要在《和工具参考指南》的 “使用长期凭证进行身份验证” 主题中完成 “步骤 1:创建您的IAM用户”AWS SDKs 和 “步骤 2:获取访问密钥”。

注意

第 3 步:更新共享凭据文件AWS SDKs和《工具参考指南》是可选的。

如果您完成了步骤 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
  1. Shift+Command+P (Ctrl+Shift+PWindows) 打开命令面板。

  2. 在搜索栏中输AWS: Add a New Connection入。

  3. 选择AWS: Add a New Connection打开 “AWS 工具包登录” 面板。

  4. AWS Toolkit 登录面板中选择 “IAM凭据”,然后选择 “继续” 按钮继续。

  5. 在提供的字段中输入您 AWS 账户的Profile NameAccess Key、和Secret Key,然后选择 “继续” 按钮将配置文件添加到您的配置文件中,并将 Toolkit 与您的 AWS 帐户关联起来。

  6. 完成身份验证并建立连接后,Toolkit AWS Explorer 将会更新以显示您的 AWS 服务和资源。

注意

在此示例中,假设 [Profile_Name] 包含语法错误并导致身份验证失败。

[Profile_Name] xaws_access_key_id= AKIAI44QH8DHBEXAMPLE xaws_secret_access_key= wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

以下是为响应身份验证尝试失败而生成的日志消息示例。

2022-11-02 22:01:54 [ERROR]: Profile [Profile_Name] is not a valid Credential Profile: not supported by the Toolkit 2022-11-02 22:01:54 [WARN]: Shared Credentials Profile [Profile_Name] is not valid. It will not be used by the toolkit.

添加额外的凭证配置文件

您可以向配置文件中添加多个凭证。为此,请打开命令面板并选择 AWS Toolkit 创建凭证配置文件。这将打开凭证文件。在此页面上,您可以在第一个配置文件下方添加一个新的配置文件,如以下示例所示:

# 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