-
Notifications
You must be signed in to change notification settings - Fork 9.3k
/
waiter.go
30 lines (23 loc) · 883 Bytes
/
waiter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
}
const (
CertificateAuthorityActiveTimeout = 1 * time.Minute
)