AWS CloudFormation
User Guide (API 版本 2010-05-15)
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 Amazon AWS 入门

AWS::Batch::ComputeEnvironment

AWS::Batch::ComputeEnvironment 资源可定义您的 AWS Batch 计算环境。有关更多信息,请参阅 AWS Batch 用户指南 中的计算环境

语法

要在 AWS CloudFormation 模板中声明此实体,请使用以下语法:

JSON

{ "Type" : "AWS::Batch::ComputeEnvironment", "Properties" : { "Type" : String, "ServiceRole" : String, "ComputeEnvironmentName" : String, "ComputeResources" : ComputeResources, "State" : String } }

YAML

Type: "AWS::Batch::ComputeEnvironment" Properties: Type: String ServiceRole: String ComputeEnvironmentName: String ComputeResources: ComputeResources State: String

属性

Type

计算环境的类型。

必需:是

Type: String

更新要求:替换

ServiceRole

与计算环境关联的服务角色,允许 AWS Batch 代表您调用 AWS API 操作。

必需:是

Type: String

更新要求:无需中断

ComputeEnvironmentName

计算环境的名称。

必需:否

Type: String

更新要求:替换

ComputeResources

为计算环境定义的计算资源。

必需:是

类型AWS Batch ComputeEnvironment ComputeResources

更新要求:无需中断

State

计算环境的状态。有效值为 ENABLEDDISABLEDENABLED 状态表示您可以向计算环境注册实例,并且关联的实例可以接受作业。

必需:否

Type: String

更新要求:无需中断

返回值

Ref

当您将 AWS::Batch::ComputeEnvironment 资源的逻辑 ID 传递给内部函数 Ref 时,该函数返回计算环境 ARN,例如 arn:aws:batch:us-east-1:555555555555:compute-environment/M4OnDemand

有关使用 Ref 功能的更多信息,请参阅参考

示例

托管计算环境

以下示例创建一个名为 C4OnDemand 的托管计算环境,该环境使用 C4 按需实例和自定义 AMI。

JSON

{ "ComputeEnvironment": { "Type": "AWS::Batch::ComputeEnvironment", "Properties": { "Type": "MANAGED", "ServiceRole": "arn:aws:iam::111122223333:role/service-role/AWSBatchServiceRole", "ComputeEnvironmentName": "C4OnDemand", "ComputeResources": { "MaxvCpus": 128, "SecurityGroupIds": [ "sg-abcd1234" ], "Type": "EC2", "Subnets": [ "subnet-aaaaaaaa", "subnet-bbbbbbbb", "subnet-cccccccc" ], "MinvCpus": 0, "ImageId": "ami-a1b2c3d4", "InstanceRole": "ecsInstanceRole", "InstanceTypes": [ "c4.large", "c4.xlarge", "c4.2xlarge", "c4.4xlarge", "c4.8xlarge" ], "Ec2KeyPair": "id_rsa", "Tags": {"Name": "Batch Instance - C4OnDemand"}, "DesiredvCpus": 48 }, "State": "ENABLED" } } }

YAML

ComputeEnvironment: Type: AWS::Batch::ComputeEnvironment Properties: Type: MANAGED ServiceRole: arn:aws:iam::111122223333:role/service-role/AWSBatchServiceRole ComputeEnvironmentName: C4OnDemand ComputeResources: MaxvCpus: 128 SecurityGroupIds: - sg-abcd1234 Type: EC2 Subnets: - subnet-aaaaaaaa - subnet-bbbbbbbb - subnet-cccccccc MinvCpus: 0 ImageId: ami-a1b2c3d4 InstanceRole: ecsInstanceRole InstanceTypes: - c4.large - c4.xlarge - c4.2xlarge - c4.4xlarge - c4.8xlarge Ec2KeyPair: id_rsa Tags: {"Name": "Batch Instance - C4OnDemand"} DesiredvCpus: 48 State: ENABLED

以下示例创建一个名为 my-first-compute-environment 的计算环境并为计算资源指定标签。

JSON

"MyComputeEnv": { "Type": "AWS::Batch::ComputeEnvironment", "Properties": { "Type": "MANAGED", "ServiceRole": "AWSBatchServiceRole", "ComputeEnvironmentName": "my-first-compute-environment", "ComputeResources": { "MinvCpus": "4", "MaxvCpus": "256", "DesiredvCpus": "4", "SecurityGroupIds": [ "sg-a1b2c3d4", "sg-4d3c2ba1" ], "Type": "EC2", "Subnets": [ "subnet-12345678", "subnet-87654321" ], "InstanceRole": "batch-instance-profile", "InstanceTypes": [ "optimal" ], "Ec2KeyPair": { "Ref": "MyKeyPair" }, "Tags": { "Owner": "A", "Project": "B" } }, "State": "ENABLED" } }

YAML

MyComputeEnv: Type: AWS::Batch::ComputeEnvironment Properties: Type: MANAGED ServiceRole: AWSBatchServiceRole ComputeEnvironmentName: my-first-compute-environment ComputeResources: MinvCpus: 4 MaxvCpus: 256 DesiredvCpus: 4 SecurityGroupIds: - sg-a1b2c3d4 - sg-4d3c2ba1 Type: EC2 Subnets: - subnet-12345678 - subnet-87654321 InstanceRole: batch-instance-profile InstanceTypes: - optimal Ec2KeyPair: !Ref MyKeyPair Tags: Owner: A Project: B State: ENABLED

本页内容: