use Here document! EOS ! ! Resources do myEC2Instance do Type "AWS::EC2::Instance" Properties do ImageId "ami-XXXXXXXX" InstanceType { Ref "InstanceType" } KeyName "your_key_name" ! UserData (<<-EOS).undent.encode64 #!/bin/bash yum install -y httpd service httpd start EOS end end end RUBY DSL TEMPLATE?
] ! roles.each do |role| _ "#{role.capitalize}SecurityGroup" do Type "AWS::EC2::SecurityGroup" Properties do GroupDescription "Security group for #{role} instances." VpcId {Ref "#{ENVIRONMENT}VPC"} Tags [ "Key" => "Name", "Value" => role, ] end end end