An open API service indexing awesome lists of open source software.

https://github.com/warfox/clojure-cdk-example

Clojure CDK example
https://github.com/warfox/clojure-cdk-example

cdk cdk-example cljs clojure

Last synced: 5 months ago
JSON representation

Clojure CDK example

Awesome Lists containing this project

README

        

#+title: Clojure CDK Example

This is an example project for CDK development with Clojure.

The `cdk.json` file tells the CDK Toolkit how to execute your app.

** Stack

This example systhesises an SQS Queue and an SNS Topic and adds a
subscription for the topic

** Useful commands

* `clj -M:test` Run Tests
* `cdk ls` list all stacks in the app
* `cdk synth` emits the synthesized CloudFormation template
* `cdk deploy` deploy this stack to your default AWS account/region
* `cdk diff` compare deployed stack with current state
* `cdk docs` open CDK documentation

** Multi-Stack deployment

* `cdk deploy StorageStack` deploy the storage stack
* `cdk deploy TopicStack` deploy the topic stack
* `cdk deploy --all` deploy all stacks

** How it works

[[https://github.com/weavejester/integrant][Integrant]] is the main tool behind this setup, it manages the dependencies
between resources and stacks, by using a simple configuration map {}

CDK Java depends on =software.amazon.awscdk.App= instance and related
=software.amazon.awscdk.Stack= instances

Integrant is used to manage the dependencies between them. The following
is the configuration used by the integrant system.

#+begin_src clojure
(def config
{:app/instance {}
:stacks/topic {:app (ig/ref :app/instance)
:stack-id "TopicStack"}
:stacks/storage {:app (ig/ref :app/instance)
:stack-id "StorageStack"}
:app/synth {:app (ig/ref :app/instance)
:stacks [(ig/ref :stacks/topic)
(ig/ref :stacks/storage)]}})
#+end_src

You can define more stacks and add them to the =:stacks= vector in =:app/synth=

Refer [[https://docs.aws.amazon.com/cdk/v2/guide/work-with-cdk-java.html#java-running][CDK Java documentation]] for more.

Enjoy!

** License
Copyright © 2023 Deepu Mohan Puthrote

Distributed under the MIT License.