AWS Amazon RDS Proxy Default Target Group
This page shows how to write Terraform and CloudFormation for Amazon RDS Proxy Default Target Group and write them securely.
aws_db_proxy_default_target_group (Terraform)
The Proxy Default Target Group in Amazon RDS can be configured in Terraform with the resource name aws_db_proxy_default_target_group
. The following sections describe 5 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_db_proxy_default_target_group" "main" {
db_proxy_name = aws_db_proxy.main.name
connection_pool_config {
connection_borrow_timeout = 120
max_connections_percent = 100
resource "aws_db_proxy_default_target_group" "db_proxy_default_target_group" {
count = var.enable_db_proxy_default_target_group ? 1 : 0
db_proxy_name = var.db_proxy_default_target_group_db_proxy_name != "" ? var.db_proxy_default_target_group_db_proxy_name : (var.enable_db_proxy ? element(aws_db_proxy.db_proxy.*.name, 0) : null)
dynamic "connection_pool_config" {
resource "aws_db_proxy_default_target_group" "db_proxy_default_target_group" {
count = var.enable_db_proxy_default_target_group ? 1 : 0
db_proxy_name = var.db_proxy_default_target_group_db_proxy_name != "" ? var.db_proxy_default_target_group_db_proxy_name : (var.enable_db_proxy ? element(aws_db_proxy.db_proxy.*.name, 0) : null)
dynamic "connection_pool_config" {
resource "aws_db_proxy_default_target_group" "main" {
db_proxy_name = aws_db_proxy.main.name
}
resource "aws_db_proxy_target" "main" {
db_cluster_identifier = aws_rds_cluster.qumitoru-db.id
resource "aws_db_proxy_default_target_group" "main" {
db_proxy_name = aws_db_proxy.main.name
}
resource "aws_db_proxy_target" "main" {
db_cluster_identifier = aws_rds_cluster.qumitoru-db.id
Parameters
-
arn
optional computed - string -
db_proxy_name
required - string -
id
optional computed - string -
name
optional computed - string -
connection_pool_config
list block-
connection_borrow_timeout
optional - number -
init_query
optional - string -
max_connections_percent
optional - number -
max_idle_connections_percent
optional - number -
session_pinning_filters
optional - set of string
-
-
timeouts
single block
Explanation in Terraform Registry
Provides a resource to manage an RDS DB proxy default target group resource. The
aws_db_proxy_default_target_group
behaves differently from normal resources, in that Terraform does not create or destroy this resource, since it implicitly exists as part of an RDS DB Proxy. On Terraform resource creation it is automatically imported and on resource destruction, Terraform performs no actions in RDS.
Tips: Best Practices for The Other AWS Amazon RDS Resources
In addition to the aws_db_instance, AWS Amazon RDS has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
aws_db_instance
Ensure backup retension of your RDS instance is specified
It's better to set it explicitly to reduce the risk of availability issues.
aws_rds_cluster
Ensure backup retension of your RDS cluster is specified
It's better to set it explicitly to reduce the risk of availability issues.
aws_rds_cluster_instance
Ensure your RDS cluster instance blocks unwanted access
It's better to limit accessibily to the minimum that is required for the application to work.
AWS::RDS::DBProxyTargetGroup (CloudFormation)
The DBProxyTargetGroup in RDS can be configured in CloudFormation with the resource name AWS::RDS::DBProxyTargetGroup
. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
Type: AWS::RDS::DBProxyTargetGroup
Properties:
DBProxyName: !Ref DBProxy
DBClusterIdentifiers: [!Ref ClusterId]
TargetGroupName: default
ConnectionPoolConfigurationInfo:
Type: AWS::RDS::DBProxyTargetGroup
Properties:
DBProxyName: !Ref TestDBProxy
DBInstanceIdentifiers: [!Ref InstanceName]
TargetGroupName: default
Type: AWS::RDS::DBProxyTargetGroup
Properties:
DBProxyName: !Ref RDSProxy
DBInstanceIdentifiers:
- test-proxy-rds
TargetGroupName: default
Type: AWS::RDS::DBProxyTargetGroup
Properties:
DbProxyName: RDS-Proxy-Demo
TargetGroupName: default
DBClusterIdentifiers:
- Fn::ImportValue: rds:${self:provider.stage}:AuroraRDSClusterId
Type: AWS::RDS::DBProxyTargetGroup
Properties:
ConnectionPoolConfigurationInfo:
MaxConnectionsPercent: 50
TargetGroupName: default
DBProxyName: !Ref RDSProxy
"Type": "AWS::RDS::DBProxyTargetGroup",
"Properties": {
"DBProxyName": {
"Ref": "dbProxy3B89EAF2"
},
"TargetGroupName": "default",
"Type": "AWS::RDS::DBProxyTargetGroup",
"Properties": {
"DBProxyName": {
"Ref": "dbProxy3B89EAF2"
},
"TargetGroupName": "default",
"Type": "AWS::RDS::DBProxyTargetGroup",
"Properties": {
"DBProxyName": {
"Ref": "dbProxy3B89EAF2"
},
"TargetGroupName": "default",
"Type": "AWS::RDS::DBProxyTargetGroup",
"Properties": {
"DBProxyName": {
"Ref": "dbProxy3B89EAF2"
},
"TargetGroupName": "default",
"AWS::RDS::DBProxyTargetGroup.ConnectionPoolConfigurationInfoFormat": {
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-dbproxytargetgroup-connectionpoolconfigurationinfoformat.html",
"Properties": {
"MaxConnectionsPercent": {
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-dbproxytargetgroup-connectionpoolconfigurationinfoformat.html#cfn-rds-dbproxytargetgroup-connectionpoolconfigurationinfoformat-maxconnectionspercent",
"UpdateType": "Mutable",
Parameters
-
DBProxyName
required - String -
TargetGroupName
required - String -
ConnectionPoolConfigurationInfo
optional - ConnectionPoolConfigurationInfoFormat -
DBInstanceIdentifiers
optional - List -
DBClusterIdentifiers
optional - List
Explanation in CloudFormation Registry
The
AWS::RDS::DBProxyTargetGroup
resource represents a set of RDS DB instances, Aurora DB clusters, or both that a proxy can connect to. Currently, each target group is associated with exactly one RDS DB instance or Aurora DB cluster.This data type is used as a response element in the
DescribeDBProxyTargetGroups
action.For information about RDS Proxy for Amazon RDS, see Managing Connections with Amazon RDS Proxy in the Amazon RDS User Guide.
For information about RDS Proxy for Amazon Aurora, see Managing Connections with Amazon RDS Proxy in the Amazon Aurora User Guide.
For a sample template that creates a DB proxy and registers a DB instance, see Examples in AWS::RDS::DBProxy.
Note Limitations apply to RDS Proxy, including DB engine version limitations and AWS Region limitations. For information about limitations that apply to RDS Proxy for Amazon RDS, see Limitations for RDS Proxy in the Amazon RDS User Guide. For information about that apply to RDS Proxy for Amazon Aurora, see Limitations for RDS Proxy in the Amazon Aurora User Guide.
Frequently asked questions
What is AWS Amazon RDS Proxy Default Target Group?
AWS Amazon RDS Proxy Default Target Group is a resource for Amazon RDS of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS Amazon RDS Proxy Default Target Group?
For Terraform, the sapphire-ko/aws-rds-proxy-test, asrkata/SebastianUA-terraform and SebastianUA/terraform source code examples are useful. See the Terraform Example section for further details.
For CloudFormation, the MAS-Group-team/terraform-aws-rds-cluster-proxy, Pivopil/awsdevbot-root-baseline and argjentsahiti/RDSProxyServerlessExample source code examples are useful. See the CloudFormation Example section for further details.