Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F/resource aws datasync location s3 storage class #19190

Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
568483c
f/aws_securityhub_member: email is optional variable
nikhil-goenka Apr 22, 2021
5273c73
f/aws_securityhub_member: email is optional variable
nikhil-goenka Apr 25, 2021
f2c5be9
f/aws_securityhub_member: email is optional variable
nikhil-goenka Apr 22, 2021
1e48317
f/aws_securityhub_member: email is optional variable
nikhil-goenka Apr 25, 2021
29747b7
Merge remote-tracking branch 'origin/master'
nikhil-goenka Apr 30, 2021
98e41ce
f/aws_securityhub_member: email is optional variable
nikhil-goenka Apr 22, 2021
598e773
f/aws_securityhub_member: email is optional variable
nikhil-goenka Apr 25, 2021
15ec17c
f/aws_securityhub_member: email is optional variable
nikhil-goenka Apr 22, 2021
bc225f5
f/aws_securityhub_member: email is optional variable
nikhil-goenka Apr 25, 2021
e1724ca
Merge remote-tracking branch 'origin/master'
nikhil-goenka May 1, 2021
914367c
f/resource_aws_datasync_location_s3
nikhil-goenka May 1, 2021
2efebe6
f/resource_aws_datasync_location_s3
nikhil-goenka May 1, 2021
d812024
f/resource_aws_datasync_location_s3
nikhil-goenka May 1, 2021
fd15a63
f/resource_aws_datasync_location_s3
nikhil-goenka May 4, 2021
97eb9dc
resource/aws_elasticache_global_replication_group: Remove deprecated …
nikhil-goenka May 4, 2021
6ce1e85
resource/aws_elasticache_global_replication_group: Remove deprecated …
nikhil-goenka May 4, 2021
230b1d4
resource/aws_elasticache_global_replication_group: Remove deprecated …
nikhil-goenka May 4, 2021
d541d46
Update website/docs/r/datasync_location_s3.html.markdown
ewbankkit May 4, 2021
3bdf011
Add CHANGELOG entry.
ewbankkit May 4, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions aws/resource_aws_datasync_location_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ func resourceAwsDataSyncLocationS3() *schema.Resource {
},
},
},
"s3_storage_class": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice(datasync.S3StorageClass_Values(), false),
},
"subdirectory": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -90,6 +97,10 @@ func resourceAwsDataSyncLocationS3Create(d *schema.ResourceData, meta interface{
Tags: tags.IgnoreAws().DatasyncTags(),
}

if v, ok := d.GetOk("s3_storage_class"); ok {
input.S3StorageClass = aws.String(v.(string))
}

log.Printf("[DEBUG] Creating DataSync Location S3: %s", input)

var output *datasync.CreateLocationS3Output
Expand Down Expand Up @@ -165,6 +176,7 @@ func resourceAwsDataSyncLocationS3Read(d *schema.ResourceData, meta interface{})

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
52 changes: 52 additions & 0 deletions aws/resource_aws_datasync_location_s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,42 @@ func TestAccAWSDataSyncLocationS3_basic(t *testing.T) {
})
}

func TestAccAWSDataSyncLocationS3_storageclass(t *testing.T) {
var locationS31 datasync.DescribeLocationS3Output
rName := acctest.RandomWithPrefix("tf-acc-test")
iamRoleResourceName := "aws_iam_role.test"
resourceName := "aws_datasync_location_s3.test"
s3BucketResourceName := "aws_s3_bucket.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSDataSync(t) },
ErrorCheck: testAccErrorCheck(t, datasync.EndpointsID),
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSDataSyncLocationS3Destroy,
Steps: []resource.TestStep{
{
Config: testAccAWSDataSyncLocationS3ConfigStorageClass(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDataSyncLocationS3Exists(resourceName, &locationS31),
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.TestCheckResourceAttr(resourceName, "subdirectory", "/test/"),
resource.TestCheckResourceAttr(resourceName, "s3_storage_class", "STANDARD_IA"),
resource.TestMatchResourceAttr(resourceName, "uri", regexp.MustCompile(`^s3://.+/`)),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"s3_bucket_arn"},
},
},
})
}

func TestAccAWSDataSyncLocationS3_disappears(t *testing.T) {
var locationS31 datasync.DescribeLocationS3Output
rName := acctest.RandomWithPrefix("tf-acc-test")
Expand Down Expand Up @@ -326,6 +362,22 @@ resource "aws_datasync_location_s3" "test" {
`
}

func testAccAWSDataSyncLocationS3ConfigStorageClass(rName string) string {
return testAccAWSDataSyncLocationS3ConfigBase(rName) + `
resource "aws_datasync_location_s3" "test" {
s3_bucket_arn = aws_s3_bucket.test.arn
subdirectory = "/test"
s3_storage_class = "STANDARD_IA"

s3_config {
bucket_access_role_arn = aws_iam_role.test.arn
}

depends_on = [aws_iam_role_policy.test]
}
`
}

func testAccAWSDataSyncLocationS3ConfigTags1(rName, key1, value1 string) string {
return testAccAWSDataSyncLocationS3ConfigBase(rName) + fmt.Sprintf(`
resource "aws_datasync_location_s3" "test" {
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 @@ -29,6 +29,7 @@ The following arguments are supported:

* `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)
* `subdirectory` - (Required) Prefix to perform actions as source or destination.
* `tags` - (Optional) Key-value pairs of resource tags to assign to the DataSync Location. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level.

Expand Down