Skip to content

authorize_db_security_group_ingress

authorize_db_security_group_ingress(
    *,
    config_overrides: Optional[RDSClientConfig] = None,
    db_security_group_name: Optional[String] = None,
    cidrip: Optional[String] = None,
    ec2_security_group_name: Optional[String] = None,
    ec2_security_group_id: Optional[String] = None,
    ec2_security_group_owner_id: Optional[String] = None,
) -> AuthorizeDBSecurityGroupIngressResult

Enables ingress to a DBSecurityGroup using one of two forms of authorization. First, EC2 or VPC security groups can be added to the DBSecurityGroup if the application using the database is running on EC2 or VPC instances. Second, IP ranges are available if the application accessing your database is running on the internet. Required parameters for this API are one of CIDR range, EC2SecurityGroupId for VPC, or (EC2SecurityGroupOwnerId and either EC2SecurityGroupName or EC2SecurityGroupId for non-VPC).

You can't authorize ingress from an EC2 security group in one Amazon Web Services Region to an Amazon RDS DB instance in another. You can't authorize ingress from a VPC security group in one VPC to an Amazon RDS DB instance in another.

For an overview of CIDR ranges, go to the Wikipedia Tutorial.

EC2-Classic was retired on August 15, 2022. If you haven't migrated from EC2-Classic to a VPC, we recommend that you migrate as soon as possible. For more information, see Migrate from EC2-Classic to a VPC in the Amazon EC2 User Guide, the blog EC2-Classic Networking is Retiring – Here’s How to Prepare, and Moving a DB instance not in a VPC into a VPC in the Amazon RDS User Guide.

Parameters:

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

    The name of the DB security group to add authorization to.

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

    The IP range to authorize.

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

    Name of the EC2 security group to authorize. For VPC DB security groups, EC2SecurityGroupId must be provided. Otherwise, EC2SecurityGroupOwnerId and either EC2SecurityGroupName or EC2SecurityGroupId must be provided.

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

    Id of the EC2 security group to authorize. For VPC DB security groups, EC2SecurityGroupId must be provided. Otherwise, EC2SecurityGroupOwnerId and either EC2SecurityGroupName or EC2SecurityGroupId must be provided.

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

    Amazon Web Services account number of the owner of the EC2 security group specified in the EC2SecurityGroupName parameter. The Amazon Web Services access key ID isn't an acceptable value. For VPC DB security groups, EC2SecurityGroupId must be provided. Otherwise, EC2SecurityGroupOwnerId and either EC2SecurityGroupName or EC2SecurityGroupId must be provided.

Raises:

Examples:

To authorize DB security group integress This example authorizes access to the specified security group by the specified CIDR block.

>>> client.authorize_db_security_group_ingress(db_security_group_name='mydbsecuritygroup', cidrip='203.0.113.5/32')
Source code in docs_src/capo_rds/_services/rds.py
def authorize_db_security_group_ingress(
    self,
    *,
    config_overrides: Optional[RDSClientConfig] = None,
    db_security_group_name: Optional["capo_rds.types.string.String"] = None,
    cidrip: Optional["capo_rds.types.string.String"] = None,
    ec2_security_group_name: Optional["capo_rds.types.string.String"] = None,
    ec2_security_group_id: Optional["capo_rds.types.string.String"] = None,
    ec2_security_group_owner_id: Optional["capo_rds.types.string.String"] = None,
) -> "capo_rds.types.authorize_db_security_group_ingress_result.AuthorizeDBSecurityGroupIngressResult":
    """<p>Enables ingress to a DBSecurityGroup using one of two forms of authorization. First, EC2 or VPC security groups can be added to the DBSecurityGroup if the application using the database is running on EC2 or VPC instances. Second, IP ranges are available if the application accessing your database is running on the internet. Required parameters for this API are one of CIDR range, EC2SecurityGroupId for VPC, or (EC2SecurityGroupOwnerId and either EC2SecurityGroupName or EC2SecurityGroupId for non-VPC).</p> <p>You can't authorize ingress from an EC2 security group in one Amazon Web Services Region to an Amazon RDS DB instance in another. You can't authorize ingress from a VPC security group in one VPC to an Amazon RDS DB instance in another.</p> <p>For an overview of CIDR ranges, go to the <a href="http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing">Wikipedia Tutorial</a>.</p> <note> <p>EC2-Classic was retired on August 15, 2022. If you haven't migrated from EC2-Classic to a VPC, we recommend that you migrate as soon as possible. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/vpc-migrate.html">Migrate from EC2-Classic to a VPC</a> in the <i>Amazon EC2 User Guide</i>, the blog <a href="http://aws.amazon.com/blogs/aws/ec2-classic-is-retiring-heres-how-to-prepare/">EC2-Classic Networking is Retiring – Here’s How to Prepare</a>, and <a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.Non-VPC2VPC.html">Moving a DB instance not in a VPC into a VPC</a> in the <i>Amazon RDS User Guide</i>.</p> </note>

    Args:
        db_security_group_name: <p>The name of the DB security group to add authorization to.</p>
        cidrip: <p>The IP range to authorize.</p>
        ec2_security_group_name: <p>Name of the EC2 security group to authorize. For VPC DB security groups, <code>EC2SecurityGroupId</code> must be provided. Otherwise, <code>EC2SecurityGroupOwnerId</code> and either <code>EC2SecurityGroupName</code> or <code>EC2SecurityGroupId</code> must be provided.</p>
        ec2_security_group_id: <p>Id of the EC2 security group to authorize. For VPC DB security groups, <code>EC2SecurityGroupId</code> must be provided. Otherwise, <code>EC2SecurityGroupOwnerId</code> and either <code>EC2SecurityGroupName</code> or <code>EC2SecurityGroupId</code> must be provided.</p>
        ec2_security_group_owner_id: <p>Amazon Web Services account number of the owner of the EC2 security group specified in the <code>EC2SecurityGroupName</code> parameter. The Amazon Web Services access key ID isn't an acceptable value. For VPC DB security groups, <code>EC2SecurityGroupId</code> must be provided. Otherwise, <code>EC2SecurityGroupOwnerId</code> and either <code>EC2SecurityGroupName</code> or <code>EC2SecurityGroupId</code> must be provided.</p>

    Raises:
        capo_rds.errors.authorization_already_exists_fault.AuthorizationAlreadyExistsFault: <p>The specified CIDR IP range or Amazon EC2 security group is already authorized for the specified DB security group.</p>
        capo_rds.errors.authorization_quota_exceeded_fault.AuthorizationQuotaExceededFault: <p>The DB security group authorization quota has been reached.</p>
        capo_rds.errors.db_security_group_not_found_fault.DBSecurityGroupNotFoundFault: <p> <code>DBSecurityGroupName</code> doesn't refer to an existing DB security group.</p>
        capo_rds.errors.invalid_db_security_group_state_fault.InvalidDBSecurityGroupStateFault: <p>The state of the DB security group doesn't allow deletion.</p>
        capo_rds.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To authorize DB security group integress
        This example authorizes access to the specified security group by the specified CIDR block.

        >>> client.authorize_db_security_group_ingress(db_security_group_name='mydbsecuritygroup', cidrip='203.0.113.5/32')
    """

    def _handler(
        req: "OperationRequest[capo_rds.types.authorize_db_security_group_ingress_message.AuthorizeDBSecurityGroupIngressMessage]",
    ) -> OperationResponse[
        "capo_rds.types.authorize_db_security_group_ingress_result.AuthorizeDBSecurityGroupIngressResult"
    ]:
        import capo_rds._operations.amazon_rd_sv19.authorize_db_security_group_ingress

        output, http_response = (
            capo_rds._operations.amazon_rd_sv19.authorize_db_security_group_ingress.authorize_db_security_group_ingress(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AuthorizeDBSecurityGroupIngress")
    )
    input_: capo_rds.types.authorize_db_security_group_ingress_message.AuthorizeDBSecurityGroupIngressMessage = {}
    if db_security_group_name is not None:
        input_["db_security_group_name"] = db_security_group_name
    if cidrip is not None:
        input_["cidrip"] = cidrip
    if ec2_security_group_name is not None:
        input_["ec2_security_group_name"] = ec2_security_group_name
    if ec2_security_group_id is not None:
        input_["ec2_security_group_id"] = ec2_security_group_id
    if ec2_security_group_owner_id is not None:
        input_["ec2_security_group_owner_id"] = ec2_security_group_owner_id

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output