pub fn require_valid_role_arn(member: &str, arn: &str) -> Result<(), Error>Expand description
Rejects a RoleArn the service would reject, before the artifact upload.
§Why the build role in particular
CreateMicrovmImage.buildRoleArn is sent on the create call, and the create call happens
after the caller has uploaded the artifact. So the service’s rejection of a malformed
role ARN arrives having already cost the upload, which is the exact ordering
ControlPlane::create_image exists to protect against and the reason issue #24 singled
this member out. RunMicrovm.executionRoleArn is cheaper to get wrong but wrong in a
confusing place: it is optional in the model, so a malformed one is a ValidationException
on a member a caller may not know is being filled from their infra config.
§Three constraints, three messages
min: 20, max: 2048, and the pattern. They get separate messages because the pattern’s
wording (“this does not look like an IAM role ARN”) is unhelpful for a value that is merely
3000 characters, and the length wording is unhelpful for a role name — which is the most
common mistake and is short.
See crate::constants::is_valid_role_arn for what the structural check decides. It cannot
tell you the role exists or grants the right log permissions; those are the failures that
actually happen most and none of them is knowable without IAM.