Function validate_name

Source
pub fn validate_name<F: FnOnce(String) -> PrincipalError>(
    name: &str,
    max_length: usize,
    map_err: F,
) -> Result<(), PrincipalError>
Expand description

Verify that an instance profile, group, role, or user name meets AWS requirements.

The AWS requirements are similar for these names:

  • The name must contain between 1 and max_length characters.
  • The name must be composed to ASCII alphanumeric characters or one of , - . = @ _.

The max_length argument is specified as an argument to this function, but should be 128 for instance profiles, 128 for IAM groups, 64 for IAM roles, and 64 for IAM users.

If name meets these requirements, Ok(()) is returned. Otherwise, Err(map_err(name.to_string())) is returned.