

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

# 设置 AWS 用户账户
<a name="setting-up-aws-login"></a>

**提示**  
使用这些主题来获取有关以下任务的帮助：  
换一个新 AWS 账户 的，一起使用Amazon GameLift Servers。
创建具有 Amazon GameLift Servers 资源使用权限的用户或组。
设置安全证书（你需要这些证书才能使用虚幻和Unity的 AWS CLI 工具和Amazon GameLift Servers插件）


与所有 AWS 服务一样， AWS 账户 您需要使用Amazon GameLift Servers服务和工具。具有两个主要功能：(1) 它为您提供一个容器，用于存放您使用该账户创建的所有 AWS 资源；以及 (2) 它允许您管理 AWS 资源的安全，包括设置用户身份验证和控制用户访问权限。 AWS 账户 创建. 不收取任何费用 AWS 账户。

**Amazon GameLift Servers使用或不使用 AWS 账号进行探索**  
您**无需** AWS 账户即可执行以下操作：
+ 在 for Gam [es 上探索用于构建、运行和提升游戏体验AWS 的 AWS](https://aws.amazon.com/gametech/)工具。阅读[博客](https://aws.amazon.com/blogs/gametech/)并浏览[游戏解决方案库](https://aws.amazon.com/solutions/games)。
+ Amazon GameLift Servers在[产品概述和资源](https://aws.amazon.com/gamelift/)中了解更多信息。 FAQs**向 AWS提问**以获取关于产品问题的解答。（试试这个：“寻找低成本方案来托管我的多人游戏”。）
+ 查阅[技术文档](https://docs.aws.amazon.com/gamelift/)，更深入地了解 Amazon GameLift Servers 的工作原理，包括有关托管和对战的开发人员指南以及服务 API 参考指南。
+ 查看有关 [Amazon GameLift Servers 定价](https://aws.amazon.com/gamelift/servers/pricing/)和成本优化技术的信息。试用[定价计算器](https://calculator.aws/#/createCalculator/GameLift)，了解根据高峰并发玩家用量（CCU）计算托管费用的方式。
+ 下载并查看插件和工具包的Amazon GameLift Servers SDKs代码存储库。请参阅 [Amazon GameLift Servers 入门](https://aws.amazon.com/gamelift/servers/getting-started/)。（你需要一个 AWS 账户 才能使用它们。）

您**确实**需要一个 AWS 账户才能执行以下操作：
+ 使用适用于 Unreal 和 Unity 的 Amazon GameLift Servers 插件来完成入门工作流程，或者使用游戏服务器封装器完成该流程。
+ 使用 AWS 管理控制台创建和管理 AWS 资源。
+ 使用 AWS Command Line Interface创建和管理 AWS 资源。
+ 结合使用 Amazon Q 和 Amazon GameLift Servers 技术文档来查找答案、获取指导和建议。

**Topics**
+ [注册获取 AWS 账户](#sign-up-for-aws)
+ [创建具有管理访问权限的用户](#create-an-admin)
+ [为 Amazon GameLift Servers 设置用户权限](#getting-started-create-iam-user)
+ [为用户设置编程式访问权限](#getting-started-iam-user-access-keys)
+ [为游戏设置编程式访问权限](#getting-started-iam-player-user)
+ [Amazon GameLift Servers 的 IAM 权限示例](gamelift-iam-policy-examples.md)
+ [为 Amazon GameLift Servers 设置 IAM 服务角色](setting-up-role.md)

## 注册获取 AWS 账户
<a name="sign-up-for-aws"></a>

如果您没有 AWS 账户，请完成以下步骤来创建一个。

**报名参加 AWS 账户**

1. 打开[https://portal.aws.amazon.com/billing/注册。](https://portal.aws.amazon.com/billing/signup)

1. 按照屏幕上的说明操作。

   在注册时，将接到电话或收到短信，要求使用电话键盘输入一个验证码。

   当您注册时 AWS 账户，就会创建*AWS 账户根用户*一个。根用户有权访问该账户中的所有 AWS 服务 和资源。作为最佳安全实践，请为用户分配管理访问权限，并且只使用根用户来执行[需要根用户访问权限的任务](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_root-user.html#root-user-tasks)。

AWS 注册过程完成后会向您发送一封确认电子邮件。您可以随时前往 [https://aws.amazon.com/](https://aws.amazon.com/)并选择 “**我的账户”，查看您当前的账户活动并管理您的账户**。

## 创建具有管理访问权限的用户
<a name="create-an-admin"></a>

注册后，请保护您的安全 AWS 账户 AWS 账户根用户 AWS IAM Identity Center，启用并创建管理用户，这样您就不会使用 root 用户执行日常任务。

**保护你的 AWS 账户根用户**

1.  选择 **Root 用户**并输入您的 AWS 账户 电子邮件地址，以账户所有者的身份登录。[AWS 管理控制台](https://console.aws.amazon.com/)在下一页上，输入您的密码。

   要获取使用根用户登录方面的帮助，请参阅《AWS 登录 用户指南》**中的 [Signing in as the root user](https://docs.aws.amazon.com/signin/latest/userguide/console-sign-in-tutorials.html#introduction-to-root-user-sign-in-tutorial)。

1. 为您的根用户启用多重身份验证（MFA）。

   有关说明，请参阅 I [A *M* 用户指南中的为 AWS 账户 根用户启用虚拟 MFA 设备（控制台）](https://docs.aws.amazon.com/IAM/latest/UserGuide/enable-virt-mfa-for-root.html)。

**创建具有管理访问权限的用户**

1. 启用 IAM Identity Center。

   有关说明，请参阅**《AWS IAM Identity Center 用户指南》中的[启用 AWS IAM Identity Center](https://docs.aws.amazon.com//singlesignon/latest/userguide/get-set-up-for-idc.html)。

1. 在 IAM Identity Center 中，为用户授予管理访问权限。

   有关使用 IAM Identity Center 目录 作为身份源的教程，请参阅《[用户*指南》 IAM Identity Center 目录中的使用默认设置配置AWS IAM Identity Center 用户*访问权限](https://docs.aws.amazon.com//singlesignon/latest/userguide/quick-start-default-idc.html)。

**以具有管理访问权限的用户身份登录**
+ 要使用您的 IAM Identity Center 用户身份登录，请使用您在创建 IAM Identity Center 用户时发送到您的电子邮件地址的登录 URL。

  有关使用 IAM Identity Center 用户[登录的帮助，请参阅*AWS 登录 用户指南*中的登录 AWS 访问门户](https://docs.aws.amazon.com/signin/latest/userguide/iam-id-center-sign-in-tutorial.html)。

**将访问权限分配给其他用户**

1. 在 IAM Identity Center 中，创建一个权限集，该权限集遵循应用最低权限的最佳做法。

   有关说明，请参阅《AWS IAM Identity Center 用户指南》**中的 [Create a permission set](https://docs.aws.amazon.com//singlesignon/latest/userguide/get-started-create-a-permission-set.html)。

1. 将用户分配到一个组，然后为该组分配单点登录访问权限。

   有关说明，请参阅《AWS IAM Identity Center 用户指南》**中的 [Add groups](https://docs.aws.amazon.com//singlesignon/latest/userguide/addgroups.html)。

## 为 Amazon GameLift Servers 设置用户权限
<a name="getting-started-create-iam-user"></a>

根据需要创建更多用户或将访问权限扩展到现有用户，以访问您的 Amazon GameLift Servers 资源。作为最佳实操（[IAM 中的安全最佳实操](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html)），请为所有用户应用最低权限。有关权限语法的指导，请参阅[Amazon GameLift Servers 的 IAM 权限示例](gamelift-iam-policy-examples.md)。

根据您管理 AWS 账户中用户的方式，按照以下说明设置用户权限。

要提供访问权限，请为您的用户、组或角色添加权限：
+ 中的用户和群组 AWS IAM Identity Center：

  创建权限集合。按照《AWS IAM Identity Center 用户指南》**中[创建权限集](https://docs.aws.amazon.com//singlesignon/latest/userguide/howtocreatepermissionset.html)的说明进行操作。
+ 通过身份提供者在 IAM 中托管的用户：

  创建适用于身份联合验证的角色。按照《IAM 用户指南》**中[针对第三方身份提供者创建角色（联合身份验证）](https://docs.aws.amazon.com//IAM/latest/UserGuide/id_roles_create_for-idp.html)的说明进行操作。
+ IAM 用户：
  + 创建您的用户可以担任的角色。按照《IAM 用户指南》**中[为 IAM 用户创建角色](https://docs.aws.amazon.com//IAM/latest/UserGuide/id_roles_create_for-user.html)的说明进行操作。
  + （不推荐使用）将策略直接附加到用户或将用户添加到用户组。按照《IAM 用户指南》**中[向用户添加权限（控制台）](https://docs.aws.amazon.com//IAM/latest/UserGuide/id_users_change-permissions.html#users_change_permissions-add-console)中的说明进行操作。

在与 IAM 用户合作时，最佳实操是始终向角色或用户组授予权限，而不是向个人用户授予权限。

## 为用户设置编程式访问权限
<a name="getting-started-iam-user-access-keys"></a>

如果用户想在 AWS 外部进行交互，则需要编程访问权限 AWS 管理控制台。授予编程访问权限的方式取决于正在访问的用户类型 AWS。

要向用户授予编程式访问权限，请选择以下选项之一。


****  

| 哪个用户需要编程式访问权限？ | 目的 | 方式 | 
| --- | --- | --- | 
| IAM | （推荐）使用控制台凭证作为临时凭证，签署对 AWS CLI AWS SDKs、或的编程请求 AWS APIs。 |  按照您希望使用的界面的说明进行操作。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/gameliftservers/latest/developerguide/setting-up-aws-login.html)  | 
|  人力身份 （在 IAM Identity Center 中管理的用户）  | 使用临时证书签署向 AWS CLI AWS SDKs、或发出的编程请求 AWS APIs。 |  按照您希望使用的界面的说明进行操作。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/gameliftservers/latest/developerguide/setting-up-aws-login.html)  | 
| IAM | 使用临时证书签署向 AWS CLI AWS SDKs、或发出的编程请求 AWS APIs。 | 按照 IAM 用户指南中的将[临时证书与 AWS 资源配合使用](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html)中的说明进行操作。 | 
| IAM | （不推荐使用）使用长期凭证签署向 AWS CLI AWS SDKs、或发出的编程请求 AWS APIs。 |  按照您希望使用的界面的说明进行操作。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/gameliftservers/latest/developerguide/setting-up-aws-login.html)  | 

如果您使用访问密钥，请参阅[管理 AWS 访问密钥的最佳实践](https://docs.aws.amazon.com/accounts/latest/reference/credentials-access-keys-best-practices.html)。

## 为游戏设置编程式访问权限
<a name="getting-started-iam-player-user"></a>

大多数游戏都使用后端服务与Amazon GameLift Servers之通信 AWS SDKs。使用后端服务（代表游戏客户端）请求游戏会话、让玩家进入游戏中以及执行其他任务。这些服务需要编程式访问权限和安全凭证来验证对 Amazon GameLift Servers 服务 API 的调用。

对于Amazon GameLift Servers，您可以通过在 AWS Identity and Access Management (IAM) 中创建玩家用户来管理此访问权限。通过下列选项之一管理玩家用户权限：
+ 创建具有玩家用户权限的 IAM 角色，并允许玩家用户在需要时担任该角色。在向 Amazon GameLift Servers 提出请求之前，后端服务必须包含担任此角色的代码。根据安全最佳实操，角色提供有限的临时访问权限。您可以将角色用于在 AWS 资源上运行的工作负载（[IAM 角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html)）或资源外部 AWS （[IAM 角色随处可](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_common-scenarios_non-aws.html)见）。
+ 使用玩家用户权限创建 IAM 用户组，并将您的玩家用户添加到该组中。此选项为您的玩家用户提供长期凭证，后端服务在与 Amazon GameLift Servers 通信时必须存储和使用这些证书。

有关权限策略语法，请参阅[玩家用户权限示例](gamelift-iam-policy-examples.md#iam-policy-admin-game-dev-example)。

有关管理工作负载使用的权限的更多信息，请参阅 [IAM 身份：IAM 中的临时凭证](https://docs.aws.amazon.com/IAM/latest/UserGuide/id.html#id_temp-creds)。

# Amazon GameLift Servers 的 IAM 权限示例
<a name="gamelift-iam-policy-examples"></a>

使用这些示例中的语法为需要访问Amazon GameLift Servers资源的用户设置 AWS Identity and Access Management (IAM) 权限。有关管理用户权限的更多信息，请参阅[为 Amazon GameLift Servers 设置用户权限](setting-up-aws-login.md#getting-started-create-iam-user)。在管理 IAM Identity Center 以外的用户的权限时，最佳实操是始终向 IAM 角色或用户组授予权限，而不是向个人用户授予权限。

如果您要Amazon GameLift ServersFleetIQ用作独立解决方案，请参阅[设置您 AWS 账户 的Amazon GameLift ServersFleetIQ](https://docs.aws.amazon.com/gameliftservers/latest/fleetiqguide/gsg-iam-permissions.html)。

## 管理权限示例
<a name="iam-policy-simple-example"></a>

这些示例为托管管理员或开发人员提供了有针对性的访问权限，以便管理 Amazon GameLift Servers 游戏托管资源。

**Example Amazon GameLift Servers 资源完全访问权限语法**  
以下示例扩展了对所有 Amazon GameLift Servers 资源的完全访问权限。    
****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": {
    "Effect": "Allow",
    "Action": "gamelift:*",
    "Resource": "*"
  }
}
```

**Example 支持默认未启用区域的 Amazon GameLift Servers 资源权限的语法**  
以下示例将访问权限扩展到所有默认情况下未启用的Amazon GameLift Servers资源和 AWS 区域。有关默认情况下未启用的区域以及如何启用这些区域的更多信息，请参阅《AWS 一般参考》**中的[管理 AWS 区域](https://docs.aws.amazon.com/general/latest/gr/rande-manage.html)。    
****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": {
    "Effect": "Allow",
    "Action": [
      "ec2:DescribeRegions",
      "gamelift:*"
    ],
    "Resource": "*"
  }
}
```

**Example Amazon GameLift Servers 资源访问 Amazon ECR 中的容器映像的语法**  
以下示例扩展了 Amazon GameLift Servers 用户在使用托管式容器实例集时所需的 Amazon Elastic Container Registry（Amazon ECR）操作的访问权限。    
****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": {
    "Effect": "Allow",
    "Action": [
      "ecr:DescribeImages",
      "ecr:BatchGetImage",
      "ecr:GetDownloadUrlForLayer"
    ],
    "Resource": "*"
  }
}
```

**Example Amazon GameLift Servers 资源和 `PassRole` 权限的语法**  
以下示例扩展了对所有 Amazon GameLift Servers 资源的访问权限，并允许用户将 IAM 服务角色传递给 Amazon GameLift Servers。服务角色使 Amazon GameLift Servers 能够有限地代表您访问其他资源和服务，如[为 Amazon GameLift Servers 设置 IAM 服务角色](setting-up-role.md)中所述。例如，在响应 `CreateBuild` 请求时，Amazon GameLift Servers 需要访问您在 Amazon S3 存储桶中的生成包文件。有关该`PassRole`操作的更多信息，请参阅 [IAM *用户指南中的 IAM：将 IAM* 角色传递给特定 AWS 服务](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_examples_iam-passrole-service.html)。    
****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "gamelift:*",
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": "iam:PassRole",
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "iam:PassedToService": "gamelift.amazonaws.com"
        }
      }
    }
  ]
}
```

## 玩家用户权限示例
<a name="iam-policy-admin-game-dev-example"></a>

这些示例允许后端服务或其他实体对 Amazon GameLift Servers API 进行 API 调用。它们涵盖了管理游戏会话、玩家会话和对战的常见场景。有关更多信息，请参阅[为游戏设置编程式访问权限](setting-up-aws-login.md#getting-started-iam-player-user)。

**Example 游戏会话置放权限的语法**  
以下示例扩展了对使用游戏会话放置队列来创建游戏会话和管理玩家会话的访问权限。Amazon GameLift Servers APIs     
****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": {
    "Sid": "PlayerPermissionsForGameSessionPlacements",
    "Effect": "Allow",
    "Action": [
      "gamelift:StartGameSessionPlacement",
      "gamelift:DescribeGameSessionPlacement",
      "gamelift:StopGameSessionPlacement",
      "gamelift:CreatePlayerSession",
      "gamelift:CreatePlayerSessions",
      "gamelift:DescribeGameSessions"
    ],
    "Resource": "*"
  }
}
```

**Example 对战权限的语法**  
以下示例扩展了FlexMatch对管理配对活动的访问权限。Amazon GameLift Servers APIs FlexMatch为新游戏或现有游戏会话匹配玩家，并为托管的游戏启动游戏会话放置。Amazon GameLift Servers有关 FlexMatch 的更多信息，请参阅[什么是 Amazon GameLift ServersFlexMatch？](https://docs.aws.amazon.com/gameliftservers/latest/flexmatchguide/match-intro.html)    
****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": {
    "Sid": "PlayerPermissionsForGameSessionMatchmaking",
    "Effect": "Allow",
    "Action": [
      "gamelift:StartMatchmaking",
      "gamelift:DescribeMatchmaking",
      "gamelift:StopMatchmaking",
      "gamelift:AcceptMatch",
      "gamelift:StartMatchBackfill",
      "gamelift:DescribeGameSessions"
    ],
    "Resource": "*"
  }
}
```

**Example 手动游戏会话放置权限的语法**  
以下示例扩展了对在Amazon GameLift Servers APIs 指定队列上手动创建游戏会话和玩家会话的访问权限。此场景支持不使用放置队列的游戏，例如允许玩家通过从可用游戏会话列表中进行选择来加入的游戏（“list-and-pick” 方法）。    
****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": {
    "Sid": "PlayerPermissionsForManualGameSessions",
    "Effect": "Allow",
    "Action": [
      "gamelift:CreateGameSession",
      "gamelift:DescribeGameSessions",
      "gamelift:SearchGameSessions",
      "gamelift:CreatePlayerSession",
      "gamelift:CreatePlayerSessions",
      "gamelift:DescribePlayerSessions"
    ],
    "Resource": "*"
  }
}
```

# 为 Amazon GameLift Servers 设置 IAM 服务角色
<a name="setting-up-role"></a>

某些Amazon GameLift Servers功能要求您将有限的访问权限扩展到您拥有的其他 AWS 资源。您可以通过创建 AWS Identity and Access Management (IAM) 角色来做到这一点。IAM [角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html)是可在账户中创建的一种具有特定权限的 IAM 身份。IAM 角色与 IAM 用户类似，因为它是一个具有权限策略的 AWS 身份，该策略决定了该身份可以做什么和不能做什么 AWS。但是，角色旨在让需要它的任何人代入，而不是唯一地与某个人员关联。此外，角色没有关联的标准长期凭证（如密码或访问密钥）。相反，当你担任角色时，它会为你的角色会话提供临时安全证书。

本主题介绍如何创建可用于 Amazon GameLift Servers 托管式实例集的角色。如果您使用Amazon GameLift ServersFleetIQ来优化亚马逊弹性计算云 (Amazon EC2) 实例上的游戏托管，[请参阅设置 AWS 账户](https://docs.aws.amazon.com/gameliftservers/latest/fleetiqguide/gsg-iam-permissions.html)您的。Amazon GameLift Servers FleetIQ

在以下步骤中，创建一个拥有自定义权限策略和允许 Amazon GameLift Servers 担任角色的信任策略的角色。

## 为 Amazon GameLift Servers 托管式 EC2 实例集创建 IAM 服务角色
<a name="setting-up-role-custom"></a>

**步骤 1：创建权限策略。**

使用本页面上的说明和示例，为您正在使用的 Amazon GameLift Servers 实例集类型创建自定义权限策略。

**使用 JSON 策略编辑器创建策略**

1. 登录 AWS 管理控制台 并打开 IAM 控制台，网址为[https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/)。

1. 在左侧的导航窗格中，选择**策略**。

   如果这是您首次选择**策略**，则会显示**欢迎访问托管式策略**页面。选择**开始使用**。

1. 在页面的顶部，选择**创建策略**。

1. 在**策略编辑器**部分，选择 **JSON** 选项。

1. 输入或粘贴一个 JSON 策略文档。有关 IAM 策略语言的详细信息，请参阅 [IAM JSON 策略](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies.html)参考。

1. 解决[策略验证](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_policy-validator.html)过程中生成的任何安全警告、错误或常规警告，然后选择**下一步**。
**注意**  
您可以随时在**可视化**和 **JSON** 编辑器选项卡之间切换。不过，如果您进行更改或在**可视化**编辑器中选择**下一步**，IAM 可能会调整策略结构以针对可视化编辑器进行优化。有关更多信息，请参阅*《IAM 用户指南》*中的[调整策略结构](https://docs.aws.amazon.com/IAM/latest/UserGuide/troubleshoot_policies.html#troubleshoot_viseditor-restructure)。

1. （可选）在中创建或编辑策略时 AWS 管理控制台，可以生成可在模板中使用的 JSON 或 YAML 策略 CloudFormation 模板。

   为此，请在**策略编辑器**中选择**操作**，然后选择**生成 CloudFormation模板**。要了解更多信息 CloudFormation，请参阅*AWS CloudFormation 用户指南*中的[AWS Identity and Access Management 资源类型参考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_IAM.html)。

1. 向策略添加完权限后，选择**下一步**。

1. 在**查看并创建**页面上，为您要创建的策略键入**策略名称**和**描述**（可选）。查看**此策略中定义的权限**以查看策略授予的权限。

1. （可选）通过以密钥值对的形式附加标签来向策略添加元数据。有关在 IAM 中使用标签的更多信息，请参阅 *IAM 用户指南*中的[AWS Identity and Access Management 资源标签](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html)。

1. 选择**创建策略**可保存您的新策略。

**步骤 2：创建 Amazon GameLift Servers 可以担任的角色。**

**创建 IAM 角色**

1. 在 IAM 控制台的导航窗格中，选择**角色**，然后选择**创建角色**。

1. 在**选择可信实体**页面上，选择**自定义信任策略**选项。此选项将打开**自定义信任策略**编辑器。

1. 将默认 JSON 语法替换为以下语法，然后选择**下一步**继续。

------
#### [ JSON ]

****  

   ```
   {
     "Version":"2012-10-17",		 	 	 
     "Statement": [
       {
         "Effect": "Allow",
         "Principal": {
           "Service": "gamelift.amazonaws.com"
         },
         "Action": "sts:AssumeRole"
       }
     ]
   }
   ```

------

1. 在**添加权限**页面上，找到并选择您在步骤 1 中创建的权限策略。选择**下一步**以继续。

1. 在**名称、查看并创建**页面上，为您要创建的角色输入**角色名称**和**描述**（可选）。查看**信任实体**和**已添加权限**。

1. 选择**创建角色**以保存您的新角色。

## 为 Amazon GameLift Servers 托管式容器创建 IAM 角色
<a name="setting-up-role-containers"></a>

如果您使用的是 Amazon GameLift Servers 托管式容器，需要创建用于容器实例集的 IAM 服务角色。此角色授予 Amazon GameLift Servers 管理您的容器实例集资源并代表您执行操作所需的有限权限。

**为容器实例集创建 IAM 角色**

1. 登录 AWS 管理控制台 并打开 IAM 控制台，网址为[https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/)。

1. 在 IAM 控制台的导航窗格中，选择**角色**，然后选择**创建角色**。

1. 在 **“选择可信实体**” 页面上，选择**AWS 服务**，然后选择**用例** “GameLift”。选择**下一步**。

1. 在**添加权限**页面上，选择托管策略 `GameLiftContainerFleetPolicy`。选择**下一步**。有关此策略的更多信息，请参阅[AWS 的托管策略 Amazon GameLift Servers](security-iam-awsmanpol.md)。

1. 在**命名、查看和创建**页面上，输入角色名称，然后选择**创建角色**以保存新角色。

## 权限策略语法
<a name="setting-up-role-syntax"></a>
+ **Amazon GameLift Servers 担任服务角色的权限**

------
#### [ JSON ]

****  

  ```
  {
    "Version":"2012-10-17",		 	 	 
    "Statement": [
      {
        "Effect": "Allow",
        "Principal": {
          "Service": "gamelift.amazonaws.com"
        },
        "Action": "sts:AssumeRole"
      }
    ]
  }
  ```

------
+ **访问默认情况下未启用的 AWS 区域的权限**

------
#### [ JSON ]

****  

  ```
  {
    "Version":"2012-10-17",		 	 	 
    "Statement": [
      {
        "Effect": "Allow",
        "Principal": {
          "Service": [
            "gamelift.amazonaws.com",
            "gamelift.ap-east-1.amazonaws.com",
            "gamelift.me-south-1.amazonaws.com",
            "gamelift.af-south-1.amazonaws.com",
            "gamelift.eu-south-1.amazonaws.com" 
          ]
        },
        "Action": "sts:AssumeRole"
      }
    ]
  }
  ```

------