解决AWS Batch服务启动实例较慢的问题,可以通过以下步骤进行:
{
"version": "2012-10-17",
"parameters": {
"InstanceType": {
"Type": "String",
"Default": "c5.large"
},
"ImageId": {
"Type": "AWS::EC2::Image::Id",
"Default": "ami-0123456789abcdef0"
}
},
"resources": {
"LaunchTemplate": {
"Type": "AWS::EC2::LaunchTemplate",
"Properties": {
"LaunchTemplateName": "MyTemplate",
"LaunchTemplateData": {
"ImageId": { "Ref": "ImageId" },
"InstanceType": { "Ref": "InstanceType" },
"NetworkInterfaces": [
{
"DeviceIndex": 0,
"SubnetId": "subnet-0123456789abcdef0",
"AssociatePublicIpAddress": true
}
]
}
}
}
}
}
{
"version": "2012-10-17",
"parameters": {
"InstanceType": {
"Type": "String",
"Default": "c5.large"
},
"ImageId": {
"Type": "AWS::EC2::Image::Id",
"Default": "ami-0123456789abcdef0"
}
},
"resources": {
"LaunchTemplate": {
"Type": "AWS::EC2::LaunchTemplate",
"Properties": {
"LaunchTemplateName": "MyTemplate",
"LaunchTemplateData": {
"ImageId": { "Ref": "ImageId" },
"InstanceType": { "Ref": "InstanceType" },
"NetworkInterfaces": [
{
"DeviceIndex": 0,
"SubnetId": "subnet-0123456789abcdef0",
"AssociatePublicIpAddress": true
}
]
}
}
},
"ComputeEnvironment": {
"Type": "AWS::Batch::ComputeEnvironment",
"Properties": {
"ComputeEnvironmentName": "MyComputeEnvironment",
"Type": "MANAGED",
"ServiceRole": "arn:aws:iam::123456789012:role/service-role/AWSBatchServiceRole",
"ComputeResources": {
"Type": "EC2",
"MinvCpus": 0,
"MaxvCpus": 256,
"DesiredvCpus": 0,
"InstanceTypes": [ { "Ref": "InstanceType" } ],
"Subnets": [ "subnet-0123456789abcdef0", "subnet-0123456789abcdef1" ],
"SecurityGroupIds": [ "sg-0123456789abcdef0" ],
"InstanceRole": "arn:aws:iam::123456789012:instance-profile/ecsInstanceRole",
"Tags": {
"Key": "Value"
}
}
}
}
}
}
{
"version": "2012-10-17",
"parameters": {
"InstanceType": {
"Type": "String",
"Default": "c5.large"
},
"ImageId": {
"Type": "AWS::EC2::Image::Id",
"Default": "ami-0123456789abcdef0"
}
},
"resources": {
"LaunchTemplate": {
"Type": "AWS::EC2::LaunchTemplate",
"Properties": {
"LaunchTemplateName": "MyTemplate",
"LaunchTemplateData": {
"ImageId": { "Ref": "ImageId" },
"InstanceType": { "Ref": "InstanceType" },
"NetworkInterfaces": [
{