Liking cljdoc? Tell your friends :D

aws-apigateway

Configuration

Add [lein-aws-api-gateway "1.10.68"] 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 in target, if auto-generated or somewhere in resources if hand-crafted
  • api-id – (required, for update and deploy tasks) the ID of the API that should be updated. The update-api task will fail if no api-id has been specified, but it is not required for the create task. You can retrieve the API ID by running aws apigateway get-rest-apis if you have the AWS command line tools installed.

Authentication

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_KEY and AWS_SECRET_KEY environment variables. This works well for continuous integration environments
  • Specify credentials in the aws.accessKeyId and aws.secretKey Java environment variables.
  • Use the default credentials stored for the AWS Command Line tools, stored in ~/.aws/credentials, which can be set using the was configure command
  • 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.

Execution

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>

API Gateway Extensions for Swagger

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.

Development

Clone and install the plugin:

git clone https://github.com/trieloff/lein-aws-apigateway.git
cd lein-aws-apigateway
lein install

Versioning and Licensing

Limitations and Improvements

  • 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.

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close