-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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 #32710 from jimfkong/f-aws_ssmcontacts_rotations
add ssm contacts rotation resource and data source
- Loading branch information
Showing
15 changed files
with
2,578 additions
and
2 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_ssmcontacts_rotation | ||
``` | ||
|
||
```release-note:new-data-source | ||
aws_ssmcontacts_rotation | ||
``` |
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,14 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package ssmcontacts | ||
|
||
// Exports for use in tests only. | ||
|
||
var ( | ||
ResourceRotation = newResourceRotation | ||
) | ||
|
||
var ( | ||
FindRotationByID = findRotationByID | ||
) |
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,65 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package ssmcontacts | ||
|
||
import ( | ||
"context" | ||
"sort" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" | ||
) | ||
|
||
var _ planmodifier.List = shiftCoveragesPlanModifier{} | ||
|
||
func ShiftCoveragesPlanModifier() planmodifier.List { | ||
return &shiftCoveragesPlanModifier{} | ||
} | ||
|
||
type shiftCoveragesPlanModifier struct{} | ||
|
||
func (s shiftCoveragesPlanModifier) PlanModifyList(ctx context.Context, req planmodifier.ListRequest, resp *planmodifier.ListResponse) { | ||
if req.PlanValue.IsNull() { | ||
return | ||
} | ||
|
||
if req.PlanValue.IsUnknown() { | ||
return | ||
} | ||
|
||
if req.ConfigValue.IsUnknown() { | ||
return | ||
} | ||
|
||
var plan, state []shiftCoveragesData | ||
resp.Diagnostics.Append(req.PlanValue.ElementsAs(ctx, &plan, false)...) | ||
resp.Diagnostics.Append(req.StateValue.ElementsAs(ctx, &state, false)...) | ||
|
||
req.PlanValue.ElementsAs(ctx, &plan, false) | ||
if resp.Diagnostics.HasError() { | ||
return | ||
} | ||
|
||
sort.Slice(plan, func(i, j int) bool { | ||
return plan[i].MapBlockKey.ValueString() < plan[j].MapBlockKey.ValueString() | ||
}) | ||
|
||
sort.Slice(state, func(i, j int) bool { | ||
return state[i].MapBlockKey.ValueString() < state[j].MapBlockKey.ValueString() | ||
}) | ||
|
||
isEqual := cmp.Diff(plan, state) == "" | ||
|
||
if isEqual { | ||
resp.PlanValue = req.StateValue | ||
} | ||
} | ||
|
||
func (s shiftCoveragesPlanModifier) Description(_ context.Context) string { | ||
return "Suppress diff for shift_coverages" | ||
} | ||
|
||
func (s shiftCoveragesPlanModifier) MarkdownDescription(ctx context.Context) string { | ||
return s.Description(ctx) | ||
} |
Oops, something went wrong.