-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20054 from DrFaust92/r/fsx_win_alias
r/fsx_windows_filesystem - support `aliases`
- Loading branch information
Showing
9 changed files
with
332 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:enhancement | ||
resource/fsx_windows_file_system: Add `aliases` argument. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package finder | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/directoryservice" | ||
"github.com/hashicorp/aws-sdk-go-base/tfawserr" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func DirectoryByID(conn *directoryservice.DirectoryService, id string) (*directoryservice.DirectoryDescription, error) { | ||
input := &directoryservice.DescribeDirectoriesInput{ | ||
DirectoryIds: aws.StringSlice([]string{id}), | ||
} | ||
|
||
output, err := conn.DescribeDirectories(input) | ||
|
||
if tfawserr.ErrCodeEquals(err, directoryservice.ErrCodeEntityDoesNotExistException) { | ||
return nil, &resource.NotFoundError{ | ||
LastError: err, | ||
LastRequest: input, | ||
} | ||
} | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if output == nil || len(output.DirectoryDescriptions) == 0 || output.DirectoryDescriptions[0] == nil { | ||
return nil, &resource.NotFoundError{ | ||
Message: "Empty result", | ||
LastRequest: input, | ||
} | ||
} | ||
|
||
// TODO Check for multiple results. | ||
// TODO https://github.com/hashicorp/terraform-provider-aws/pull/17613. | ||
|
||
directory := output.DirectoryDescriptions[0] | ||
|
||
if stage := aws.StringValue(directory.Stage); stage == directoryservice.DirectoryStageDeleted { | ||
return nil, &resource.NotFoundError{ | ||
Message: stage, | ||
LastRequest: input, | ||
} | ||
} | ||
|
||
return directory, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package waiter | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/directoryservice" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/terraform-providers/terraform-provider-aws/aws/internal/service/directoryservice/finder" | ||
"github.com/terraform-providers/terraform-provider-aws/aws/internal/tfresource" | ||
) | ||
|
||
func DirectoryStage(conn *directoryservice.DirectoryService, id string) resource.StateRefreshFunc { | ||
return func() (interface{}, string, error) { | ||
output, err := finder.DirectoryByID(conn, id) | ||
|
||
if tfresource.NotFound(err) { | ||
return nil, "", nil | ||
} | ||
|
||
if err != nil { | ||
return nil, "", err | ||
} | ||
|
||
return output, aws.StringValue(output.Stage), nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package waiter | ||
|
||
import ( | ||
"errors" | ||
"time" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/directoryservice" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/terraform-providers/terraform-provider-aws/aws/internal/tfresource" | ||
) | ||
|
||
const ( | ||
DirectoryCreatedTimeout = 60 * time.Minute | ||
DirectoryDeletedTimeout = 60 * time.Minute | ||
) | ||
|
||
func DirectoryCreated(conn *directoryservice.DirectoryService, id string) (*directoryservice.DirectoryDescription, error) { | ||
stateConf := &resource.StateChangeConf{ | ||
Pending: []string{directoryservice.DirectoryStageRequested, directoryservice.DirectoryStageCreating, directoryservice.DirectoryStageCreated}, | ||
Target: []string{directoryservice.DirectoryStageActive}, | ||
Refresh: DirectoryStage(conn, id), | ||
Timeout: DirectoryCreatedTimeout, | ||
} | ||
|
||
outputRaw, err := stateConf.WaitForState() | ||
|
||
if output, ok := outputRaw.(*directoryservice.DirectoryDescription); ok { | ||
tfresource.SetLastError(err, errors.New(aws.StringValue(output.StageReason))) | ||
|
||
return output, err | ||
} | ||
|
||
return nil, err | ||
} | ||
|
||
func DirectoryDeleted(conn *directoryservice.DirectoryService, id string) (*directoryservice.DirectoryDescription, error) { | ||
stateConf := &resource.StateChangeConf{ | ||
Pending: []string{directoryservice.DirectoryStageActive, directoryservice.DirectoryStageDeleting}, | ||
Target: []string{}, | ||
Refresh: DirectoryStage(conn, id), | ||
Timeout: DirectoryDeletedTimeout, | ||
} | ||
|
||
outputRaw, err := stateConf.WaitForState() | ||
|
||
if output, ok := outputRaw.(*directoryservice.DirectoryDescription); ok { | ||
tfresource.SetLastError(err, errors.New(aws.StringValue(output.StageReason))) | ||
|
||
return output, err | ||
} | ||
|
||
return nil, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.