From af262ef85cea1ac6ba1cbd1295ad5a03a238924d Mon Sep 17 00:00:00 2001 From: Graham Davison Date: Wed, 18 Nov 2020 19:27:52 -0800 Subject: [PATCH] Corrects connection_pool_config to be Optional and Computed --- ...ource_aws_db_proxy_default_target_group.go | 3 +- ..._aws_db_proxy_default_target_group_test.go | 42 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/aws/resource_aws_db_proxy_default_target_group.go b/aws/resource_aws_db_proxy_default_target_group.go index 45bc04f3cc3..4600addfe1c 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 8e9eaca7617..06623fe222e 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