Skip to content

add_role_to_db_instance async

add_role_to_db_instance(
    *,
    config_overrides: Optional[AsyncRDSClientConfig] = None,
    db_instance_identifier: Optional[String] = None,
    role_arn: Optional[String] = None,
    feature_name: Optional[String] = None,
) -> None

Associates an Amazon Web Services Identity and Access Management (IAM) role with a DB instance.

To add a role to a DB instance, the status of the DB instance must be available.

This command doesn't apply to RDS Custom.

Parameters:

  • db_instance_identifier (Optional[String], default: None ) –

    The name of the DB instance to associate the IAM role with.

  • role_arn (Optional[String], default: None ) –

    The Amazon Resource Name (ARN) of the IAM role to associate with the DB instance, for example arn:aws:iam::123456789012:role/AccessRole.

  • feature_name (Optional[String], default: None ) –

    The name of the feature for the DB instance that the IAM role is to be associated with. For information about supported feature names, see DBEngineVersion.

Raises:

Examples:

To associate an AWS Identity and Access Management (IAM) role with a DB instance The following example adds the role to a DB instance named test-instance.

>>> await client.add_role_to_db_instance(db_instance_identifier='test-instance', role_arn='arn:aws:iam::111122223333:role/rds-s3-integration-role', feature_name='S3_INTEGRATION')
Source code in docs_src/capo_rds/_services/async_rds.py
async def add_role_to_db_instance(
    self,
    *,
    config_overrides: Optional[AsyncRDSClientConfig] = None,
    db_instance_identifier: Optional["capo_rds.types.string.String"] = None,
    role_arn: Optional["capo_rds.types.string.String"] = None,
    feature_name: Optional["capo_rds.types.string.String"] = None,
) -> None:
    """<p>Associates an Amazon Web Services Identity and Access Management (IAM) role with a DB instance.</p> <note> <p>To add a role to a DB instance, the status of the DB instance must be <code>available</code>.</p> </note> <p>This command doesn't apply to RDS Custom.</p>

    Args:
        db_instance_identifier: <p>The name of the DB instance to associate the IAM role with.</p>
        role_arn: <p>The Amazon Resource Name (ARN) of the IAM role to associate with the DB instance, for example <code>arn:aws:iam::123456789012:role/AccessRole</code>.</p>
        feature_name: <p>The name of the feature for the DB instance that the IAM role is to be associated with. For information about supported feature names, see <a>DBEngineVersion</a>.</p>

    Raises:
        capo_rds.errors.db_instance_not_found_fault.DBInstanceNotFoundFault: <p> <code>DBInstanceIdentifier</code> doesn't refer to an existing DB instance.</p>
        capo_rds.errors.db_instance_role_already_exists_fault.DBInstanceRoleAlreadyExistsFault: <p>The specified <code>RoleArn</code> or <code>FeatureName</code> value is already associated with the DB instance.</p>
        capo_rds.errors.db_instance_role_quota_exceeded_fault.DBInstanceRoleQuotaExceededFault: <p>You can't associate any more Amazon Web Services Identity and Access Management (IAM) roles with the DB instance because the quota has been reached.</p>
        capo_rds.errors.invalid_db_instance_state_fault.InvalidDBInstanceStateFault: <p>The DB instance isn't in a valid state.</p>
        capo_rds.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To associate an AWS Identity and Access Management (IAM) role with a DB instance
        The following example adds the role to a DB instance named test-instance.

        >>> await client.add_role_to_db_instance(db_instance_identifier='test-instance', role_arn='arn:aws:iam::111122223333:role/rds-s3-integration-role', feature_name='S3_INTEGRATION')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_rds.types.add_role_to_db_instance_message.AddRoleToDBInstanceMessage]",
    ) -> AsyncOperationResponse[None]:
        import capo_rds._operations.amazon_rd_sv19.add_role_to_db_instance

        (
            output,
            http_response,
        ) = await capo_rds._operations.amazon_rd_sv19.add_role_to_db_instance.async_add_role_to_db_instance(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AddRoleToDBInstance")
    )
    input_: capo_rds.types.add_role_to_db_instance_message.AddRoleToDBInstanceMessage = {}
    if db_instance_identifier is not None:
        input_["db_instance_identifier"] = db_instance_identifier
    if role_arn is not None:
        input_["role_arn"] = role_arn
    if feature_name is not None:
        input_["feature_name"] = feature_name

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