Skip to content

WarFox/clojure-cdk-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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.

(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)]}})

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

Refer CDK Java documentation for more.

Enjoy!

License

Copyright © 2023 Deepu Mohan Puthrote

Distributed under the MIT License.