- A Leiningen plugin to deploy AWS API Gateway APIs using Swagger.
Add [lein-aws-api-gateway "1.10.68-1"] to the :plugins vector of your
project.clj or profile.clj.
Configure your project.clj by adding an :api-gateway configuration map:
:api-gateway {:api-id "your-api-id"
:swagger "target/swagger.json"}
The configuration parameters map to the command line arguments in the aws-apigateway-importer, in particular:
swagger– (required) the path to the Swagger file that should be used in the import. Depending on your workflow, this is most likely somewhere intarget, if auto-generated or somewhere inresourcesif hand-craftedapi-id– (required, forupdateanddeploytasks) the ID of the API that should be updated. Theupdate-apitask will fail if noapi-idhas been specified, but it is not required for thecreatetask. You can retrieve the API ID by runningaws apigateway get-rest-apisif you have the AWS command line tools installed.
The plugin does not allow or encourage specifying authentication credentials in the project.clj, so you have to chose one of the following options:
- Specify credentials in
AWS_ACCESS_KEYandAWS_SECRET_KEYenvironment variables. This works well for continuous integration environments - Specify credentials in the
aws.accessKeyIdandaws.secretKeyJava environment variables. - Use the default credentials stored for the AWS Command Line tools, stored in
~/.aws/credentials, which can be set using thewas configurecommand - If you are running on EC2, it will pick up the instance profile credentials
For further reference, please check the AWS Java SDK Credentials Reference documentation.
In order to create a new API, use following command:
lein aws-api-gateway create
Creating a new API will return the API ID. This ID is important for future use. The :api-id in your configuration will be ignored when running this task.
To update an API, run
lein aws-api-gateway update
To delete an already existing API, run
lein aws-api-gateway delete <API-ID>
To deploy an existing API, run
lein aws-api-gateway deploy <STAGE>
If you want to deploy the API, your Swagger file should use the x-amazon-apigateway-auth and x-amazon-apigateway-integration extensions. The aws-apigateway-importer documentation provides an example.
Clone and install the plugin:
git clone https://github.com/trieloff/lein-aws-apigateway.git
cd lein-aws-apigateway
lein install
- The current version is 1.10.68-1 and it wraps the AWS Java SDK of the same version (without the -1 patch).
- The plugin is distributed under the terms of the Eclipse Public License, the same as Leiningen uses.
- Nobody knows if this thing is working
- When I have time, I want to figure out how to hook the plugin to a ring route in your app, so that it can generate the Swagger file as part of the build process.