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

add ssm contacts rotation resource and data source #32710

Merged
merged 27 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c1490d7
add ssm contacts rotation resource and data source
jimfkong Jul 14, 2023
02fe3b2
Merge branch 'main' into f-aws_ssmcontacts_rotations
johnsonaj Dec 20, 2023
86dd6c9
aws_ssmcontacts_rotation: convert to framework
johnsonaj Dec 22, 2023
3be72a7
Merge branch 'main' into f-aws_ssmcontacts_rotations
johnsonaj Jan 24, 2024
f6e10b4
aws_ssmcontacts_rotation: getting autoflex working
johnsonaj Jan 25, 2024
222b18e
aws_ssmcontacts_rotation: cleanup
johnsonaj Jan 25, 2024
6a9637f
rename file
johnsonaj Jan 25, 2024
28176c7
fmt tests
johnsonaj Jan 25, 2024
95cd56a
chore: cleanup
johnsonaj Jan 25, 2024
f9592dc
Merge branch 'main' into f-aws_ssmcontacts_rotations
johnsonaj Jan 25, 2024
02f4d3b
liters
johnsonaj Jan 25, 2024
4cd57c8
add copyright headers
johnsonaj Jan 25, 2024
9739ad1
add copyright headers
johnsonaj Jan 25, 2024
e087ce7
Merge branch 'main' into f-aws_ssmcontacts_rotations
johnsonaj Jan 25, 2024
192128c
aws_rekognition_project: testing
johnsonaj Jan 25, 2024
3d7192b
aws_ssmcontacts_rotation: make tests serial
johnsonaj Jan 31, 2024
da53f49
Merge branch 'main' into f-aws_ssmcontacts_rotations
johnsonaj Jan 31, 2024
955a45a
aws_ssmcontacts_rotation: datasource to framework
johnsonaj Jan 31, 2024
49157c9
aws_ssmcontacts_rotation: tweak datasource tests
johnsonaj Jan 31, 2024
432fdd3
rename files
johnsonaj Jan 31, 2024
55e1e97
fmt resource docs
johnsonaj Jan 31, 2024
36a0420
fmt resource docs
johnsonaj Jan 31, 2024
4e55973
fix document linter
johnsonaj Jan 31, 2024
174a528
fix document linter
johnsonaj Jan 31, 2024
7979c59
remove unused code
johnsonaj Jan 31, 2024
2f87313
add tags test
johnsonaj Jan 31, 2024
1ef9e89
add CHANGELOG entry
johnsonaj Jan 31, 2024
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/32710.txt
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
```
18 changes: 18 additions & 0 deletions internal/framework/flex/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ func Int32ToFramework(ctx context.Context, v *int32) types.Int64 {
return output
}

func Int32ValueToFramework(ctx context.Context, v int32) types.Int64 {
var output types.Int64

panicOnError(Flatten(ctx, v, &output))

return output
}

// Int32FromFramework coverts a Framework Int64 value to an int32 pointer.
// A null Int64 is converted to a nil int32 pointer.
func Int32FromFramework(ctx context.Context, v types.Int64) *int32 {
Expand All @@ -67,3 +75,13 @@ func Int32FromFramework(ctx context.Context, v types.Int64) *int32 {

return output
}

// Int32ValueFromFramework coverts a Framework Int64 value to an int32 pointer.
// A null Int64 is converted to a nil int32 pointer.
func Int32ValueFromFramework(ctx context.Context, v types.Int64) int32 {
var output int32

panicOnError(Expand(ctx, v, &output))

return output
}
14 changes: 14 additions & 0 deletions internal/service/ssmcontacts/exports_test.go
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
)
65 changes: 65 additions & 0 deletions internal/service/ssmcontacts/planmodifiers.go
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)
}
Loading
Loading