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

<!-- Please refer to the contribution guidelines before raising a PR: https://github.com/localstack/localstack/blob/master/CONTRIBUTING.md --> #5

Open
iambary44 opened this issue Oct 11, 2023 · 0 comments

Comments

@iambary44
Copy link
Member

Motivation

As reported in a LocalStack Slack Community post, we would raise an exception when trying to update a stage with some method settings.
Here's the message to reproduce:

> resource "aws_api_gateway_method_settings" "this" {


rest_api_id = var.rest_api_id
stage_name  = var.stage_name
method_path = "${trimprefix(var.path, "/")}/${var.method}"

settings {
  metrics_enabled        = var.metrics_enabled
  logging_level          = var.logging_level
  caching_enabled        = var.caching_enabled
  cache_ttl_in_seconds   = var.cache_ttl_in_seconds
  cache_data_encrypted   = var.cache_data_encrypted
  throttling_rate_limit  = var.rate_limit.rate
  throttling_burst_limit = var.rate_limit.burst
}

Here is the error:
│ Error: updating API Gateway Stage failed: BadRequestException: Invalid method setting path: /test/GET/throttling/burstLimit. Must be one of: [/deploymentId, /description, /cacheClusterEnabled, /cacheClusterSize, /clientCertificateId, /accessLogSettings, /accessLogSettings/destinationArn, /accessLogSettings/format, /{resourcePath}/{httpMethod}/metrics/enabled, /{resourcePath}/{httpMethod}/logging/dataTrace, /{resourcePath}/{httpMethod}/logging/loglevel, /{resourcePath}/{httpMethod}/throttling/burstLimit/{resourcePath}/{httpMethod}/throttling/rateLimit/{resourcePath}/{httpMethod}/caching/ttlInSeconds, /{resourcePath}/{httpMethod}/caching/enabled, /{resourcePath}/{httpMethod}/caching/dataEncrypted, /{resourcePath}/{httpMethod}/caching/requireAuthorizationForCacheControl, /{resourcePath}/{httpMethod}/caching/unauthorizedCacheControlHeaderStrategy, ///metrics/enabled, ///logging/dataTrace, ///logging/loglevel, ///throttling/burstLimit ///throttling/rateLimit ///caching/ttlInSeconds, ///caching/enabled, ///caching/dataEncrypted, ///caching/requireAuthorizationForCacheControl, ///caching/unauthorizedCacheControlHeaderStrategy, /variables/{variable_name}, /tracingEnabled]

│ with module.apgw.module.testlambda.aws_api_gateway_method_settings.this,
│ on ../modules/definitions/apgw/method/main.tf line 22, in resource "aws_api_gateway_method_settings" "this":
│ 22: resource "aws_api_gateway_method_settings" "this" {

User's repo to reproduce:
https://github.com/joecolly/localstack-tf-apgw

This PR is a follow up from #9039 and #8873. There was still an issue with the formatting of the error, and we didn't get all the fields from it properly.

https://docs.aws.amazon.com/apigateway/latest/api/patch-operations.html#UpdateStage-Patch

We also didn't use the default values from */* method settings when creating a new one by update.

Changes

Fix the STAGE_UPDATE_PATHS list to have all the right paths, and adapted the logic for the error message (maybe we should just create it once?)
I've added some logic in an existing patch to get the default values from */* method settings.

Added snapshots tests to validate the behaviour with default settings and being able to set a {resource}/{method}/* path.

Originally posted by @bentsku in localstack/localstack#9334

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant