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

[Bug]: Error: updating API Gateway Integration: operation error API Gateway: UpdateIntegration, https response error StatusCode: 400, RequestID: ffd09554-7291-4bbe-963e-359592f90c38, BadRequestException: Invalid mapping expression specified: Validation Result: warnings : [], errors : [Invalid mapping expression parameter specified: method.request.querystring.ucid] #39801

Closed
Makanist opened this issue Oct 18, 2024 · 8 comments · Fixed by #40124
Assignees
Labels
bug Addresses a defect in current functionality. service/apigateway Issues and PRs that pertain to the apigateway service.
Milestone

Comments

@Makanist
Copy link

Makanist commented Oct 18, 2024

Terraform Core Version

v1.9.8

AWS Provider Version

registry.terraform.io/hashicorp/aws v5.72.1

Affected Resource(s)

module.api_gateway_resources_module.aws_api_gateway_integration.api_gateway_integration: Modifying... [id=agi-oihadyzjnf-79r2xs-ANY]

Expected Behavior

I was expected the stack to remove the parameters from the method and integration resources.

Actual Behavior

Instead it is removing from method and failing to remove from integration resource causing a failure. But if I run the same apply command immediately, its executing properly as parameter and method id already removed.

Relevant Error/Panic Output Snippet

module.api_gateway_deployment_module.aws_wafv2_web_acl_association.api_gateway_waf_association: Destroying... [id=arn:aws:wafv2:us-west-2:134567476717:regional/webacl/spotter-data-api-de-dev-pub-waf/833a358a-ace6-4e12-b85e-bec7ad816ed3,arn:aws:apigateway:us-west-2::/restapis/oihadyzjnf/stages/dev]
module.api_gateway_deployment_module.aws_wafv2_web_acl_association.api_gateway_waf_association: Destruction complete after 1s
module.api_gateway_resources_module.aws_api_gateway_method.api_gateway_method: Modifying... [id=agm-oihadyzjnf-79r2xs-ANY]
╷
│ Error: updating API Gateway Integration: operation error API Gateway: UpdateIntegration, https response error StatusCode: 400, RequestID: 838b10d1-cbcf-49c7-9acb-cbbf98a7ff86, BadRequestException: Invalid mapping expression specified: Validation Result: warnings : [], errors : [Invalid mapping expression parameter specified: method.request.querystring.name]
│ 
│   with module.api_gateway_resources_module.aws_api_gateway_method.api_gateway_method,
│   on ../modules/api_gateway_proxy_resources/api_gateway_resource.tf line 18, in resource "aws_api_gateway_method" "api_gateway_method":
│   18: resource "aws_api_gateway_method" "api_gateway_method" {

Terraform Configuration Files

resource "aws_api_gateway_method" "api_gateway_method" {
  rest_api_id   = var.rest_api_id
  resource_id   = aws_api_gateway_resource.api_gateway_resource.id
  http_method   = "ANY"
  authorization = "NONE"
  request_parameters = merge(
    {
      "method.request.path.proxy" = true
    },
    # { for _path_param in var.path_param : "method.request.path.${_path_param}" => true },
    { for param in var.utm_params : "method.request.querystring.${param}" => false }
  )

  lifecycle {
    create_before_destroy = true
  }

  depends_on = [ aws_api_gateway_resource.api_gateway_resource]
}

resource "aws_api_gateway_integration" "api_gateway_integration" {
  rest_api_id             = var.rest_api_id
  resource_id             = aws_api_gateway_resource.api_gateway_resource.id
  http_method             = aws_api_gateway_method.api_gateway_method.http_method
  integration_http_method = "ANY"
  type                    = "HTTP_PROXY"
  uri                     = "https://${var.uri}/{proxy}"
  connection_type         = "VPC_LINK"
  connection_id           = var.vpc_link_id
  cache_key_parameters = concat(
    ["method.request.path.proxy", "integration.request.path.proxy", "integration.request.header.Host"],
    # [for _path_param in var.path_param : "method.request.path.${_path_param}"],
    [for param in var.utm_params : "method.request.querystring.${param}"],
    [for param in var.utm_params : "integration.request.querystring.${param}"]
  )
  request_parameters = merge ({
    "integration.request.path.proxy"  = "method.request.path.proxy"
    "integration.request.header.Host" = "'${var.uri}'"
  },
  { for param in var.utm_params : "integration.request.querystring.${param}" => "method.request.querystring.${param}" }
  )
  
  lifecycle {
    create_before_destroy = true
  }
  
}

Steps to Reproduce

You can create an aws api reaource and have a proxy method integration with utmquery string parameters. Once parameters are added from TF you can try to remove one of the parameters from TF code then you will get hit with this error. I have shared the complete block of method and integration resources.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@Makanist Makanist added the bug Addresses a defect in current functionality. label Oct 18, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • 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.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added service/apigateway Issues and PRs that pertain to the apigateway service. needs-triage Waiting for first response or review from a maintainer. labels Oct 18, 2024
@Makanist
Copy link
Author

Adding fresh logs for plan and apply. It shows clearly the param got removed from the method but can't be removed from the cache key on the integration as it is already gone now the reference became invalid. attaching the logs.
tf_apply.txt
tf_paln.txt

@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Oct 21, 2024
@YakDriver YakDriver self-assigned this Nov 12, 2024
@github-actions github-actions bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Nov 12, 2024
@YakDriver
Copy link
Member

Related #29991

Confusingly, the error you're seeing actually comes from Method, which, starting with #29991, began updating Integration.

Copy link

Warning

This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

@github-actions github-actions bot added this to the v5.76.0 milestone Nov 14, 2024
@Makanist
Copy link
Author

How my issue is resolved? Can you give me detailed steps on the fix??

@github-actions github-actions bot removed the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Nov 14, 2024
Copy link

This functionality has been released in v5.76.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. Thank you!

@Makanist
Copy link
Author

Hello Team,

I have upgraded my provider to 5.76 and ran "terraform init -upgrade". That helped me resolve the problem. Thanks for the quick turnaround on the bug. Appreciate it.

Regards,
Sai Teja Makani

Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 23, 2024
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/apigateway Issues and PRs that pertain to the apigateway service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants