diff --git a/.changelog/21362.txt b/.changelog/21362.txt new file mode 100644 index 00000000000..6693805974a --- /dev/null +++ b/.changelog/21362.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_codedeploy_deployment_group: Correctly update `deployment_group_name` argument +``` diff --git a/internal/service/codedeploy/deployment_group.go b/internal/service/codedeploy/deployment_group.go index a25f364ea50..0a4402cebc3 100644 --- a/internal/service/codedeploy/deployment_group.go +++ b/internal/service/codedeploy/deployment_group.go @@ -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") { @@ -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) } }