教程:使用创建 Amazon EC2 竞价舰队角色 AWS CLI - AWS Batch

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

教程:使用创建 Amazon EC2 竞价舰队角色 AWS CLI

为您的 Spot 队列计算环境创建 EC2 SpotFleetTaggingRole A mazon IAM 角色
  1. 使用 AWS 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. 要将亚马逊EC2SpotFleetTaggingRole托管 IAM 策略附加到您的亚马逊EC2SpotFleetTaggingRole角色,请使用运行以下命令 AWS 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.
  • 使用 AWS CLI运行以下命令。

    $ aws iam create-service-linked-role --aws-service-name spot.amazonaws.com
为 Amazon EC2 Spot 队列创建 IA AWSServiceRoleForEC2SpotFleet M 服务相关角色
注意

如果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.
  • 使用 AWS CLI运行以下命令。

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