Skip to content

Commit

Permalink
fix acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Puneeth-n committed Dec 16, 2017
1 parent 036ae40 commit be7076a
Show file tree
Hide file tree
Showing 2 changed files with 299 additions and 73 deletions.
11 changes: 8 additions & 3 deletions aws/resource_aws_lb_listener_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func resourceAwsLbListenerCertificate() *schema.Resource {

func resourceAwsLbListenerCertificateCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).elbv2conn

params := &elbv2.AddListenerCertificatesInput{
ListenerArn: aws.String(d.Get("listener_arn").(string)),
Certificates: []*elbv2.Certificate{
Expand All @@ -42,6 +43,7 @@ func resourceAwsLbListenerCertificateCreate(d *schema.ResourceData, meta interfa
},
}

log.Printf("[DEBUG] Adding certificate: %s of listener: %s", d.Get("certificate_arn").(string), d.Get("listener_arn").(string))
resp, err := conn.AddListenerCertificates(params)
if err != nil {
return errwrap.Wrapf("Error creating LB Listener Certificate: {{err}}", err)
Expand All @@ -58,6 +60,8 @@ func resourceAwsLbListenerCertificateCreate(d *schema.ResourceData, meta interfa

func resourceAwsLbListenerCertificateRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).elbv2conn
log.Printf("[DEBUG] Reading certificate: %s of listener: %s", d.Get("certificate_arn").(string), d.Get("listener_arn").(string))

params := &elbv2.DescribeListenerCertificatesInput{
ListenerArn: aws.String(d.Get("listener_arn").(string)),
PageSize: aws.Int64(400),
Expand All @@ -68,7 +72,7 @@ func resourceAwsLbListenerCertificateRead(d *schema.ResourceData, meta interface
for morePages && !found {
resp, err := conn.DescribeListenerCertificates(params)
if err != nil {
return errwrap.Wrapf("Error describing LB Listener Certificates: {{err}}", err)
return err
}

for _, cert := range resp.Certificates {
Expand All @@ -82,7 +86,7 @@ func resourceAwsLbListenerCertificateRead(d *schema.ResourceData, meta interface
}
}

if *resp.NextMarker != "" {
if resp.NextMarker != nil {
params.Marker = resp.NextMarker
} else {
morePages = false
Expand All @@ -100,6 +104,8 @@ func resourceAwsLbListenerCertificateRead(d *schema.ResourceData, meta interface

func resourceAwsLbListenerCertificateDelete(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).elbv2conn
log.Printf("[DEBUG] Deleting certificate: %s of listener: %s", d.Get("certificate_arn").(string), d.Get("listener_arn").(string))

params := &elbv2.RemoveListenerCertificatesInput{
ListenerArn: aws.String(d.Get("listener_arn").(string)),
Certificates: []*elbv2.Certificate{
Expand All @@ -109,7 +115,6 @@ func resourceAwsLbListenerCertificateDelete(d *schema.ResourceData, meta interfa
},
}

// Returns no useful response.
_, err := conn.RemoveListenerCertificates(params)
if err != nil {
return errwrap.Wrapf("Error removing LB Listener Certificate: {{err}}", err)
Expand Down
Loading

0 comments on commit be7076a

Please sign in to comment.