使用 AWS CLI 创建 Amazon EC2 竞价型实例集角色
要为竞价型实例集计算环境创建 AmazonEC2SpotFleetTaggingRole IAM 角色
-
使用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" } ] }' -
要将 AmazonEC2SpotFleetTaggingRole 托管 IAM policy 附加到AmazonEC2SpotFleetTaggingRole 角色上,请使用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 nameAWSServiceRoleForEC2Spothas 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 竞价型实例集的AWSServiceRoleForEC2SpotFleet IAM 服务相关角色
注意
如果AWSServiceRoleForEC2SpotFleet IAM 服务相关角色已存在,则会出现类似于以下内容的错误消息。
An error occurred (InvalidInput) when calling the CreateServiceLinkedRole operation: Service role nameAWSServiceRoleForEC2SpotFleethas been taken in this account, please try a different suffix.
-
使用AWS CLI运行以下命令。
$aws iam create-service-linked-role --aws-service-name spotfleet.amazonaws.com