Skip to content

create_role_alias async

create_role_alias(
    role_alias: RoleAlias,
    role_arn: RoleArn,
    *,
    config_overrides: Optional[AsyncIoTClientConfig] = None,
    credential_duration_seconds: Optional[CredentialDurationSeconds] = None,
    tags: Optional[TagList] = None,
) -> CreateRoleAliasResponse

Creates a role alias.

Requires permission to access the CreateRoleAlias action.

The value of credentialDurationSeconds must be less than or equal to the maximum session duration of the IAM role that the role alias references. For more information, see Modifying a role maximum session duration (Amazon Web Services API) from the Amazon Web Services Identity and Access Management User Guide.

Parameters:

  • role_alias (RoleAlias) –

    The role alias that points to a role ARN. This allows you to change the role without having to update the device.

  • role_arn (RoleArn) –

    The role ARN.

  • credential_duration_seconds (Optional[CredentialDurationSeconds], default: None ) –

    How long (in seconds) the credentials will be valid. The default value is 3,600 seconds.

    This value must be less than or equal to the maximum session duration of the IAM role that the role alias references.

  • tags (Optional[TagList], default: None ) –

    Metadata which can be used to manage the role alias.

    For URI Request parameters use format: ...key1=value1&key2=value2...

    For the CLI command-line parameter use format: &&tags "key1=value1&key2=value2..."

    For the cli-input-json file use format: "tags": "key1=value1&key2=value2..."

Raises:

Source code in docs_src/capo_iot/_services/async_io_t.py
async def create_role_alias(
    self,
    role_alias: "capo_iot.types.role_alias.RoleAlias",
    role_arn: "capo_iot.types.role_arn.RoleArn",
    *,
    config_overrides: Optional[AsyncIoTClientConfig] = None,
    credential_duration_seconds: Optional[
        "capo_iot.types.credential_duration_seconds.CredentialDurationSeconds"
    ] = None,
    tags: Optional["capo_iot.types.tag_list.TagList"] = None,
) -> "capo_iot.types.create_role_alias_response.CreateRoleAliasResponse":
    """<p>Creates a role alias.</p> <p>Requires permission to access the <a href="https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions">CreateRoleAlias</a> action.</p> <important> <p>The value of <a href="https://docs.aws.amazon.com/iot/latest/apireference/API_CreateRoleAlias.html#iot-CreateRoleAlias-request-credentialDurationSeconds"> <code>credentialDurationSeconds</code> </a> must be less than or equal to the maximum session duration of the IAM role that the role alias references. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/roles-managingrole-editing-api.html#roles-modify_max-session-duration-api"> Modifying a role maximum session duration (Amazon Web Services API)</a> from the Amazon Web Services Identity and Access Management User Guide.</p> </important>

    Args:
        role_alias: <p>The role alias that points to a role ARN. This allows you to change the role without having to update the device.</p>
        role_arn: <p>The role ARN.</p>
        credential_duration_seconds: <p>How long (in seconds) the credentials will be valid. The default value is 3,600 seconds.</p> <p>This value must be less than or equal to the maximum session duration of the IAM role that the role alias references.</p>
        tags: <p>Metadata which can be used to manage the role alias.</p> <note> <p>For URI Request parameters use format: ...key1=value1&key2=value2...</p> <p>For the CLI command-line parameter use format: &&tags "key1=value1&key2=value2..."</p> <p>For the cli-input-json file use format: "tags": "key1=value1&key2=value2..."</p> </note>

    Raises:
        capo_iot.errors.internal_failure_exception.InternalFailureException: <p>An unexpected error has occurred.</p>
        capo_iot.errors.invalid_request_exception.InvalidRequestException: <p>The request is not valid.</p>
        capo_iot.errors.limit_exceeded_exception.LimitExceededException: <p>A limit has been exceeded.</p>
        capo_iot.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>The resource already exists.</p>
        capo_iot.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service is temporarily unavailable.</p>
        capo_iot.errors.throttling_exception.ThrottlingException: <p>The rate exceeds the limit.</p>
        capo_iot.errors.unauthorized_exception.UnauthorizedException: <p>You are not authorized to perform this operation.</p>
        capo_iot.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_iot.types.create_role_alias_request.CreateRoleAliasRequest]",
    ) -> AsyncOperationResponse[
        "capo_iot.types.create_role_alias_response.CreateRoleAliasResponse"
    ]:
        import capo_iot._operations.aws_iot_service.create_role_alias

        (
            output,
            http_response,
        ) = await capo_iot._operations.aws_iot_service.create_role_alias.async_create_role_alias(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateRoleAlias")
    )
    input_: capo_iot.types.create_role_alias_request.CreateRoleAliasRequest = {
        "role_alias": role_alias,
        "role_arn": role_arn,
    }
    if credential_duration_seconds is not None:
        input_["credential_duration_seconds"] = credential_duration_seconds
    if tags is not None:
        input_["tags"] = tags

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output