Skip to content

Commit

Permalink
Merge pull request #18547 from gazoakley/f-datasync-s3-attrs
Browse files Browse the repository at this point in the history
resource/aws_datasync_location_s3: Add `agent_arns` and `s3_storage_class` arguments
  • Loading branch information
ewbankkit authored May 13, 2021
2 parents ab69a9b + 7b0faba commit 17f20df
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/18547.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_datasync_location_s3: Add `agent_arns` argument
```
15 changes: 12 additions & 3 deletions aws/resource_aws_datasync_location_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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))
}
Expand Down Expand Up @@ -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())

Expand Down
2 changes: 2 additions & 0 deletions aws/resource_aws_datasync_location_s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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://.+/`)),
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/datasync_location_s3.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 17f20df

Please sign in to comment.