diff --git a/aws/resource_aws_db_proxy_default_target_group.go b/aws/resource_aws_db_proxy_default_target_group.go index 45bc04f3cc34..4600addfe1c4 100644 --- a/aws/resource_aws_db_proxy_default_target_group.go +++ b/aws/resource_aws_db_proxy_default_target_group.go @@ -44,7 +44,8 @@ func resourceAwsDbProxyDefaultTargetGroup() *schema.Resource { }, "connection_pool_config": { Type: schema.TypeList, - Required: true, + Optional: true, + Computed: true, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ diff --git a/aws/resource_aws_db_proxy_default_target_group_test.go b/aws/resource_aws_db_proxy_default_target_group_test.go index 8e9eaca76173..06623fe222e1 100644 --- a/aws/resource_aws_db_proxy_default_target_group_test.go +++ b/aws/resource_aws_db_proxy_default_target_group_test.go @@ -46,6 +46,40 @@ func TestAccAWSDBProxyDefaultTargetGroup_Basic(t *testing.T) { }) } +func TestAccAWSDBProxyDefaultTargetGroup_EmptyConnectionPoolConfig(t *testing.T) { + var dbProxyTargetGroup rds.DBProxyTargetGroup + resourceName := "aws_db_proxy_default_target_group.test" + rName := acctest.RandomWithPrefix("tf-acc-test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t); testAccDBProxyPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSDBProxyTargetGroupDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSDBProxyDefaultTargetGroupConfig_EmptyConnectionPoolConfig(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSDBProxyTargetGroupExists(resourceName, &dbProxyTargetGroup), + testAccMatchResourceAttrRegionalARN(resourceName, "arn", "rds", regexp.MustCompile(`target-group:.+`)), + resource.TestCheckResourceAttr(resourceName, "connection_pool_config.#", "1"), + resource.TestCheckTypeSetElemNestedAttrs(resourceName, "connection_pool_config.*", map[string]string{ + "connection_borrow_timeout": "120", + "init_query": "", + "max_connections_percent": "100", + "max_idle_connections_percent": "50", + }), + resource.TestCheckResourceAttr(resourceName, "connection_pool_config.0.session_pinning_filters.#", "0"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func TestAccAWSDBProxyDefaultTargetGroup_ConnectionBorrowTimeout(t *testing.T) { var dbProxyTargetGroup rds.DBProxyTargetGroup resourceName := "aws_db_proxy_default_target_group.test" @@ -420,6 +454,14 @@ resource "aws_subnet" "test" { func testAccAWSDBProxyDefaultTargetGroupConfig_Basic(rName string) string { return testAccAWSDBProxyDefaultTargetGroupConfigBase(rName) + ` +resource "aws_db_proxy_default_target_group" "test" { + db_proxy_name = aws_db_proxy.test.name +} +` +} + +func testAccAWSDBProxyDefaultTargetGroupConfig_EmptyConnectionPoolConfig(rName string) string { + return testAccAWSDBProxyDefaultTargetGroupConfigBase(rName) + ` resource "aws_db_proxy_default_target_group" "test" { db_proxy_name = aws_db_proxy.test.name