-
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.
service/acmpca: Add activation of ACMPCA CA to acceptance tests (#13684)
* r/aws_acmpca_certificate_authority: Test CA activation. Acceptance test output: $ make testacc TEST=./aws/ TESTARGS='-run=TestAccAwsAcmpcaCertificateAuthority_Enabled' ==> Checking that code complies with gofmt requirements... TF_ACC=1 go test ./aws/ -v -count 1 -parallel 20 -run=TestAccAwsAcmpcaCertificateAuthority_Enabled -timeout 120m === RUN TestAccAwsAcmpcaCertificateAuthority_Enabled === PAUSE TestAccAwsAcmpcaCertificateAuthority_Enabled === CONT TestAccAwsAcmpcaCertificateAuthority_Enabled --- PASS: TestAccAwsAcmpcaCertificateAuthority_Enabled (69.95s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 69.989s Add 'TestAccAwsAcmpcaCertificateAuthority_disappears'. Acceptance test output: $ make testacc TEST=./aws/ TESTARGS='-run=TestAccAwsAcmpcaCertificateAuthority_disappears' ==> Checking that code complies with gofmt requirements... TF_ACC=1 go test ./aws/ -v -count 1 -parallel 20 -run=TestAccAwsAcmpcaCertificateAuthority_disappears -timeout 120m === RUN TestAccAwsAcmpcaCertificateAuthority_disappears === PAUSE TestAccAwsAcmpcaCertificateAuthority_disappears === CONT TestAccAwsAcmpcaCertificateAuthority_disappears --- PASS: TestAccAwsAcmpcaCertificateAuthority_disappears (25.10s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 25.138s * r/aws_acmpca_certificate_authority: Remove CAs with DELETED status.
- Loading branch information
Showing
5 changed files
with
226 additions
and
114 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,25 @@ | ||
package finder | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/acmpca" | ||
) | ||
|
||
// CertificateAuthorityByARN returns the certificate authority corresponding to the specified ARN. | ||
// Returns nil if no certificate authority is found. | ||
func CertificateAuthorityByARN(conn *acmpca.ACMPCA, arn string) (*acmpca.CertificateAuthority, error) { | ||
input := &acmpca.DescribeCertificateAuthorityInput{ | ||
CertificateAuthorityArn: aws.String(arn), | ||
} | ||
|
||
output, err := conn.DescribeCertificateAuthority(input) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if output == nil { | ||
return nil, nil | ||
} | ||
|
||
return output.CertificateAuthority, 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,35 @@ | ||
package waiter | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/acmpca" | ||
"github.com/hashicorp/aws-sdk-go-base/tfawserr" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/terraform-providers/terraform-provider-aws/aws/internal/service/acmpca/finder" | ||
) | ||
|
||
const ( | ||
certificateAuthorityStatusNotFound = "NotFound" | ||
certificateAuthorityStatusUnknown = "Unknown" | ||
) | ||
|
||
// CertificateAuthorityStatus fetches the Deployment and its Status | ||
func CertificateAuthorityStatus(conn *acmpca.ACMPCA, arn string) resource.StateRefreshFunc { | ||
return func() (interface{}, string, error) { | ||
certificateAuthority, err := finder.CertificateAuthorityByARN(conn, arn) | ||
|
||
if tfawserr.ErrCodeEquals(err, acmpca.ErrCodeResourceNotFoundException) { | ||
return nil, certificateAuthorityStatusNotFound, nil | ||
} | ||
|
||
if err != nil { | ||
return nil, certificateAuthorityStatusUnknown, err | ||
} | ||
|
||
if certificateAuthority == nil { | ||
return nil, certificateAuthorityStatusNotFound, nil | ||
} | ||
|
||
return certificateAuthority, aws.StringValue(certificateAuthority.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,26 @@ | ||
package waiter | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/aws/aws-sdk-go/service/acmpca" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
// CertificateAuthorityCreated waits for a CertificateAuthority to return Active or PendingCertificate | ||
func CertificateAuthorityCreated(conn *acmpca.ACMPCA, arn string, timeout time.Duration) (*acmpca.CertificateAuthority, error) { | ||
stateConf := &resource.StateChangeConf{ | ||
Pending: []string{"", acmpca.CertificateAuthorityStatusCreating}, | ||
Target: []string{acmpca.CertificateAuthorityStatusActive, acmpca.CertificateAuthorityStatusPendingCertificate}, | ||
Refresh: CertificateAuthorityStatus(conn, arn), | ||
Timeout: timeout, | ||
} | ||
|
||
outputRaw, err := stateConf.WaitForState() | ||
|
||
if v, ok := outputRaw.(*acmpca.CertificateAuthority); ok { | ||
return v, 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.