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 recovery control config resources #20568

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
46577ef
Add recovery control config resources
Aug 14, 2021
50d6041
Adding changelog
Aug 14, 2021
d6423af
Fix markdown issues
Aug 16, 2021
6c842c8
Fixing import
Aug 16, 2021
5e860ad
Try fixing errors
Aug 16, 2021
25f8e6a
Fix linter errors
Aug 17, 2021
bddf501
Fix linters
Aug 17, 2021
b558d79
flatten cluster_endpoints
Aug 17, 2021
ea18903
Add safety rule resource
Aug 18, 2021
732a9e5
linter fix
Aug 18, 2021
d85133e
linters
Aug 18, 2021
259808c
Fix issues
Aug 18, 2021
f4a44c2
fix fmt error
Aug 18, 2021
bf66879
Add acceptance tests
Aug 19, 2021
4c9ba20
Fixing terrafmt linters
Aug 19, 2021
2a09df8
fix linter
Aug 19, 2021
8f5ca03
Update RC tests
Aug 20, 2021
01ad698
make fmt
Aug 20, 2021
2ce8232
Add safety rule test
Aug 23, 2021
35f44ef
r/route53rcc_cluster: Fix resource
YakDriver Aug 24, 2021
560cad8
tests/r/route53rcc_cluster: Fix tests
YakDriver Aug 24, 2021
c453bf3
tests/r/route53rcc_control_panel: Fix resource
YakDriver Aug 24, 2021
376bd43
tests/r/route53rcc_control_panel: Fix tests
YakDriver Aug 24, 2021
1449a56
r/route53rcc_routing_control: Fix resource
YakDriver Aug 24, 2021
dd4fae9
tests/r/route53rcc_routing_control: Fix tests
YakDriver Aug 24, 2021
61d7d09
r/route53rcc_safety_rule: Fix resource
YakDriver Aug 24, 2021
de71e32
tests/r/route53rcc_safety_rule: Fix tests
YakDriver Aug 24, 2021
b387ebb
tests/r/route53rcc: Switch to serial tests
YakDriver Aug 24, 2021
47c4a6e
tests/r/route53rcc_safety_rule: Linty
YakDriver Aug 24, 2021
dbfb397
tests/r/r53rcc: All serial all the time
YakDriver Aug 24, 2021
7f6422c
Fix typos
YakDriver Aug 24, 2021
0542f69
i/r/r53rcc_status: Clean up status
YakDriver Aug 24, 2021
b630b8c
i/r/r53rcc_status: Clean up waiter
YakDriver Aug 24, 2021
f804852
r53rcc: Refactor imports, internal
YakDriver Aug 24, 2021
5e6efb6
docs/r/r53rcc_cluster: Fixup docs
YakDriver Aug 24, 2021
b6c340e
docs/r/r53rcc_control_panel: Fixup docs
YakDriver Aug 24, 2021
854f84d
docs/r/r53rcc_routing_control: Fixup docs
YakDriver Aug 24, 2021
37c11ae
docs/r/r53rcc_safety_rule: Fixup docs
YakDriver Aug 24, 2021
1086f12
docs/r/r53rcc_safety_rule: Fixup docs
YakDriver Aug 24, 2021
c3f575e
docs/r/r53rcc_safety_rule: Fixup docs
YakDriver Aug 24, 2021
28ad18a
tests/r53rcc: Add precheck
YakDriver Aug 24, 2021
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
15 changes: 15 additions & 0 deletions .changelog/20568.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```release-note:new-resource
aws_route53recoverycontrolconfig_cluster
```

```release-note:new-resource
aws_route53recoverycontrolconfig_control_panel
```

```release-note:new-resource
aws_route53recoverycontrolconfig_routing_control
```

```release-note:new-resource
aws_route53recoverycontrolconfig_safety_rule
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package waiter

import (
"github.com/aws/aws-sdk-go/aws"
r53rcc "github.com/aws/aws-sdk-go/service/route53recoverycontrolconfig"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func Route53RecoveryControlConfigClusterStatus(conn *r53rcc.Route53RecoveryControlConfig, clusterArn string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
input := &r53rcc.DescribeClusterInput{
ClusterArn: aws.String(clusterArn),
}

output, err := conn.DescribeCluster(input)

if err != nil {
return output, "", err
}

return output, aws.StringValue(output.Cluster.Status), nil
}
}

func Route53RecoveryControlConfigRoutingControlStatus(conn *r53rcc.Route53RecoveryControlConfig, routingControlArn string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
input := &r53rcc.DescribeRoutingControlInput{
RoutingControlArn: aws.String(routingControlArn),
}

output, err := conn.DescribeRoutingControl(input)

if err != nil {
return output, "", err
}

return output, aws.StringValue(output.RoutingControl.Status), nil
}
}

func Route53RecoveryControlConfigControlPanelStatus(conn *r53rcc.Route53RecoveryControlConfig, controlPanelArn string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
input := &r53rcc.DescribeControlPanelInput{
ControlPanelArn: aws.String(controlPanelArn),
}

output, err := conn.DescribeControlPanel(input)

if err != nil {
return output, "", err
}

return output, aws.StringValue(output.ControlPanel.Status), nil
}
}

func Route53RecoveryControlConfigSafetyRuleStatus(conn *r53rcc.Route53RecoveryControlConfig, safetyRuleArn string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
input := &r53rcc.DescribeSafetyRuleInput{
SafetyRuleArn: aws.String(safetyRuleArn),
}

output, err := conn.DescribeSafetyRule(input)

if err != nil {
return output, "", err
}

if output.AssertionRule != nil {
return output, aws.StringValue(output.AssertionRule.Status), nil
}

if output.GatingRule != nil {
return output, aws.StringValue(output.GatingRule.Status), nil
}

return output, "", nil
}
}
161 changes: 161 additions & 0 deletions aws/internal/service/route53recoverycontrolconfig/waiter/waiter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
package waiter

import (
"time"

r53rcc "github.com/aws/aws-sdk-go/service/route53recoverycontrolconfig"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

const (
Route53RecoveryControlConfigTimeout = 60 * time.Second
Route53RecoveryControlConfigMinTimeout = 5 * time.Second
)

func Route53RecoveryControlConfigClusterCreated(conn *r53rcc.Route53RecoveryControlConfig, clusterArn string) (*r53rcc.DescribeClusterOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{r53rcc.StatusPending},
Target: []string{r53rcc.StatusDeployed},
Refresh: Route53RecoveryControlConfigClusterStatus(conn, clusterArn),
Timeout: Route53RecoveryControlConfigTimeout,
MinTimeout: Route53RecoveryControlConfigMinTimeout,
}

outputRaw, err := stateConf.WaitForState()

if output, ok := outputRaw.(*r53rcc.DescribeClusterOutput); ok {
return output, err
}

return nil, err
}

func Route53RecoveryControlConfigClusterDeleted(conn *r53rcc.Route53RecoveryControlConfig, clusterArn string) (*r53rcc.DescribeClusterOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{r53rcc.StatusPendingDeletion},
Target: []string{},
Refresh: Route53RecoveryControlConfigClusterStatus(conn, clusterArn),
Timeout: Route53RecoveryControlConfigTimeout,
Delay: Route53RecoveryControlConfigMinTimeout,
NotFoundChecks: 1,
}

outputRaw, err := stateConf.WaitForState()

if output, ok := outputRaw.(*r53rcc.DescribeClusterOutput); ok {
return output, err
}

return nil, err
}

func Route53RecoveryControlConfigRoutingControlCreated(conn *r53rcc.Route53RecoveryControlConfig, routingControlArn string) (*r53rcc.DescribeRoutingControlOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{r53rcc.StatusPending},
Target: []string{r53rcc.StatusDeployed},
Refresh: Route53RecoveryControlConfigRoutingControlStatus(conn, routingControlArn),
Timeout: Route53RecoveryControlConfigTimeout,
MinTimeout: Route53RecoveryControlConfigMinTimeout,
}

outputRaw, err := stateConf.WaitForState()

if output, ok := outputRaw.(*r53rcc.DescribeRoutingControlOutput); ok {
return output, err
}

return nil, err
}

func Route53RecoveryControlConfigRoutingControlDeleted(conn *r53rcc.Route53RecoveryControlConfig, routingControlArn string) (*r53rcc.DescribeRoutingControlOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{r53rcc.StatusPendingDeletion},
Target: []string{},
Refresh: Route53RecoveryControlConfigRoutingControlStatus(conn, routingControlArn),
Timeout: Route53RecoveryControlConfigTimeout,
Delay: Route53RecoveryControlConfigMinTimeout,
NotFoundChecks: 1,
}

outputRaw, err := stateConf.WaitForState()

if output, ok := outputRaw.(*r53rcc.DescribeRoutingControlOutput); ok {
return output, err
}

return nil, err
}

func Route53RecoveryControlConfigControlPanelCreated(conn *r53rcc.Route53RecoveryControlConfig, controlPanelArn string) (*r53rcc.DescribeControlPanelOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{r53rcc.StatusPending},
Target: []string{r53rcc.StatusDeployed},
Refresh: Route53RecoveryControlConfigControlPanelStatus(conn, controlPanelArn),
Timeout: Route53RecoveryControlConfigTimeout,
MinTimeout: Route53RecoveryControlConfigMinTimeout,
}

outputRaw, err := stateConf.WaitForState()

if output, ok := outputRaw.(*r53rcc.DescribeControlPanelOutput); ok {
return output, err
}

return nil, err
}

func Route53RecoveryControlConfigControlPanelDeleted(conn *r53rcc.Route53RecoveryControlConfig, controlPanelArn string) (*r53rcc.DescribeControlPanelOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{r53rcc.StatusPendingDeletion},
Target: []string{},
Refresh: Route53RecoveryControlConfigControlPanelStatus(conn, controlPanelArn),
Timeout: Route53RecoveryControlConfigTimeout,
Delay: Route53RecoveryControlConfigMinTimeout,
NotFoundChecks: 1,
}

outputRaw, err := stateConf.WaitForState()

if output, ok := outputRaw.(*r53rcc.DescribeControlPanelOutput); ok {
return output, err
}

return nil, err
}

func Route53RecoveryControlConfigSafetyRuleCreated(conn *r53rcc.Route53RecoveryControlConfig, safetyRuleArn string) (*r53rcc.DescribeSafetyRuleOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{r53rcc.StatusPending},
Target: []string{r53rcc.StatusDeployed},
Refresh: Route53RecoveryControlConfigSafetyRuleStatus(conn, safetyRuleArn),
Timeout: Route53RecoveryControlConfigTimeout,
MinTimeout: Route53RecoveryControlConfigMinTimeout,
}

outputRaw, err := stateConf.WaitForState()

if output, ok := outputRaw.(*r53rcc.DescribeSafetyRuleOutput); ok {
return output, err
}

return nil, err
}

func Route53RecoveryControlConfigSafetyRuleDeleted(conn *r53rcc.Route53RecoveryControlConfig, safetyRuleArn string) (*r53rcc.DescribeSafetyRuleOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{r53rcc.StatusPendingDeletion},
Target: []string{},
Refresh: Route53RecoveryControlConfigSafetyRuleStatus(conn, safetyRuleArn),
Timeout: Route53RecoveryControlConfigTimeout,
Delay: Route53RecoveryControlConfigMinTimeout,
NotFoundChecks: 1,
}

outputRaw, err := stateConf.WaitForState()

if output, ok := outputRaw.(*r53rcc.DescribeSafetyRuleOutput); ok {
return output, err
}

return nil, err
}
4 changes: 4 additions & 0 deletions aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,10 @@ func Provider() *schema.Provider {
"aws_route53_resolver_query_log_config_association": resourceAwsRoute53ResolverQueryLogConfigAssociation(),
"aws_route53_resolver_rule_association": resourceAwsRoute53ResolverRuleAssociation(),
"aws_route53_resolver_rule": resourceAwsRoute53ResolverRule(),
"aws_route53recoverycontrolconfig_cluster": resourceAwsRoute53RecoveryControlConfigCluster(),
"aws_route53recoverycontrolconfig_control_panel": resourceAwsRoute53RecoveryControlConfigControlPanel(),
"aws_route53recoverycontrolconfig_routing_control": resourceAwsRoute53RecoveryControlConfigRoutingControl(),
"aws_route53recoverycontrolconfig_safety_rule": resourceAwsRoute53RecoveryControlConfigSafetyRule(),
"aws_route53recoveryreadiness_cell": resourceAwsRoute53RecoveryReadinessCell(),
"aws_route53recoveryreadiness_readiness_check": resourceAwsRoute53RecoveryReadinessReadinessCheck(),
"aws_route53recoveryreadiness_recovery_group": resourceAwsRoute53RecoveryReadinessRecoveryGroup(),
Expand Down
Loading