Skip to content

Commit

Permalink
resource/aws_iam_instance_profile: Remove deprecated (helper/schema.R…
Browse files Browse the repository at this point in the history
…esourceData).Partial() and (helper/schema.ResourceData).SetPartial()

Reference: hashicorp#12083
Reference: hashicorp#12087

Previously:

```
aws/resource_aws_iam_instance_profile.go:200:2: R007: deprecated (schema.ResourceData).Partial
aws/resource_aws_iam_instance_profile.go:209:3: R008: deprecated (schema.ResourceData).SetPartial
aws/resource_aws_iam_instance_profile.go:219:3: R008: deprecated (schema.ResourceData).SetPartial
aws/resource_aws_iam_instance_profile.go:222:2: R007: deprecated (schema.ResourceData).Partial
aws/resource_aws_iam_instance_profile.go:249:2: R007: deprecated (schema.ResourceData).Partial
aws/resource_aws_iam_instance_profile.go:268:3: R008: deprecated (schema.ResourceData).SetPartial
aws/resource_aws_iam_instance_profile.go:275:2: R007: deprecated (schema.ResourceData).Partial
```

Output from acceptance testing:

```
--- PASS: TestAccAWSIAMInstanceProfile_withoutRole (13.88s)
--- PASS: TestAccAWSIAMInstanceProfile_basic (14.58s)
--- PASS: TestAccAWSIAMInstanceProfile_withRoleNotRoles (14.64s)
--- PASS: TestAccAWSIAMInstanceProfile_namePrefix (14.70s)
```
  • Loading branch information
bflad authored and adamdecaf committed May 28, 2020
1 parent 3a9eb41 commit a1a65a1
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions aws/resource_aws_iam_instance_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,13 @@ func instanceProfileSetRoles(d *schema.ResourceData, iamconn *iam.IAM) error {

currentRoles := schema.CopySet(oldRoles)

d.Partial(true)

for _, role := range oldRoles.Difference(newRoles).List() {
err := instanceProfileRemoveRole(iamconn, d.Id(), role.(string))
if err != nil {
return fmt.Errorf("Error removing role %s from IAM instance profile %s: %s", role, d.Id(), err)
}
currentRoles.Remove(role)
d.Set("roles", currentRoles)
d.SetPartial("roles")
}

for _, role := range newRoles.Difference(oldRoles).List() {
Expand All @@ -216,11 +213,8 @@ func instanceProfileSetRoles(d *schema.ResourceData, iamconn *iam.IAM) error {
}
currentRoles.Add(role)
d.Set("roles", currentRoles)
d.SetPartial("roles")
}

d.Partial(false)

return nil
}

Expand All @@ -246,8 +240,6 @@ func instanceProfileRemoveAllRoles(d *schema.ResourceData, iamconn *iam.IAM) err
func resourceAwsIamInstanceProfileUpdate(d *schema.ResourceData, meta interface{}) error {
iamconn := meta.(*AWSClient).iamconn

d.Partial(true)

if d.HasChange("role") {
oldRole, newRole := d.GetChange("role")

Expand All @@ -264,16 +256,12 @@ func resourceAwsIamInstanceProfileUpdate(d *schema.ResourceData, meta interface{
return fmt.Errorf("Error adding role %s to IAM instance profile %s: %s", newRole.(string), d.Id(), err)
}
}

d.SetPartial("role")
}

if d.HasChange("roles") {
return instanceProfileSetRoles(d, iamconn)
}

d.Partial(false)

return nil
}

Expand Down

0 comments on commit a1a65a1

Please sign in to comment.