diff --git a/.changelog/18547.txt b/.changelog/18547.txt new file mode 100644 index 00000000000..eaac1d3a5a1 --- /dev/null +++ b/.changelog/18547.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_datasync_location_s3: Add `agent_arns` argument +``` \ No newline at end of file diff --git a/aws/resource_aws_datasync_location_s3.go b/aws/resource_aws_datasync_location_s3.go index 37723572fbc..8fa5bf11f88 100644 --- a/aws/resource_aws_datasync_location_s3.go +++ b/aws/resource_aws_datasync_location_s3.go @@ -29,6 +29,12 @@ func resourceAwsDataSyncLocationS3() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "agent_arns": { + Type: schema.TypeSet, + Optional: true, + ForceNew: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, "s3_bucket_arn": { Type: schema.TypeString, Required: true, @@ -97,6 +103,10 @@ func resourceAwsDataSyncLocationS3Create(d *schema.ResourceData, meta interface{ Tags: tags.IgnoreAws().DatasyncTags(), } + if v, ok := d.GetOk("agent_arns"); ok { + input.AgentArns = expandStringSet(v.(*schema.Set)) + } + if v, ok := d.GetOk("s3_storage_class"); ok { input.S3StorageClass = aws.String(v.(string)) } @@ -168,15 +178,14 @@ func resourceAwsDataSyncLocationS3Read(d *schema.ResourceData, meta interface{}) return fmt.Errorf("error parsing Location S3 (%s) URI (%s): %s", d.Id(), aws.StringValue(output.LocationUri), err) } + d.Set("agent_arns", flattenStringSet(output.AgentArns)) d.Set("arn", output.LocationArn) - if err := d.Set("s3_config", flattenDataSyncS3Config(output.S3Config)); err != nil { return fmt.Errorf("error setting s3_config: %s", err) } - + d.Set("s3_storage_class", output.S3StorageClass) d.Set("subdirectory", subdirectory) d.Set("uri", output.LocationUri) - d.Set("s3_storage_class", output.S3StorageClass) tags, err := keyvaluetags.DatasyncListTags(conn, d.Id()) diff --git a/aws/resource_aws_datasync_location_s3_test.go b/aws/resource_aws_datasync_location_s3_test.go index e38060a8c16..f6262a0eed2 100644 --- a/aws/resource_aws_datasync_location_s3_test.go +++ b/aws/resource_aws_datasync_location_s3_test.go @@ -96,10 +96,12 @@ func TestAccAWSDataSyncLocationS3_basic(t *testing.T) { Config: testAccAWSDataSyncLocationS3Config(rName), Check: resource.ComposeTestCheckFunc( testAccCheckAWSDataSyncLocationS3Exists(resourceName, &locationS31), + resource.TestCheckResourceAttr(resourceName, "agent_arns.#", "0"), testAccMatchResourceAttrRegionalARN(resourceName, "arn", "datasync", regexp.MustCompile(`location/loc-.+`)), resource.TestCheckResourceAttrPair(resourceName, "s3_bucket_arn", s3BucketResourceName, "arn"), resource.TestCheckResourceAttr(resourceName, "s3_config.#", "1"), resource.TestCheckResourceAttrPair(resourceName, "s3_config.0.bucket_access_role_arn", iamRoleResourceName, "arn"), + resource.TestCheckResourceAttrSet(resourceName, "s3_storage_class"), resource.TestCheckResourceAttr(resourceName, "subdirectory", "/test/"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestMatchResourceAttr(resourceName, "uri", regexp.MustCompile(`^s3://.+/`)), diff --git a/website/docs/r/datasync_location_s3.html.markdown b/website/docs/r/datasync_location_s3.html.markdown index 7c20aef3921..61b3ebe0847 100644 --- a/website/docs/r/datasync_location_s3.html.markdown +++ b/website/docs/r/datasync_location_s3.html.markdown @@ -27,6 +27,7 @@ resource "aws_datasync_location_s3" "example" { The following arguments are supported: +* `agent_arns` - (Optional) A list of DataSync Agent ARNs with which this location will be associated. * `s3_bucket_arn` - (Required) Amazon Resource Name (ARN) of the S3 Bucket. * `s3_config` - (Required) Configuration block containing information for connecting to S3. * `s3_storage_class` - (Optional) The Amazon S3 storage class that you want to store your files in when this location is used as a task destination. [Valid values](https://docs.aws.amazon.com/datasync/latest/userguide/create-s3-location.html#using-storage-classes)