-
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 #29769 from pschun/f-ssmincidents-replicationset
New Resource and Data source: aws_ssmincidents_replicationset
- Loading branch information
Showing
20 changed files
with
1,733 additions
and
86 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,7 @@ | ||
```release-note:new-resource | ||
aws_ssmincidents_replication_set | ||
``` | ||
|
||
```release-note:new-data-source | ||
aws_ssmincidents_replication_set | ||
``` |
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,36 @@ | ||
package ssmincidents | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
|
||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/aws/aws-sdk-go-v2/service/ssmincidents" | ||
"github.com/aws/aws-sdk-go-v2/service/ssmincidents/types" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-provider-aws/internal/tfresource" | ||
) | ||
|
||
func FindReplicationSetByID(context context.Context, client *ssmincidents.Client, arn string) (*types.ReplicationSet, error) { | ||
input := &ssmincidents.GetReplicationSetInput{ | ||
Arn: aws.String(arn), | ||
} | ||
output, err := client.GetReplicationSet(context, input) | ||
if err != nil { | ||
var notFoundError *types.ResourceNotFoundException | ||
if errors.As(err, ¬FoundError) { | ||
return nil, &resource.NotFoundError{ | ||
LastError: err, | ||
LastRequest: input, | ||
} | ||
} | ||
|
||
return nil, err | ||
} | ||
|
||
if output == nil || output.ReplicationSet == nil { | ||
return nil, tfresource.NewEmptyResultError(input) | ||
} | ||
|
||
return output.ReplicationSet, 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,50 @@ | ||
package ssmincidents | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/aws/aws-sdk-go-v2/service/ssmincidents/types" | ||
) | ||
|
||
func expandRegions(regions []interface{}) map[string]types.RegionMapInputValue { | ||
if len(regions) == 0 { | ||
return nil | ||
} | ||
|
||
regionMap := make(map[string]types.RegionMapInputValue) | ||
for _, region := range regions { | ||
regionData := region.(map[string]interface{}) | ||
|
||
input := types.RegionMapInputValue{} | ||
|
||
if kmsKey := regionData["kms_key_arn"].(string); kmsKey != "DefaultKey" { | ||
input.SseKmsKeyId = aws.String(kmsKey) | ||
} | ||
|
||
regionMap[regionData["name"].(string)] = input | ||
} | ||
|
||
return regionMap | ||
} | ||
|
||
func flattenRegions(regions map[string]types.RegionInfo) []map[string]interface{} { | ||
if len(regions) == 0 { | ||
return nil | ||
} | ||
|
||
tfRegionData := make([]map[string]interface{}, 0) | ||
for regionName, regionData := range regions { | ||
region := make(map[string]interface{}) | ||
|
||
region["name"] = regionName | ||
region["status"] = regionData.Status | ||
region["kms_key_arn"] = aws.ToString(regionData.SseKmsKeyId) | ||
|
||
if v := regionData.StatusMessage; v != nil { | ||
region["status_message"] = aws.ToString(v) | ||
} | ||
|
||
tfRegionData = append(tfRegionData, region) | ||
} | ||
|
||
return tfRegionData | ||
} |
Oops, something went wrong.