Skip to content

Commit

Permalink
Handle profile change on update; optimize update
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-codaio committed Feb 25, 2020
1 parent e1737d7 commit ae2f056
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions aws/resource_aws_iot_provisioning_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,26 @@ func resourceAwsIotProvisioningTemplateUpdate(d *schema.ResourceData, meta inter
}
}

_, err := conn.UpdateProvisioningTemplate(&iot.UpdateProvisioningTemplateInput{
Description: aws.String(d.Get("description").(string)),
Enabled: aws.Bool(d.Get("enabled").(bool)),
ProvisioningRoleArn: aws.String(d.Get("provisioning_role_arn").(string)),
TemplateName: aws.String(d.Id()),
})
if d.HasChanges("description", "enabled", "provisioning_role_arn") {
err := resource.Retry(1*time.Minute, func() *resource.RetryError {
_, err := conn.UpdateProvisioningTemplate(&iot.UpdateProvisioningTemplateInput{
Description: aws.String(d.Get("description").(string)),
Enabled: aws.Bool(d.Get("enabled").(bool)),
ProvisioningRoleArn: aws.String(d.Get("provisioning_role_arn").(string)),
TemplateName: aws.String(d.Id()),
})

// Handle IoT not detecting the provisioning role's assume role policy immediately.
if isAWSErr(err, iot.ErrCodeInvalidRequestException, "The provisioning role cannot be assumed by AWS IoT") {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
})

if err != nil {
log.Printf("[ERROR] %s", err)
return err
if err != nil {
log.Printf("[ERROR] %s", err)
return err
}
}

return resourceAwsIotProvisioningTemplateRead(d, meta)
Expand Down

0 comments on commit ae2f056

Please sign in to comment.