Skip to content

Commit

Permalink
resource/aws_licensemanager_license_configuration: Refactor tagging t…
Browse files Browse the repository at this point in the history
…o use keyvaluetags library

Reference: #7052
Reference: #7926

Output from acceptance testing:

```
--- PASS: TestAccAWSLicenseManagerLicenseConfiguration_basic (12.91s)
--- PASS: TestAccAWSLicenseManagerLicenseConfiguration_update (20.57s)
```
  • Loading branch information
bflad committed Oct 1, 2019
1 parent 688c305 commit 0f398b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 119 deletions.
12 changes: 8 additions & 4 deletions aws/resource_aws_licensemanager_license_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/aws/aws-sdk-go/service/licensemanager"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
)

func resourceAwsLicenseManagerLicenseConfiguration() *schema.Resource {
Expand Down Expand Up @@ -89,7 +90,7 @@ func resourceAwsLicenseManagerLicenseConfigurationCreate(d *schema.ResourceData,
}

if v, ok := d.GetOk("tags"); ok && len(v.(map[string]interface{})) > 0 {
opts.Tags = tagsFromMapLicenseManager(v.(map[string]interface{}))
opts.Tags = keyvaluetags.New(v.(map[string]interface{})).IgnoreAws().LicensemanagerTags()
}

log.Printf("[DEBUG] License Manager license configuration: %s", opts)
Expand Down Expand Up @@ -127,7 +128,7 @@ func resourceAwsLicenseManagerLicenseConfigurationRead(d *schema.ResourceData, m
}
d.Set("name", resp.Name)

if err := d.Set("tags", tagsToMapLicenseManager(resp.Tags)); err != nil {
if err := d.Set("tags", keyvaluetags.LicensemanagerKeyValueTags(resp.Tags).IgnoreAws().Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}

Expand All @@ -140,9 +141,12 @@ func resourceAwsLicenseManagerLicenseConfigurationUpdate(d *schema.ResourceData,
d.Partial(true)

if d.HasChange("tags") {
if err := setTagsLicenseManager(conn, d); err != nil {
return err
o, n := d.GetChange("tags")

if err := keyvaluetags.LicensemanagerUpdateTags(conn, d.Id(), o, n); err != nil {
return fmt.Errorf("error updating License Manager License Configuration (%s) tags: %s", d.Id(), err)
}

d.SetPartial("tags")
}

Expand Down
115 changes: 0 additions & 115 deletions aws/tagsLicenseManager.go

This file was deleted.

0 comments on commit 0f398b1

Please sign in to comment.