Skip to content

Commit 7d3d33f

Browse files
authored
Merge pull request #16303 from hashicorp/b-db_proxy-connection_pool-optional
resource/aws_db_proxy_default_target_group: Make connection_pool_config Optional
2 parents faba986 + af262ef commit 7d3d33f

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

aws/resource_aws_db_proxy_default_target_group.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ func resourceAwsDbProxyDefaultTargetGroup() *schema.Resource {
4444
},
4545
"connection_pool_config": {
4646
Type: schema.TypeList,
47-
Required: true,
47+
Optional: true,
48+
Computed: true,
4849
MaxItems: 1,
4950
Elem: &schema.Resource{
5051
Schema: map[string]*schema.Schema{

aws/resource_aws_db_proxy_default_target_group_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,40 @@ func TestAccAWSDBProxyDefaultTargetGroup_Basic(t *testing.T) {
4646
})
4747
}
4848

49+
func TestAccAWSDBProxyDefaultTargetGroup_EmptyConnectionPoolConfig(t *testing.T) {
50+
var dbProxyTargetGroup rds.DBProxyTargetGroup
51+
resourceName := "aws_db_proxy_default_target_group.test"
52+
rName := acctest.RandomWithPrefix("tf-acc-test")
53+
54+
resource.ParallelTest(t, resource.TestCase{
55+
PreCheck: func() { testAccPreCheck(t); testAccDBProxyPreCheck(t) },
56+
Providers: testAccProviders,
57+
CheckDestroy: testAccCheckAWSDBProxyTargetGroupDestroy,
58+
Steps: []resource.TestStep{
59+
{
60+
Config: testAccAWSDBProxyDefaultTargetGroupConfig_EmptyConnectionPoolConfig(rName),
61+
Check: resource.ComposeTestCheckFunc(
62+
testAccCheckAWSDBProxyTargetGroupExists(resourceName, &dbProxyTargetGroup),
63+
testAccMatchResourceAttrRegionalARN(resourceName, "arn", "rds", regexp.MustCompile(`target-group:.+`)),
64+
resource.TestCheckResourceAttr(resourceName, "connection_pool_config.#", "1"),
65+
resource.TestCheckTypeSetElemNestedAttrs(resourceName, "connection_pool_config.*", map[string]string{
66+
"connection_borrow_timeout": "120",
67+
"init_query": "",
68+
"max_connections_percent": "100",
69+
"max_idle_connections_percent": "50",
70+
}),
71+
resource.TestCheckResourceAttr(resourceName, "connection_pool_config.0.session_pinning_filters.#", "0"),
72+
),
73+
},
74+
{
75+
ResourceName: resourceName,
76+
ImportState: true,
77+
ImportStateVerify: true,
78+
},
79+
},
80+
})
81+
}
82+
4983
func TestAccAWSDBProxyDefaultTargetGroup_ConnectionBorrowTimeout(t *testing.T) {
5084
var dbProxyTargetGroup rds.DBProxyTargetGroup
5185
resourceName := "aws_db_proxy_default_target_group.test"
@@ -420,6 +454,14 @@ resource "aws_subnet" "test" {
420454

421455
func testAccAWSDBProxyDefaultTargetGroupConfig_Basic(rName string) string {
422456
return testAccAWSDBProxyDefaultTargetGroupConfigBase(rName) + `
457+
resource "aws_db_proxy_default_target_group" "test" {
458+
db_proxy_name = aws_db_proxy.test.name
459+
}
460+
`
461+
}
462+
463+
func testAccAWSDBProxyDefaultTargetGroupConfig_EmptyConnectionPoolConfig(rName string) string {
464+
return testAccAWSDBProxyDefaultTargetGroupConfigBase(rName) + `
423465
resource "aws_db_proxy_default_target_group" "test" {
424466
db_proxy_name = aws_db_proxy.test.name
425467

0 commit comments

Comments
 (0)