我现在尝试了 7 次,但仍然失败。我正在向我的 API 网关添加一个新的路由端点。我已对云形成文件进行了必要的更改并将其上传到 AWS。
每次尝试,我得到以下错误,我不知道如何解决它。
'comp/*/*' is not a valid method path. Method paths can be defined as
{resource_path}/{http_method} for an individual method override,
or */* for overriding all methods in the stage.
(Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException;
Request ID: 0878sd34-4555-987s-3332-8dfg7d8f9;
Proxy: null)
这是云形成文件的一部分。
DevEnvStage:
Type: "AWS::ApiGateway::Stage"
Properties:
RestApiId: !Ref RestApi
StageName: 'dev'
Description: Stage for development environment
DeploymentId: !Ref FakeStageDeployment
CacheClusterEnabled: false
MethodSettings:
- HttpMethod: "*"
ResourcePath: "/red/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
- HttpMethod: "*"
ResourcePath: "/yellow/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
- HttpMethod: "*"
ResourcePath: "/blue/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
- HttpMethod: "*"
ResourcePath: "/comp/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
- HttpMethod: "*"
ResourcePath: "/dribl/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
- HttpMethod: "*"
ResourcePath: "/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
Variables:
"": ""
QaEnvStage:
Type: "AWS::ApiGateway::Stage"
Properties:
RestApiId: !Ref RestApi
StageName: 'qa'
Description: Stage for development environment
DeploymentId: !Ref FakeStageDeployment
CacheClusterEnabled: false
MethodSettings:
- HttpMethod: "*"
ResourcePath: "/black/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
- HttpMethod: "*"
ResourcePath: "/red/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
- HttpMethod: "*"
ResourcePath: "/yellow/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
- HttpMethod: "*"
ResourcePath: "/blue/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
- HttpMethod: "*"
ResourcePath: "/comp/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
- HttpMethod: "*"
ResourcePath: "/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
Variables:
"": ""
StageEnvStage:
Type: "AWS::ApiGateway::Stage"
Properties:
RestApiId: !Ref RestApi
StageName: 'stg'
Description: Stage for development environment
DeploymentId: !Ref FakeStageDeployment
CacheClusterEnabled: false
MethodSettings:
- HttpMethod: "*"
ResourcePath: "/black/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
- HttpMethod: "*"
ResourcePath: "/red/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
- HttpMethod: "*"
ResourcePath: "/yellow/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
- HttpMethod: "*"
ResourcePath: "/blue/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
- HttpMethod: "*"
ResourcePath: "/comp/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
- HttpMethod: "*"
ResourcePath: "/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
Variables:
"": ""
ProdEnvStage:
Type: "AWS::ApiGateway::Stage"
Properties:
RestApiId: !Ref RestApi
StageName: 'prod'
Description: Stage for development environment
DeploymentId: !Ref FakeStageDeployment
CacheClusterEnabled: false
MethodSettings:
- HttpMethod: "*"
ResourcePath: "/yellow/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
- HttpMethod: "*"
ResourcePath: "/red/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
- HttpMethod: "*"
ResourcePath: "/red/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
- HttpMethod: "*"
ResourcePath: "/blue/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
- HttpMethod: "*"
ResourcePath: "/comp/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
- HttpMethod: "*"
ResourcePath: "/*"
CachingEnabled: true
CacheDataEncrypted: false
CacheTtlInSeconds: 180
Variables:
"Hostname": ""
DevEnvGatewayCustomDomain:
Type: "AWS::ApiGateway::DomainName"
Properties:
DomainName: ""
CertificateArn: ""
EndpointConfiguration:
Types:
- EDGE
DevEnvGatewayBasePathMapping:
Type: "AWS::ApiGateway::BasePathMapping"
Properties:
RestApiId: !Ref RestApi
DomainName: !Ref DevEnvGatewayCustomDomain
Stage: !Ref DevEnvStage
QaEnvGatewayCustomDomain:
Type: "AWS::ApiGateway::DomainName"
Properties:
DomainName: ""
CertificateArn: ""
EndpointConfiguration:
Types:
- EDGE
QaEnvGatewayBasePathMapping:
Type: "AWS::ApiGateway::BasePathMapping"
Properties:
RestApiId: !Ref RestApi
DomainName: !Ref QaEnvGatewayCustomDomain
Stage: !Ref QaEnvStage
StageEnvGatewayCustomDomain:
Type: "AWS::ApiGateway::DomainName"
Properties:
DomainName: ""
CertificateArn: ""
EndpointConfiguration:
Types:
- EDGE
StageEnvGatewayBasePathMapping:
Type: "AWS::ApiGateway::BasePathMapping"
Properties:
RestApiId: !Ref RestApi
DomainName: !Ref StageEnvGatewayCustomDomain
Stage: !Ref StageEnvStage
ProdEnvGatewayCustomDomain:
Type: "AWS::ApiGateway::DomainName"
Properties:
DomainName: ""
CertificateArn: ""
EndpointConfiguration:
Types:
- EDGE
ProdEnvGatewayBasePathMapping:
Type: "AWS::ApiGateway::BasePathMapping"
Properties:
RestApiId: !Ref RestApi
DomainName: !Ref ProdEnvGatewayCustomDomain
Stage: !Ref ProdEnvStage
正如您在方法设置部分中看到的那样。comp 的 HttpMehod 是“ /comp/*
”不是“ /comp/*/*
”