在AWS应用迁移管理器中,可以通过设置策略来限制资源的大小及数量。例如,下面的代码将限制AWS应用迁移管理器在迁移过程中启动的最大实例大小为t2.medium:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "LimitInstanceSize",
"Effect": "Deny",
"Action": [
"ec2:RunInstances"
],
"Resource": [
"arn:aws:ec2:*:*:instance/*"
],
"Condition": {
"ForAllValues:StringEquals": {
"ec2:InstanceType": [
"m5.large",
"m5a.large",
"m5d.large",
"m5ad.large",
"r5.large",
"r5a.large",
"r5d.large",
"r5ad.large",
"z1d.large",
"t3.large",
"t2.xlarge",
"t3.xlarge",
"m4.xlarge",
"r4.xlarge",
"c4.xlarge",
"c5.xlarge",
"t2.large",
"t2.medium"
]
}
}
}
]
}
这段代码中,Deny代表禁止,ec2:RunInstances代表运行实例,Resource中的Instance/*代表所有实例。而Condition中的ec2:InstanceType代表实例大小,其取值为m5.large等。由于设置了Deny的条件,所以条件内的实例大小都不能被启动。