Skip to content

Commit

Permalink
Merge pull request #21362 from hashicorp/b-codedeploy-deployment-group
Browse files Browse the repository at this point in the history
r/codedeploy/deployment_group: fix `deployment_group_name` update handling
  • Loading branch information
anGie44 authored Oct 19, 2021
2 parents fe61d69 + b3878db commit 2fa6ebc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .changelog/21362.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_codedeploy_deployment_group: Correctly update `deployment_group_name` argument
```
13 changes: 7 additions & 6 deletions internal/service/codedeploy/deployment_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -701,18 +701,19 @@ func resourceDeploymentGroupUpdate(d *schema.ResourceData, meta interface{}) err
if d.HasChangesExcept("tags", "tags_all") {
// required fields
applicationName := d.Get("app_name").(string)
deploymentGroupName := d.Get("deployment_group_name").(string)
serviceRoleArn := d.Get("service_role_arn").(string)

input := codedeploy.UpdateDeploymentGroupInput{
ApplicationName: aws.String(applicationName),
CurrentDeploymentGroupName: aws.String(deploymentGroupName),
ServiceRoleArn: aws.String(serviceRoleArn),
ApplicationName: aws.String(applicationName),
ServiceRoleArn: aws.String(serviceRoleArn),
}

if d.HasChange("deployment_group_name") {
_, n := d.GetChange("deployment_group_name")
o, n := d.GetChange("deployment_group_name")
input.CurrentDeploymentGroupName = aws.String(o.(string))
input.NewDeploymentGroupName = aws.String(n.(string))
} else {
input.CurrentDeploymentGroupName = aws.String(d.Get("deployment_group_name").(string))
}

if d.HasChange("deployment_style") {
Expand Down Expand Up @@ -805,7 +806,7 @@ func resourceDeploymentGroupUpdate(d *schema.ResourceData, meta interface{}) err
_, err = conn.UpdateDeploymentGroup(&input)
}
if err != nil {
return fmt.Errorf("Error updating CodeDeploy deployment group: %w", err)
return fmt.Errorf("error updating CodeDeploy deployment group (%s): %w", d.Id(), err)
}
}

Expand Down

0 comments on commit 2fa6ebc

Please sign in to comment.