0

我正在利用 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
4

1 回答 1

0

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

于 2021-06-09T17:41:59.153 回答