设置缓存将波浪号添加到资源路径

Setting Cache adding Tildes to Resource Path

我正在利用 AWS 的 CDK 开发我们的 API 层。到目前为止一切正常,现在我正在添加缓存。我在舞台上启用了 CacheCluster,我正在尝试为我的几个端点启用它。我面临的问题是 CDK 正在将资源路径从 /v1/configuration 更改为 /~1v1~1configuration。我试过转义我的 /s,但这并没有解决我的问题。

CDK C# 代码

new Amazon.CDK.AWS.APIGateway.Stage(this, "prod", new Amazon.CDK.AWS.APIGateway.StageProps
{
    Deployment = deployment,
    StageName = "prod",
    Variables = stageVariables,
    CacheClusterEnabled = true,
    CacheClusterSize = "1.6",
    DataTraceEnabled = true,
    LoggingLevel = MethodLoggingLevel.INFO,
    MetricsEnabled = true,
    TracingEnabled = true,
    MethodOptions = new Dictionary<string, IMethodDeploymentOptions>
    {
        { "/v1/configuration/GET", new MethodDeploymentOptions { CachingEnabled = true }}
    }
});

阶段中的结果方法设置:

MethodSettings:
  - DataTraceEnabled: true
    HttpMethod: "*"
    LoggingLevel: INFO
    MetricsEnabled: true
    ResourcePath: /*
  - CachingEnabled: true
    HttpMethod: GET
    ResourcePath: /~1v1~1configuration

编码为 ~1 的正斜杠是预期的行为。请参阅:https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apitgateway-stage-methodsetting.html#cfn-apigateway-stage-methodsetting-resourcepath