[英]AWS Api Gateway Custom Domain Name with undefined stage
我正在嘗試在 AWS API 網關中設置自定義域名,其中調用者必須在任何基本路徑名之后明確指定階段名稱。 這是我過去做過的事情,但現在看來,由於 AWS 更新了控制台界面,這不再可能了。 最終的 url 應該是這樣的:
https://example.com/ {basePath}/{stage}/function
我嘗試使用 AWS CLI,但 stage 又是一個必填字段aws: error: the following arguments are required: --stage
我嘗試使用 Boto3,遵循文檔( https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/apigateway.html#APIGateway.Client.create_base_path_mapping )但是,即使階段可以指定為'none'(您要用於此映射的 API 階段的名稱。如果您希望調用者在任何基本路徑名之后顯式指定階段名稱,請指定“(無)”。 ),這樣做會返回錯誤:
botocore.errorfactory.BadRequestException: An error occurred (BadRequestException) when calling the CreateBasePathMapping operation: Invalid stage identifier specified
有趣(或令人沮喪)的是,我有一些使用舊控制台創建的自定義域名,並且運行良好,沒有定義任何階段。
仍然可以僅指定“API ID”和“路徑”而省略“階段”參數。 我從控制台和 CLI 都試過了:
從控制台:“階段”設置是您提到的下拉菜單,但可以留空(不要 select 任何東西)。 如果你做了 select 一個階段,刪除 API 映射並重新添加它
來自 CLI:剛剛也嘗試過,並且在 CLI 版本aws-cli/1.18.69 Python/3.7.7 Darwin/18.7.0 botocore/1.16.19
$ aws apigateway create-base-path-mapping --domain-name **** --rest-api-id *** --base-path test
{
"basePath": "test",
"restApiId": "***"
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.