From 2b1b0e0b2c083a20833de8a7d0c470e1ed9d1431 Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Sat, 6 Nov 2021 22:52:51 +0200 Subject: [PATCH 1/3] validation for datasync s3 location --- internal/service/datasync/location_s3.go | 9 +++-- internal/service/datasync/location_s3_test.go | 33 ++++--------------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/internal/service/datasync/location_s3.go b/internal/service/datasync/location_s3.go index 7880d3771c6..69cf00b58bf 100644 --- a/internal/service/datasync/location_s3.go +++ b/internal/service/datasync/location_s3.go @@ -38,13 +38,16 @@ func ResourceLocationS3() *schema.Resource { Type: schema.TypeSet, Optional: true, ForceNew: true, - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: verify.ValidARN, + }, }, "s3_bucket_arn": { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.NoZeroValues, + ValidateFunc: verify.ValidARN, }, "s3_config": { Type: schema.TypeList, @@ -57,7 +60,7 @@ func ResourceLocationS3() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.NoZeroValues, + ValidateFunc: verify.ValidARN, }, }, }, diff --git a/internal/service/datasync/location_s3_test.go b/internal/service/datasync/location_s3_test.go index 04ad410c19e..c1d224eb2e8 100644 --- a/internal/service/datasync/location_s3_test.go +++ b/internal/service/datasync/location_s3_test.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" + tfdatasync "github.com/hashicorp/terraform-provider-aws/internal/service/datasync" ) func TestAccDataSyncLocationS3_basic(t *testing.T) { @@ -105,8 +106,8 @@ func TestAccDataSyncLocationS3_disappears(t *testing.T) { Config: testAccLocationS3Config(rName), Check: resource.ComposeTestCheckFunc( testAccCheckLocationS3Exists(resourceName, &locationS31), - testAccCheckLocationS3Disappears(&locationS31), - ), + acctest.CheckResourceDisappears(acctest.Provider, tfdatasync.ResourceLocationS3(), resourceName), + acctest.CheckResourceDisappears(acctest.Provider, tfdatasync.ResourceLocationS3(), resourceName)), ExpectNonEmptyPlan: true, }, }, @@ -215,20 +216,6 @@ func testAccCheckLocationS3Exists(resourceName string, locationS3 *datasync.Desc } } -func testAccCheckLocationS3Disappears(location *datasync.DescribeLocationS3Output) resource.TestCheckFunc { - return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).DataSyncConn - - input := &datasync.DeleteLocationInput{ - LocationArn: location.LocationArn, - } - - _, err := conn.DeleteLocation(input) - - return err - } -} - func testAccCheckLocationS3NotRecreated(i, j *datasync.DescribeLocationS3Output) resource.TestCheckFunc { return func(s *terraform.State) error { if !aws.TimeValue(i.CreationTime).Equal(aws.TimeValue(j.CreationTime)) { @@ -242,7 +229,7 @@ func testAccCheckLocationS3NotRecreated(i, j *datasync.DescribeLocationS3Output) func testAccLocationS3BaseConfig(rName string) string { return fmt.Sprintf(` resource "aws_iam_role" "test" { - name = %q + name = %[1]q assume_role_policy = < Date: Sat, 6 Nov 2021 22:57:52 +0200 Subject: [PATCH 2/3] changelog --- .changelog/21661.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/21661.txt diff --git a/.changelog/21661.txt b/.changelog/21661.txt new file mode 100644 index 00000000000..3a282d7b0ee --- /dev/null +++ b/.changelog/21661.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_datasync_s3_location: Add validation `agent_arns``, `s3_bucket_arn`` and `s3_config.bucket_access_role_arn`.` +``` \ No newline at end of file From b74234a8d4532db9505f556954dcb59da1a90213 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 8 Nov 2021 11:51:31 -0500 Subject: [PATCH 3/3] Tweak CHANGELOG entry. --- .changelog/21661.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changelog/21661.txt b/.changelog/21661.txt index 3a282d7b0ee..d37f9c67b37 100644 --- a/.changelog/21661.txt +++ b/.changelog/21661.txt @@ -1,3 +1,3 @@ ```release-note:enhancement -resource/aws_datasync_s3_location: Add validation `agent_arns``, `s3_bucket_arn`` and `s3_config.bucket_access_role_arn`.` +resource/aws_datasync_s3_location: Add validation to `agent_arns`, `s3_bucket_arn` and `s3_config.bucket_access_role_arn` arguments ``` \ No newline at end of file