Merge pull request #2631 from kislyuk/patch-2
Batch: computeResources.instanceRole is an instance profile
This commit is contained in:
commit
7b63b2818e
@ -854,8 +854,10 @@ class BatchBackend(BaseBackend):
|
|||||||
raise InvalidParameterValueException(
|
raise InvalidParameterValueException(
|
||||||
"computeResources must contain {0}".format(param)
|
"computeResources must contain {0}".format(param)
|
||||||
)
|
)
|
||||||
|
for profile in self.iam_backend.get_instance_profiles():
|
||||||
if self.iam_backend.get_role_by_arn(cr["instanceRole"]) is None:
|
if profile.arn == cr["instanceRole"]:
|
||||||
|
break
|
||||||
|
else:
|
||||||
raise InvalidParameterValueException(
|
raise InvalidParameterValueException(
|
||||||
"could not find instanceRole {0}".format(cr["instanceRole"])
|
"could not find instanceRole {0}".format(cr["instanceRole"])
|
||||||
)
|
)
|
||||||
|
@ -55,6 +55,10 @@ def _setup(ec2_client, iam_client):
|
|||||||
RoleName="TestRole", AssumeRolePolicyDocument="some_policy"
|
RoleName="TestRole", AssumeRolePolicyDocument="some_policy"
|
||||||
)
|
)
|
||||||
iam_arn = resp["Role"]["Arn"]
|
iam_arn = resp["Role"]["Arn"]
|
||||||
|
iam_client.create_instance_profile(InstanceProfileName="TestRole")
|
||||||
|
iam_client.add_role_to_instance_profile(
|
||||||
|
InstanceProfileName="TestRole", RoleName="TestRole"
|
||||||
|
)
|
||||||
|
|
||||||
return vpc_id, subnet_id, sg_id, iam_arn
|
return vpc_id, subnet_id, sg_id, iam_arn
|
||||||
|
|
||||||
@ -83,7 +87,7 @@ def test_create_managed_compute_environment():
|
|||||||
"subnets": [subnet_id],
|
"subnets": [subnet_id],
|
||||||
"securityGroupIds": [sg_id],
|
"securityGroupIds": [sg_id],
|
||||||
"ec2KeyPair": "string",
|
"ec2KeyPair": "string",
|
||||||
"instanceRole": iam_arn,
|
"instanceRole": iam_arn.replace("role", "instance-profile"),
|
||||||
"tags": {"string": "string"},
|
"tags": {"string": "string"},
|
||||||
"bidPercentage": 123,
|
"bidPercentage": 123,
|
||||||
"spotIamFleetRole": "string",
|
"spotIamFleetRole": "string",
|
||||||
@ -209,7 +213,7 @@ def test_delete_managed_compute_environment():
|
|||||||
"subnets": [subnet_id],
|
"subnets": [subnet_id],
|
||||||
"securityGroupIds": [sg_id],
|
"securityGroupIds": [sg_id],
|
||||||
"ec2KeyPair": "string",
|
"ec2KeyPair": "string",
|
||||||
"instanceRole": iam_arn,
|
"instanceRole": iam_arn.replace("role", "instance-profile"),
|
||||||
"tags": {"string": "string"},
|
"tags": {"string": "string"},
|
||||||
"bidPercentage": 123,
|
"bidPercentage": 123,
|
||||||
"spotIamFleetRole": "string",
|
"spotIamFleetRole": "string",
|
||||||
|
@ -51,6 +51,10 @@ def _setup(ec2_client, iam_client):
|
|||||||
RoleName="TestRole", AssumeRolePolicyDocument="some_policy"
|
RoleName="TestRole", AssumeRolePolicyDocument="some_policy"
|
||||||
)
|
)
|
||||||
iam_arn = resp["Role"]["Arn"]
|
iam_arn = resp["Role"]["Arn"]
|
||||||
|
iam_client.create_instance_profile(InstanceProfileName="TestRole")
|
||||||
|
iam_client.add_role_to_instance_profile(
|
||||||
|
InstanceProfileName="TestRole", RoleName="TestRole"
|
||||||
|
)
|
||||||
|
|
||||||
return vpc_id, subnet_id, sg_id, iam_arn
|
return vpc_id, subnet_id, sg_id, iam_arn
|
||||||
|
|
||||||
@ -78,7 +82,7 @@ def test_create_env_cf():
|
|||||||
"InstanceTypes": ["optimal"],
|
"InstanceTypes": ["optimal"],
|
||||||
"Subnets": [subnet_id],
|
"Subnets": [subnet_id],
|
||||||
"SecurityGroupIds": [sg_id],
|
"SecurityGroupIds": [sg_id],
|
||||||
"InstanceRole": iam_arn,
|
"InstanceRole": iam_arn.replace("role", "instance-profile"),
|
||||||
},
|
},
|
||||||
"ServiceRole": iam_arn,
|
"ServiceRole": iam_arn,
|
||||||
},
|
},
|
||||||
@ -129,7 +133,7 @@ def test_create_job_queue_cf():
|
|||||||
"InstanceTypes": ["optimal"],
|
"InstanceTypes": ["optimal"],
|
||||||
"Subnets": [subnet_id],
|
"Subnets": [subnet_id],
|
||||||
"SecurityGroupIds": [sg_id],
|
"SecurityGroupIds": [sg_id],
|
||||||
"InstanceRole": iam_arn,
|
"InstanceRole": iam_arn.replace("role", "instance-profile"),
|
||||||
},
|
},
|
||||||
"ServiceRole": iam_arn,
|
"ServiceRole": iam_arn,
|
||||||
},
|
},
|
||||||
@ -195,7 +199,7 @@ def test_create_job_def_cf():
|
|||||||
"InstanceTypes": ["optimal"],
|
"InstanceTypes": ["optimal"],
|
||||||
"Subnets": [subnet_id],
|
"Subnets": [subnet_id],
|
||||||
"SecurityGroupIds": [sg_id],
|
"SecurityGroupIds": [sg_id],
|
||||||
"InstanceRole": iam_arn,
|
"InstanceRole": iam_arn.replace("role", "instance-profile"),
|
||||||
},
|
},
|
||||||
"ServiceRole": iam_arn,
|
"ServiceRole": iam_arn,
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user