AWS::RDS::DBSecurityGroupIngress - AWS CloudFormation

AWS::RDS::DBSecurityGroupIngress

The AWS::RDS::DBSecurityGroupIngress resource enables ingress to a DB security group using one of two forms of authorization. First, you can add EC2 or VPC security groups to the DB security group 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.

This type supports updates. For more information about updating stacks, see AWS CloudFormation Stacks Updates.

For details about the settings for DB security group ingress, see AuthorizeDBSecurityGroupIngress.

Note

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.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::RDS::DBSecurityGroupIngress", "Properties" : { "CIDRIP" : String, "DBSecurityGroupName" : String, "EC2SecurityGroupId" : String, "EC2SecurityGroupName" : String, "EC2SecurityGroupOwnerId" : String } }

YAML

Type: AWS::RDS::DBSecurityGroupIngress Properties: CIDRIP: String DBSecurityGroupName: String EC2SecurityGroupId: String EC2SecurityGroupName: String EC2SecurityGroupOwnerId: String

Properties

CIDRIP

The IP range to authorize.

Required: No

Type: String

Update requires: No interruption

DBSecurityGroupName

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

Required: Yes

Type: String

Update requires: No interruption

EC2SecurityGroupId

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.

Required: No

Type: String

Update requires: No interruption

EC2SecurityGroupName

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.

Required: No

Type: String

Update requires: No interruption

EC2SecurityGroupOwnerId

AWS account number of the owner of the EC2 security group specified in the EC2SecurityGroupName parameter. The AWS 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.

Required: No

Type: String

Update requires: No interruption

Return values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the DB security group that this ingress rule is associated with.

For more information about using the Ref function, see Ref.

Fn::GetAtt

Examples

Enable ingress to a DB security group

The following example creates a DB security group and allows ingress to it from a specified VPC security group.

JSON

{ "Resources": { "MyDBSecurityGroupIngress": { "Type": "AWS::RDS::DBSecurityGroupIngress", "Properties": { "DBSecurityGroupName": { "Ref": "MyDBSecurityGroup" }, "EC2SecurityGroupId": { "Ref": "MyVPCSecurityGroup" } } }, "MyDBSecurityGroup": { "Type": "AWS::RDS::DBSecurityGroup", "Properties": { "GroupDescription": "My database security group" } }, "MyVPCSecurityGroup": { "Type": "AWS::EC2::SecurityGroup", "Properties": { "GroupDescription": "My VPC security group", "VpcId": "vpc-12345678" } } } }

YAML

Resources: MyDBSecurityGroupIngress: Type: AWS::RDS::DBSecurityGroupIngress Properties: DBSecurityGroupName: Ref: MyDBSecurityGroup EC2SecurityGroupId: Ref: MyVPCSecurityGroup MyDBSecurityGroup: Type: AWS::RDS::DBSecurityGroup Properties: GroupDescription: My database security group MyVPCSecurityGroup: Type: AWS::EC2::SecurityGroup Properties: GroupDescription: My VPC security group VpcId: vpc-12345678