-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Resource: aws_route53_key_signing_key
Reference: #16834 Reference: #16836 Output from acceptance testing in AWS Commercial: ``` --- PASS: TestAccAwsRoute53KeySigningKey_disappears (134.60s) --- PASS: TestAccAwsRoute53KeySigningKey_basic (135.34s) --- PASS: TestAccAwsRoute53KeySigningKey_Status (180.85s) ```
- Loading branch information
Showing
10 changed files
with
923 additions
and
0 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,9 @@ | ||
package route53 | ||
|
||
const ( | ||
KeySigningKeyStatusActionNeeded = "ACTION_NEEDED" | ||
KeySigningKeyStatusActive = "ACTIVE" | ||
KeySigningKeyStatusDeleting = "DELETING" | ||
KeySigningKeyStatusInactive = "INACTIVE" | ||
KeySigningKeyStatusInternalFailure = "INTERNAL_FAILURE" | ||
) |
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 finder | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/route53" | ||
tfroute53 "github.com/terraform-providers/terraform-provider-aws/aws/internal/service/route53" | ||
) | ||
|
||
func KeySigningKey(conn *route53.Route53, hostedZoneID string, name string) (*route53.KeySigningKey, error) { | ||
input := &route53.GetDNSSECInput{ | ||
HostedZoneId: aws.String(hostedZoneID), | ||
} | ||
|
||
var result *route53.KeySigningKey | ||
|
||
output, err := conn.GetDNSSEC(input) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if output == nil { | ||
return nil, nil | ||
} | ||
|
||
for _, keySigningKey := range output.KeySigningKeys { | ||
if keySigningKey == nil { | ||
continue | ||
} | ||
|
||
if aws.StringValue(keySigningKey.Name) == name { | ||
result = keySigningKey | ||
break | ||
} | ||
} | ||
|
||
return result, err | ||
} | ||
|
||
func KeySigningKeyByResourceID(conn *route53.Route53, resourceID string) (*route53.KeySigningKey, error) { | ||
hostedZoneID, name, err := tfroute53.KeySigningKeyParseResourceID(resourceID) | ||
|
||
if err != nil { | ||
return nil, fmt.Errorf("error parsing Route 53 Key Signing Key (%s) identifier: %w", resourceID, err) | ||
} | ||
|
||
return KeySigningKey(conn, hostedZoneID, name) | ||
} |
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 route53 | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
const KeySigningKeyResourceIDSeparator = "," | ||
|
||
func KeySigningKeyCreateResourceID(transitGatewayRouteTableID string, prefixListID string) string { | ||
parts := []string{transitGatewayRouteTableID, prefixListID} | ||
id := strings.Join(parts, KeySigningKeyResourceIDSeparator) | ||
|
||
return id | ||
} | ||
|
||
func KeySigningKeyParseResourceID(id string) (string, string, error) { | ||
parts := strings.Split(id, KeySigningKeyResourceIDSeparator) | ||
|
||
if len(parts) == 2 && parts[0] != "" && parts[1] != "" { | ||
return parts[0], parts[1], nil | ||
} | ||
|
||
return "", "", fmt.Errorf("unexpected format for ID (%[1]s), expected hosted-zone-id%[2]sname", id, KeySigningKeyResourceIDSeparator) | ||
} |
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,44 @@ | ||
package waiter | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/route53" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/terraform-providers/terraform-provider-aws/aws/internal/service/route53/finder" | ||
) | ||
|
||
func ChangeInfoStatus(conn *route53.Route53, changeID string) resource.StateRefreshFunc { | ||
return func() (interface{}, string, error) { | ||
input := &route53.GetChangeInput{ | ||
Id: aws.String(changeID), | ||
} | ||
|
||
output, err := conn.GetChange(input) | ||
|
||
if err != nil { | ||
return nil, "", err | ||
} | ||
|
||
if output == nil || output.ChangeInfo == nil { | ||
return nil, "", nil | ||
} | ||
|
||
return output.ChangeInfo, aws.StringValue(output.ChangeInfo.Status), nil | ||
} | ||
} | ||
|
||
func KeySigningKeyStatus(conn *route53.Route53, hostedZoneID string, name string) resource.StateRefreshFunc { | ||
return func() (interface{}, string, error) { | ||
keySigningKey, err := finder.KeySigningKey(conn, hostedZoneID, name) | ||
|
||
if err != nil { | ||
return nil, "", err | ||
} | ||
|
||
if keySigningKey == nil { | ||
return nil, "", nil | ||
} | ||
|
||
return keySigningKey, aws.StringValue(keySigningKey.Status), 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,67 @@ | ||
package waiter | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/route53" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
const ( | ||
ChangeTimeout = 30 * time.Minute | ||
|
||
KeySigningKeyStatusTimeout = 5 * time.Minute | ||
) | ||
|
||
func ChangeInfoStatusInsync(conn *route53.Route53, changeID string) (*route53.ChangeInfo, error) { | ||
stateConf := &resource.StateChangeConf{ | ||
Pending: []string{route53.ChangeStatusPending}, | ||
Target: []string{route53.ChangeStatusInsync}, | ||
Refresh: ChangeInfoStatus(conn, changeID), | ||
Delay: 30 * time.Second, | ||
MinTimeout: 5 * time.Second, | ||
Timeout: ChangeTimeout, | ||
} | ||
|
||
outputRaw, err := stateConf.WaitForState() | ||
|
||
if output, ok := outputRaw.(*route53.ChangeInfo); ok { | ||
return output, err | ||
} | ||
|
||
return nil, err | ||
} | ||
|
||
func KeySigningKeyStatusUpdated(conn *route53.Route53, hostedZoneID string, name string, status string) (*route53.KeySigningKey, error) { | ||
stateConf := &resource.StateChangeConf{ | ||
Target: []string{status}, | ||
Refresh: KeySigningKeyStatus(conn, hostedZoneID, name), | ||
MinTimeout: 5 * time.Second, | ||
Timeout: KeySigningKeyStatusTimeout, | ||
} | ||
|
||
outputRaw, err := stateConf.WaitForState() | ||
|
||
if output, ok := outputRaw.(*route53.KeySigningKey); ok { | ||
if err != nil && output != nil && output.Status != nil && output.StatusMessage != nil { | ||
newErr := fmt.Errorf("%s: %s", aws.StringValue(output.Status), aws.StringValue(output.StatusMessage)) | ||
|
||
switch e := err.(type) { | ||
case *resource.TimeoutError: | ||
if e.LastError == nil { | ||
e.LastError = newErr | ||
} | ||
case *resource.UnexpectedStateError: | ||
if e.LastError == nil { | ||
e.LastError = newErr | ||
} | ||
} | ||
} | ||
|
||
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.