Batch: computeResources.instanceRole is an instance profile

It's not an IAM role (the API parameter name in Batch is a misnomer).

Validation by matching against known role ARNs will always fail.
Scan the known instance profile ARNs instead.
This commit is contained in:
Andrey Kislyuk 2019-12-11 14:45:10 -08:00 committed by GitHub
parent 4d5bf1c5c6
commit ad234f225f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -815,8 +815,10 @@ class BatchBackend(BaseBackend):
raise InvalidParameterValueException(
"computeResources must contain {0}".format(param)
)
if self.iam_backend.get_role_by_arn(cr["instanceRole"]) is None:
for profile in self.iam_backend.get_instance_profiles():
if profile.arn == cr["instanceRole"]:
break
else:
raise InvalidParameterValueException(
"could not find instanceRole {0}".format(cr["instanceRole"])
)