Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creation of "aws_appmesh_route" fails if one of the "weighted_targets" has "weight = 0" #13479

Closed
mkielar opened this issue May 25, 2020 · 4 comments · Fixed by #13539
Closed
Labels
bug Addresses a defect in current functionality. service/appmesh Issues and PRs that pertain to the appmesh service.
Milestone

Comments

@mkielar
Copy link
Contributor

mkielar commented May 25, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

0.12.20

Affected Resource(s)

  • aws_appmesh_route

Terraform Configuration Files

resource "aws_appmesh_route" "vrr" {
  mesh_name           = var.appmesh.name
  name                = local.name
  virtual_router_name = aws_appmesh_virtual_router.vr.name

  spec {
    http_route {
      match {
        prefix = "/"
      }

      action {
        dynamic "weighted_target" {
          for_each = local.deployments
          content {
            virtual_node = aws_appmesh_virtual_node.vn[weighted_target.key].name
            weight       = weighted_target.value.weight
          }
        }
      }
    }
  }

}

Terraform Plan Output

 Terraform will perform the following actions:
   # module.[MASKED].module.[MASKED].aws_appmesh_route.vrr will be updated in-place
   ~ resource "aws_appmesh_route" "vrr" {
         arn                 = "arn:aws:appmesh:eu-west-1:[MASKED]:mesh/[MASKED]/virtualRouter/[MASKED]/route/[MASKED]"
         created_date        = "2020-05-23T22:46:26Z"
         id                  = "[MASKED]"
         last_updated_date   = "2020-05-23T22:46:26Z"
         mesh_name           = "[MASKED]"
         name                = "[MASKED]"
         tags                = {}
         virtual_router_name = "[MASKED]"
       ~ spec {
             priority = 0
           ~ http_route {
               ~ action {
                   + weighted_target {
                       + virtual_node = "[MASKED]-blue"
                       + weight       = 100
                     }
                   - weighted_target {
                       - virtual_node = "[MASKED]-blue" -> null
                       - weight       = 90 -> null
                     }
                   + weighted_target {
                       + virtual_node = "[MASKED]-green"
                       + weight       = 0
                     }
                   - weighted_target {
                       - virtual_node = "[MASKED]-green" -> null
                       - weight       = 10 -> null
                     }
                 }
                 match {
                     prefix = "/"
                 }
             }
         }
     }

Debug Output

�[0m�[1mmodule.[MASKED].module.[MASKED].aws_appmesh_route.vrr: Modifying... [id=c662fd86-1630-492c-952e-2cca14d07795]�[0m�[0m
2020/05/25 00:01:01 [DEBUG] module.[MASKED].module.[MASKED].aws_appmesh_route.vrr: applying the planned Update change
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4: 2020/05/25 00:01:01 [DEBUG] Updating App Mesh route: {
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4:   MeshName: "[MASKED]",
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4:   RouteName: "[MASKED]",
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4:   Spec: {
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4:     HttpRoute: {
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4:       Action: {
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4:         WeightedTargets: [{
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4:             VirtualNode: "[MASKED]"
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4:           },{
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4:             VirtualNode: "[MASKED]",
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4:             Weight: 100
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4:           }]
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4:       },
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4:       Match: {
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4:         Prefix: "/"
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4:       }
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4:     }
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4:   },
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4:   VirtualRouterName: "[MASKED]"
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4: }
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4: 2020/05/25 00:01:01 [DEBUG] [aws-sdk-go] DEBUG: Validate Request App Mesh/UpdateRoute failed, not retrying, error InvalidParameter: 1 validation error(s) found.
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4: - missing required field, UpdateRouteInput.Spec.HttpRoute.Action.WeightedTargets[0].Weight.
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4: 2020/05/25 00:01:01 [DEBUG] [aws-sdk-go] DEBUG: Build Request App Mesh/UpdateRoute failed, not retrying, error InvalidParameter: 1 validation error(s) found.
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4: - missing required field, UpdateRouteInput.Spec.HttpRoute.Action.WeightedTargets[0].Weight.
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4: 2020/05/25 00:01:01 [DEBUG] [aws-sdk-go] DEBUG: Sign Request App Mesh/UpdateRoute failed, not retrying, error InvalidParameter: 1 validation error(s) found.
2020-05-25T00:01:01.973Z [DEBUG] plugin.terraform-provider-aws_v2.63.0_x4: - missing required field, UpdateRouteInput.Spec.HttpRoute.Action.WeightedTargets[0].Weight.
2020/05/25 00:01:01 [DEBUG] module.[MASKED].module.[MASKED].aws_appmesh_route.vrr: apply errored, but we're indicating that via the Error pointer rather than returning it: error updating App Mesh route: InvalidParameter: 1 validation error(s) found.
- missing required field, UpdateRouteInput.Spec.HttpRoute.Action.WeightedTargets[0].Weight.
2020/05/25 00:01:01 [ERROR] module.[MASKED].module.[MASKED]: eval: *terraform.EvalApplyPost, err: error updating App Mesh route: InvalidParameter: 1 validation error(s) found.
- missing required field, UpdateRouteInput.Spec.HttpRoute.Action.WeightedTargets[0].Weight.
2020/05/25 00:01:01 [ERROR] module.[MASKED].module.[MASKED]: eval: *terraform.EvalSequence, err: error updating App Mesh route: InvalidParameter: 1 validation error(s) found.
- missing required field, UpdateRouteInput.Spec.HttpRoute.Action.WeightedTargets[0].Weight.

Panic Output

N/A

Expected Behavior

I'm deploying a new version of service and want the old one to have 100% traffic routed on Virtual Router, while the new one initially gets no traffic. I intend script traffic shifting for Canary Deployments and make it happen outside of terraform.

I checked that this configuration is possible, by manually created two routes (one with 100% weight, and the other with 0% weight) in AWS Console.

The output of terraform plan properly shows that it will set one of the weights to 100 and the other to 0.

The expected behaviour in this case is that the resource gets updated accordingly.

Actual Behavior

The API Call (see the debug log) shows, that - were weight was intended to be 0 - the attribute is not sent to AWS at all. Instead Terraform attempts to send malformed message, lacking weight attribute in one of the WeightedTargets, and AWS Rejects that request with an error message:

 Error: error updating App Mesh route: InvalidParameter: 1 validation error(s) found.
 - missing required field, UpdateRouteInput.Spec.HttpRoute.Action.WeightedTargets[0].Weight.
   on .terraform/modules/[MASKED].[MASKED]/terraform/modules/ecs/service_blue_green/appmesh.tf line 67, in resource "aws_appmesh_route" "vrr":
   67: resource "aws_appmesh_route" "vrr" {

Steps to Reproduce

  1. Create a deployment of aws_appmesh_route with one of the weighted_target.weight set to 0.
  2. terraform apply

Important Factoids

References

@ghost ghost added the service/appmesh Issues and PRs that pertain to the appmesh service. label May 25, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label May 25, 2020
@anGie44 anGie44 added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Jun 3, 2020
@anGie44 anGie44 added this to the v2.65.0 milestone Jun 4, 2020
@anGie44
Copy link
Contributor

anGie44 commented Jun 4, 2020

The fix for this has been merged and will release with version 2.65.0 of the Terraform AWS Provider, expected in this week's release.

@ghost
Copy link

ghost commented Jun 5, 2020

This has been released in version 2.65.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Jul 4, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Jul 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/appmesh Issues and PRs that pertain to the appmesh service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants