AWS Amazon RDS Proxy Target
This page shows how to write Terraform and CloudFormation for Amazon RDS Proxy Target and write them securely.
aws_db_proxy_target (Terraform)
The Proxy Target in Amazon RDS can be configured in Terraform with the resource name aws_db_proxy_target
. The following sections describe 5 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_db_proxy_target" "main" {
db_instance_identifier = aws_db_instance.main.id
db_proxy_name = aws_db_proxy.main.name
target_group_name = aws_db_proxy_default_target_group.main.name
}
resource "aws_db_proxy_target" "db_proxy_target" {
count = var.enable_db_proxy_target ? 1 : 0
db_proxy_name = var.db_proxy_target_db_proxy_name != "" ? var.db_proxy_target_db_proxy_name : (var.enable_db_proxy ? element(aws_db_proxy.db_proxy.*.name, 0) : null)
target_group_name = var.db_proxy_target_target_group_name != "" ? var.db_proxy_target_target_group_name : (var.enable_db_proxy_default_target_group ? element(aws_db_proxy_default_target_group.db_proxy_default_target_group.*.db_proxy_name, 0) : null)
resource "aws_db_proxy_target" "db_proxy_target" {
count = var.enable_db_proxy_target ? 1 : 0
db_proxy_name = var.db_proxy_target_db_proxy_name != "" ? var.db_proxy_target_db_proxy_name : (var.enable_db_proxy ? element(aws_db_proxy.db_proxy.*.name, 0) : null)
target_group_name = var.db_proxy_target_target_group_name != "" ? var.db_proxy_target_target_group_name : (var.enable_db_proxy_default_target_group ? element(aws_db_proxy_default_target_group.db_proxy_default_target_group.*.db_proxy_name, 0) : null)
resource "aws_db_proxy_target" "main" {
db_cluster_identifier = aws_rds_cluster.qumitoru-db.id
db_proxy_name = aws_db_proxy.main.name
target_group_name = "default"
}
resource "aws_db_proxy_target" "main" {
db_cluster_identifier = aws_rds_cluster.qumitoru-db.id
db_proxy_name = aws_db_proxy.main.name
target_group_name = "default"
}
Parameters
-
db_cluster_identifier
optional - string -
db_instance_identifier
optional - string -
db_proxy_name
required - string -
endpoint
optional computed - string -
id
optional computed - string -
port
optional computed - number -
rds_resource_id
optional computed - string -
target_arn
optional computed - string -
target_group_name
required - string -
tracked_cluster_id
optional computed - string -
type
optional computed - string
Explanation in Terraform Registry
Provides an RDS DB proxy target resource.
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 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:
TargetGroupName: default
DBProxyName: !Ref RDSProxy
DBInstanceIdentifiers:
- !Ref RDSInstance
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 Target?
AWS Amazon RDS Proxy Target 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 Target?
For Terraform, the sapphire-ko/aws-rds-proxy-test, SebastianUA/terraform and asrkata/SebastianUA-terraform source code examples are useful. See the Terraform Example section for further details.
For CloudFormation, the Pivopil/awsdevbot-root-baseline, argjentsahiti/RDSProxyServerlessExample and montecha/examples source code examples are useful. See the CloudFormation Example section for further details.