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

[New Resource] aws_datasync_location_fsx_ontap_file_system #32632

Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
9d6eb8b
Initial WIP commit (not working)
R-Campbell Jul 13, 2023
ea2ab09
update tests and remove tips
R-Campbell Jul 20, 2023
e017f73
update schema and tests
R-Campbell Jul 21, 2023
66832e8
Merge branch 'hashicorp:main' into f-aws_datasync_location_fsx_ontap_…
R-Campbell Jul 21, 2023
cb334d4
Add changelog, fix smb default version
R-Campbell Jul 26, 2023
81ca77a
Merge branch 'main' into HEAD
ewbankkit Aug 17, 2023
de3c847
Add copywrite headers.
ewbankkit Aug 17, 2023
4c67546
Fix semgrep 'ci.caps4-in-func-name '.
ewbankkit Aug 17, 2023
0cfc8da
Fix tfproviderdocs errors.
ewbankkit Aug 17, 2023
5ad0983
Fix documentation terrafmt errors.
ewbankkit Aug 17, 2023
e933f30
Fix acceptance test terrafmt errors.
ewbankkit Aug 17, 2023
64f3cf3
r/aws_datasync_location_fsx_ontap_file_system: Alphabetize attributes.
ewbankkit Aug 18, 2023
9356b32
r/aws_datasync_location_fsx_ontap_file_system: Add 'FindFSxONTAPLocat…
ewbankkit Aug 18, 2023
396f18f
r/aws_datasync_location_fsx_ontap_file_system: Tidy up acceptance tests.
ewbankkit Aug 18, 2023
be32547
r/aws_datasync_agent: Cosmetics.
ewbankkit Aug 18, 2023
e7938bf
'FindFSxONTAPLocationByARN' -> 'FindLocationFSxONTAPByARN'.
ewbankkit Aug 18, 2023
d76990a
r/aws_datasync_location_efs: Alphabetize attributes.
ewbankkit Aug 18, 2023
ad4d886
r/aws_datasync_location_efs: Add and use 'FindLocationEFSByARN'.
ewbankkit Aug 18, 2023
5debf5b
r/aws_datasync_location_fsx_ontap_file_system: Tweak the resource nam…
ewbankkit Aug 18, 2023
93b9412
'FindFSxLustreLocationByARN' -> 'FindLocationFSxLustreByARN'.
ewbankkit Aug 18, 2023
6661e4b
r/aws_datasync_location_fsx_lustre_file_system: Alphabetize attributes.
ewbankkit Aug 18, 2023
be76239
r/aws_datasync_location_fsx_lustre_file_system: Tidy up.
ewbankkit Aug 18, 2023
dd0dced
r/aws_datasync_location_fsx_openzfs_file_system: Alphabetize attributes.
ewbankkit Aug 19, 2023
fa0d042
'FindFSxOpenZFSLocationByARN' -> 'FindLocationFSxOpenZFSByARN'.
ewbankkit Aug 19, 2023
1b60d59
r/aws_datasync_location_fsx_openzfs_file_system: Tidy up.
ewbankkit Aug 19, 2023
d5910ba
'LocationFSxOntap' -> 'LocationFSxONTAP'.
ewbankkit Aug 19, 2023
b690035
r/aws_datasync_location_fsx_windows_file_system: Alphabetize attributes.
ewbankkit Aug 19, 2023
7e64a58
r/aws_datasync_location_fsx_openzfs_file_system: Tidy up acceptance t…
ewbankkit Aug 19, 2023
a517be7
r/aws_datasync_location_fsx_lustre_file_system: Set 'fsx_filesystem_a…
ewbankkit Aug 19, 2023
00b3a58
r/aws_datasync_location_fsx_windows_file_system: Add 'FindLocationFSx…
ewbankkit Aug 19, 2023
4dd2226
r/aws_datasync_location_fsx_windows_file_system: Tidy up acceptance t…
ewbankkit Aug 19, 2023
d375b7c
r/aws_datasync_location_hdfs: Alphabetize attributes.
ewbankkit Aug 19, 2023
2f0a9f8
r/aws_datasync_location_hdfs: Tidy up.
ewbankkit Aug 19, 2023
e8182bf
r/aws_datasync_location_hdfs: Tidy up acceptance tests.
ewbankkit Aug 19, 2023
a1ef474
r/aws_datasync_location_efs: Tidy up acceptance tests.
ewbankkit Aug 20, 2023
1e2bcd2
r/aws_datasync_location_nfs: Tidy up.
ewbankkit Aug 20, 2023
65cfae6
r/aws_datasync_location_object_storage: Alphabetize attributes.
ewbankkit Aug 20, 2023
024d972
r/aws_datasync_location_object_storage: Tidy up.
ewbankkit Aug 20, 2023
9623461
r/aws_datasync_location_s3: Alphabetize attributes.
ewbankkit Aug 20, 2023
69e8df7
r/aws_datasync_location_s3: Tidy up resource Create.
ewbankkit Aug 20, 2023
f78288f
r/aws_datasync_location_s3: Add 'FindLocationS3ByARN'.
ewbankkit Aug 20, 2023
036a3fc
r/aws_datasync_location_s3: Tidy up acceptance tests.
ewbankkit Aug 20, 2023
5c73677
r/aws_datasync_location_smb: Alphabetize attributes.
ewbankkit Aug 20, 2023
51336a0
r/aws_datasync_location_smb: Add 'FindLocationSMBByARN'.
ewbankkit Aug 20, 2023
a2d23c8
r/aws_datasync_location_smb: Tidy up acceptance tests.
ewbankkit Aug 20, 2023
e8df6e0
r/aws_datasync_task: Tidy up.
ewbankkit Aug 20, 2023
1c89ed5
r/aws_datasync_task: Tidy up acceptance tests.
ewbankkit Aug 20, 2023
f65cf2e
Support Azure blob URIs in 'subdirectoryFromLocationURI'.
ewbankkit Aug 20, 2023
f646a0b
r/aws_datasync_location_azure_blob: New resource.
ewbankkit Aug 20, 2023
18bd42b
datasync: Simplify sweepers.
ewbankkit Aug 21, 2023
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
7 changes: 7 additions & 0 deletions .changelog/32632.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:new-resource
aws_datasync_location_fsx_ontap_file_system
```

```release-note:new-resource
aws_datasync_location_azure_blob
```
28 changes: 27 additions & 1 deletion internal/service/datasync/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,9 @@ func resourceAgentCreate(ctx context.Context, d *schema.ResourceData, meta inter
_, err = tfresource.RetryWhenNotFound(ctx, d.Timeout(schema.TimeoutCreate), func() (interface{}, error) {
return FindAgentByARN(ctx, conn, d.Id())
})

if err != nil {
return sdkdiag.AppendErrorf(diags, "waiting for DataSync Agent (%s) creation: %s", d.Id(), err)
return sdkdiag.AppendErrorf(diags, "waiting for DataSync Agent (%s) create: %s", d.Id(), err)
}

return append(diags, resourceAgentRead(ctx, d, meta)...)
Expand Down Expand Up @@ -287,3 +288,28 @@ func resourceAgentDelete(ctx context.Context, d *schema.ResourceData, meta inter

return diags
}

func FindAgentByARN(ctx context.Context, conn *datasync.DataSync, arn string) (*datasync.DescribeAgentOutput, error) {
input := &datasync.DescribeAgentInput{
AgentArn: aws.String(arn),
}

output, err := conn.DescribeAgentWithContext(ctx, input)

if tfawserr.ErrMessageContains(err, datasync.ErrCodeInvalidRequestException, "does not exist") {
return nil, &retry.NotFoundError{
LastError: err,
LastRequest: input,
}
}

if err != nil {
return nil, err
}

if output == nil {
return nil, tfresource.NewEmptyResultError(input)
}

return output, nil
}
22 changes: 12 additions & 10 deletions internal/service/datasync/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,11 @@ func testAccCheckAgentDestroy(ctx context.Context) resource.TestCheckFunc {
}
}

func testAccCheckAgentExists(ctx context.Context, resourceName string, agent *datasync.DescribeAgentOutput) resource.TestCheckFunc {
func testAccCheckAgentExists(ctx context.Context, n string, v *datasync.DescribeAgentOutput) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[resourceName]
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", resourceName)
return fmt.Errorf("Not found: %s", n)
}

conn := acctest.Provider.Meta().(*conns.AWSClient).DataSyncConn(ctx)
Expand All @@ -243,7 +243,7 @@ func testAccCheckAgentExists(ctx context.Context, resourceName string, agent *da
return err
}

*agent = *output
*v = *output

return nil
}
Expand All @@ -260,7 +260,11 @@ func testAccCheckAgentNotRecreated(i, j *datasync.DescribeAgentOutput) resource.
}

func testAccAgentAgentConfig_base(rName string) string {
return acctest.ConfigCompose(acctest.ConfigVPCWithSubnets(rName, 1), fmt.Sprintf(`
return acctest.ConfigCompose(
acctest.ConfigVPCWithSubnets(rName, 1),
// See https://docs.aws.amazon.com/datasync/latest/userguide/agent-requirements.html#ec2-instance-types.
acctest.AvailableEC2InstanceTypeForAvailabilityZone("aws_subnet.test[0].availability_zone", "m5.2xlarge", "m5.4xlarge"),
fmt.Sprintf(`
# Reference: https://docs.aws.amazon.com/datasync/latest/userguide/deploy-agents.html
data "aws_ssm_parameter" "aws_service_datasync_ami" {
name = "/aws/service/datasync/ami"
Expand Down Expand Up @@ -320,11 +324,9 @@ resource "aws_instance" "test" {

ami = data.aws_ssm_parameter.aws_service_datasync_ami.value
associate_public_ip_address = true

# Default instance type from sync.sh
instance_type = "c5.2xlarge"
vpc_security_group_ids = [aws_security_group.test.id]
subnet_id = aws_subnet.test[0].id
instance_type = data.aws_ec2_instance_type_offering.available.instance_type
vpc_security_group_ids = [aws_security_group.test.id]
subnet_id = aws_subnet.test[0].id

tags = {
Name = %[1]q
Expand Down
89 changes: 89 additions & 0 deletions internal/service/datasync/common_fsx_protocol_functions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package datasync

import (
"github.com/aws/aws-sdk-go/service/datasync"
)

func expandProtocol(l []interface{}) *datasync.FsxProtocol {
if len(l) == 0 || l[0] == nil {
return nil
}

m := l[0].(map[string]interface{})

Protocol := &datasync.FsxProtocol{
NFS: expandNFS(m["nfs"].([]interface{})),
SMB: expandSMB(m["smb"].([]interface{})),
}

return Protocol
}

func flattenProtocol(protocol *datasync.FsxProtocol) []interface{} {
if protocol == nil {
return []interface{}{}
}

m := map[string]interface{}{
"nfs": flattenNFS(protocol.NFS),
"smb": flattenSMB(protocol.SMB),
}

return []interface{}{m}
}

func expandNFS(l []interface{}) *datasync.FsxProtocolNfs {
if len(l) == 0 || l[0] == nil {
return nil
}

m := l[0].(map[string]interface{})

Protocol := &datasync.FsxProtocolNfs{
MountOptions: expandNFSMountOptions(m["mount_options"].([]interface{})),
}

return Protocol
}

func expandSMB(l []interface{}) *datasync.FsxProtocolSmb {
if len(l) == 0 || l[0] == nil {
return nil
}

m := l[0].(map[string]interface{})

Protocol := &datasync.FsxProtocolSmb{
MountOptions: expandSMBMountOptions(m["mount_options"].([]interface{})),
}

return Protocol
}

// todo: go another level down?
func flattenNFS(nfs *datasync.FsxProtocolNfs) []interface{} {
if nfs == nil {
return []interface{}{}
}

m := map[string]interface{}{
"mount_options": flattenNFSMountOptions(nfs.MountOptions),
}

return []interface{}{m}
}

func flattenSMB(smb *datasync.FsxProtocolSmb) []interface{} {
if smb == nil {
return []interface{}{}
}

m := map[string]interface{}{
"mount_options": flattenSMBMountOptions(smb.MountOptions),
}

return []interface{}{m}
}
189 changes: 0 additions & 189 deletions internal/service/datasync/find.go

This file was deleted.

Loading
Loading