View a markdown version of this page

使用创建 Amazon EC2 竞价型队列角色 Amazon CLI - Amazon Batch
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

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

使用创建 Amazon EC2 竞价型队列角色 Amazon CLI

为您的 Spot 队列计算环境创建 AmazonEC2SpotFleetTaggingRoleIAM 角色
  1. 使用 Amazon CLI运行以下命令。

    $ aws iam create-role --role-name AmazonEC2SpotFleetTaggingRole \ --assume-role-policy-document '{ "Version":"2012-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Principal": { "Service": "spotfleet.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }'
  2. 要将AmazonEC2SpotFleetTaggingRole托管 IAM 策略附加到您的AmazonEC2SpotFleetTaggingRole角色,请使用运行以下命令 Amazon CLI。

    $ aws iam attach-role-policy \ --policy-arn \ arn:aws:iam::aws:policy/service-role/AmazonEC2SpotFleetTaggingRole \ --role-name \ AmazonEC2SpotFleetTaggingRole
创建适用于 Amazon EC2 Spot 的 AWSServiceRoleForEC2Spot IAM 服务相关角色
注意

如果AWSServiceRoleForEC2Spot IAM 服务相关角色已存在,则会出现类似于以下内容的错误消息。

An error occurred (InvalidInput) when calling the CreateServiceLinkedRole operation: Service role name AWSServiceRoleForEC2Spot has been taken in this account, please try a different suffix.
  • 使用 Amazon CLI运行以下命令。

    $ aws iam create-service-linked-role --aws-service-name spot.amazonaws.com
要创建适用于 Amazon EC2 竞价型实例集的AWSServiceRoleForEC2SpotFleet IAM 服务相关角色
注意

如果AWSServiceRoleForEC2SpotFleet IAM 服务相关角色已存在,则会出现类似于以下内容的错误消息。

An error occurred (InvalidInput) when calling the CreateServiceLinkedRole operation: Service role name AWSServiceRoleForEC2SpotFleet has been taken in this account, please try a different suffix.
  • 使用 Amazon CLI运行以下命令。

    $ aws iam create-service-linked-role --aws-service-name spotfleet.amazonaws.com