class BeanstalkTemplate
Public Class Methods
new(params)
click to toggle source
# File lib/gantree/cfn/beanstalk.rb, line 3 def initialize params @stack_name = params[:stack_name] @docker_version = params[:solution] @size = params[:instance_size] @rds = params[:rds] @env = params[:env] @domain = params[:domain] @requirements = params[:requirements] @rds_enabled = params[:rds?] @env_type = params[:env_type] end
Public Instance Methods
beanstalk_parmaters()
click to toggle source
# File lib/gantree/cfn/beanstalk.rb, line 42 def beanstalk_parmaters "parameter 'KeyName', :Description => 'The Key Pair to launch instances with', :Type => 'String', :Default => 'default' parameter 'InstanceSecurityGroup', :Type => 'String' parameter 'InstanceType', :Description => 'EC2 Instance Type', :Type => 'String', :Default => '#{@size}' parameter 'ApplicationName', :Description => 'The name of the Elastic Beanstalk Application', :Type => 'String', :Default => '#{@stack_name}' parameter 'Environment', :Type => 'String', :Default => '#{@env_type}' parameter 'IamInstanceProfile', :Type => 'String', :Default => 'EbApp' #{"parameter 'RDSHostURLPass', :Type => 'String'" if @rds_enabled }" end
configuration_template()
click to toggle source
# File lib/gantree/cfn/beanstalk.rb, line 73 def configuration_template "resource 'ConfigurationTemplate', :Type => 'AWS::ElasticBeanstalk::ConfigurationTemplate', :Properties => { :ApplicationName => ref('Application'), :SolutionStackName => '#{@docker_version}', :Description => 'Default Configuration Version #{@docker_version} - with SSH access', :OptionSettings => [ { :Namespace => 'aws:elasticbeanstalk:application:environment', :OptionName => 'AWS_REGION', :Value => aws_region, }, { :Namespace => 'aws:autoscaling:launchconfiguration', :OptionName => 'EC2KeyName', :Value => ref('KeyName'), }, { :Namespace => 'aws:autoscaling:launchconfiguration', :OptionName => 'IamInstanceProfile', :Value => ref('IamInstanceProfile'), }, { :Namespace => 'aws:autoscaling:launchconfiguration', :OptionName => 'InstanceType', :Value => ref('InstanceType'), }, { :Namespace => 'aws:autoscaling:launchconfiguration', :OptionName => 'SecurityGroups', :Value => join(',', join('-', '#{@env_type}', 'br'), ref('InstanceSecurityGroup')), }, { :Namespace => 'aws:autoscaling:updatepolicy:rollingupdate', :OptionName => 'RollingUpdateEnabled', :Value => 'true' }, { :Namespace => 'aws:autoscaling:updatepolicy:rollingupdate', :OptionName => 'MaxBatchSize', :Value => '1' }, { :Namespace => 'aws:autoscaling:updatepolicy:rollingupdate', :OptionName => 'MinInstancesInService', :Value => '2' }, { :Namespace => 'aws:elasticbeanstalk:hostmanager', :OptionName => 'LogPublicationControl', :Value => 'true' }, #{set_rds_parameters if @rds_enabled } ], }" end
create()
click to toggle source
# File lib/gantree/cfn/beanstalk.rb, line 15 def create "#{@requirements} template do value :AWSTemplateFormatVersion => '2010-09-09' value :Description => '#{@stack_name} Service Parent Template (2014-08-15)' #{beanstalk_parmaters} resource 'Application', :Type => 'AWS::ElasticBeanstalk::Application', :Properties => { :Description => '#{@stack_name}', :ApplicationName => '#{@stack_name}', } #{configuration_template} #{resources} output 'URL', :Description => 'URL of the AWS Elastic Beanstalk Environment', :Value => join('', 'http://', get_att('EbEnvironment', 'EndpointURL')) end.exec! " end
resources()
click to toggle source
# File lib/gantree/cfn/beanstalk.rb, line 113 def resources "resource 'EbEnvironment', :Type => 'AWS::ElasticBeanstalk::Environment', :Properties => { :ApplicationName => '#{@stack_name}', :EnvironmentName => '#{@env}', :Description => 'Default Environment', :TemplateName => ref('ConfigurationTemplate'), :OptionSettings => [], } resource 'HostRecord', :Type => 'AWS::Route53::RecordSet', :Properties => { :Comment => 'DNS name for my stack', :HostedZoneName => '#{@domain}', :Name => join('.', '#{@stack_name}', '#{@domain}'), :ResourceRecords => [ get_att('EbEnvironment', 'EndpointURL') ], :TTL => '60', :Type => 'CNAME', }" end
set_rds_parameters()
click to toggle source
# File lib/gantree/cfn/beanstalk.rb, line 131 def set_rds_parameters "{ :Namespace => 'aws:elasticbeanstalk:application:environment', :OptionName => 'DB_HostURL', :Value => ref('RDSHostURLPass'), }," end