API Gatewayの管理コンソールが新しくなってて、swaggerのインポートが簡単にできるようになっていました。4/5のアップデートですね。
これでaws-apigateway-importerを使わずに済む!
本家も公式行ってね、とアナウンスしておりますので、喜び勇んでCLIからインポートするように。
CLIを1.10.20に上げて、
>aws apigateway import-rest-api help
import-rest-api
^^^^^^^^^^^^^^^
Description
***********
A feature of the Amazon API Gateway control service for creating a new
API from an external API definition file.
Synopsis
********
import-rest-api
[--fail-on-warnings | --no-fail-on-warnings]
[--parameters <value>]
--body <value>
[--cli-input-json <value>]
[--generate-cli-skeleton]
Options
*******
"--fail-on-warnings" | "--no-fail-on-warnings" (boolean)
A query parameter to indicate whether to rollback the API creation
("true" ) or not ("false" ) when a warning is encountered. The
default value is "false" .
"--parameters" (map)
Custom header parameters as part of the request.
Shorthand Syntax:
KeyName1=string,KeyName2=string
JSON Syntax:
{"string": "string"
...}
"--body" (blob)
The POST request body containing external API definitions.
Currently, only Swagger definition JSON files are supported.
"--cli-input-json" (string) Performs service operation based on the
JSON string provided. The JSON string follows the format provided by
"--generate-cli-skeleton". If other arguments are provided on the
command line, the CLI values will override the JSON-provided values.
"--generate-cli-skeleton" (boolean) Prints a sample input JSON to
standard output. Note the specified operation is not run if this
argument is specified. The sample input can be used as an argument for
"--cli-input-json".
Output
******
id -> (string)
The API's identifier. This identifier is unique across all of your
APIs in Amazon API Gateway.
name -> (string)
The API's name.
description -> (string)
The API's description.
createdDate -> (timestamp)
The date when the API was created, in ISO 8601 format .
warnings -> (list)
(string)
・・・あれ、jsonサポートのみ?yamlサポートしてないっすか?
仕方ない、yaml管理してたのをjsonに直して、、
aws apigateway import-rest-api --body test.json
A client error (BadRequestException) occurred when calling the ImportRestApi ope
ration: Invalid Swagger 2.0 input.
え?このjsonファイル、管理コンソールからだと通るんだけど、、、
教えて偉い人!
ということで上記の通り、
aws apigateway import-rest-api --body file://test.json
ってしたらうまくいきました。
後はupdate-rest-apiとかput-rest-apiとか組み合わせればよいのね。
満足!