Created
November 27, 2013 04:56
-
-
Save bellkev/7670855 to your computer and use it in GitHub Desktop.
How to introduce new symbol bindings into a macro if necessary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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