Skip to content

Instantly share code, notes, and snippets.

@bellkev
Created November 27, 2013 04:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bellkev/7670855 to your computer and use it in GitHub Desktop.
Save bellkev/7670855 to your computer and use it in GitHub Desktop.
How to introduce new symbol bindings into a macro if necessary
; Introduce new variables with nested chunks of scope
(deftemplate my-template
:aws-template-format-version "2010-09-09"
:description "My description"
(with-params [my-parameter {:type :string :description "My string parameter"}]
(with-mappings [my-mapping
{:first-level-key-one {:second-level-key-one "Value"}
:first-level-key-two {:second-level-key-two "Another Value"}}]
(with-conditions [my-condition (not my-parameter)
my-second-condition (= (-> my-mapping :first-level-key-one :second-level-key-one)
my-parameter)]
(resource my-instance aws.ec2/instance :image-id "ami-79fd7eee")
{:my-first-output (:instance-type my-instance)
:my-second-output my-parameter}))))
; Or just kind of introduce new bindings as they come up
(deftemplate my-template
:aws-template-format-version "2010-09-09"
:description "My description"
:parameters [(param my-parameter
:type :string
:description "My string parameter")]
:mappings [(mapping my-mapping
:first-level-key-one
{:second-level-key-one "Value"}
:first-level-key-two
{:second-level-key-two "Another Value"})]
:conditions [(condition my-condition
(not my-parameter))
(condition my-second-condition
(= (-> my-mapping :first-level-key-one :second-level-key-one)
my-parameter))]
:resources [(resource my-instance
aws.ec2/instance
:image-id "ami-79fd7eee")]
:outputs [(output my-first-output (:instance-type my-instance))
(output my-second-output my-parameter)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment