Module: Enscalator::Plugins::ElasticBeanstalk

Includes:
Helpers
Defined in:
lib/enscalator/plugins/elastic_beanstalk.rb

Overview

Collection of methods to work with Elastic Beanstalk

Instance Method Summary collapse

Methods included from Helpers

#cfn_call_script, #create_ssh_key, #find_ami, #flatten_hash, #gen_ssh_key_name, #init_assets_dir, #init_aws_config, #read_user_data, #run_cmd

Methods included from Helpers::Dns

#get_dns_records, #upsert_dns_record

Methods included from Helpers::Stack

#cfn_create_stack, #generate_parameters, #get_resource, #get_resources, #wait_stack

Methods included from Helpers::Wrappers

#cfn_client, #cfn_resource, #ec2_client, #route53_client

Instance Method Details

#elastic_beanstalk_app(app_name, stack_name, ssh_key: app_name, solution_stack_name: '64bit Amazon Linux 2015.09 v2.0.4 running Ruby 2.2 (Passenger Standalone)', instance_type: 't2.small') ⇒ Object

Create new ElasticBeanstalk instance

Parameters:

  • app_name (String)

    application name

  • ssh_key (String) (defaults to: app_name)

    name of ssh key to configure instance with

  • solution_stack_name (String) (defaults to: '64bit Amazon Linux 2015.09 v2.0.4 running Ruby 2.2 (Passenger Standalone)')

    stack name of Elastic Beanstalk solution

  • instance_type (String) (defaults to: 't2.small')

    default instance type



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/enscalator/plugins/elastic_beanstalk.rb', line 13

def elastic_beanstalk_app(app_name,
                          stack_name,
                          ssh_key: app_name,
                          solution_stack_name: '64bit Amazon Linux 2015.09 v2.0.4 running Ruby 2.2 (Passenger Standalone)',
                          instance_type: 't2.small')

  properties = {
    ApplicationName: app_name,
    Description: "#{app_name} in #{stack_name} stack",
    ConfigurationTemplates:
      [
        {
          TemplateName: 'DefaultConfiguration',
          Description: 'Default Configuration Version 1.0 - with SSH access',
          SolutionStackName: solution_stack_name,
          OptionSettings: [
            {
              'Namespace': 'aws:autoscaling:launchconfiguration',
              'OptionName': 'EC2KeyName',
              'Value': ssh_key
            },
            {
              'Namespace': 'aws:ec2:vpc',
              'OptionName': 'VPCId',
              'Value': vpc.id
            },
            {
              'Namespace': 'aws:ec2:vpc',
              'OptionName': 'Subnets',
              'Value': { 'Fn::Join': [',', ref_application_subnets] }
            },
            {
              'Namespace': 'aws:ec2:vpc',
              'OptionName': 'ELBSubnets',
              'Value': { 'Fn::Join': [',', public_subnets] }
            },
            {
              'Namespace': 'aws:autoscaling:launchconfiguration',
              'OptionName': 'SecurityGroups',
              'Value': { 'Fn::Join': [',', [ref_application_security_group, ref_private_security_group]] }
            },
            {
              'Namespace': 'aws:autoscaling:launchconfiguration',
              'OptionName': 'InstanceType',
              'Value': instance_type
            }
          ]
        }
      ]
  }

  elastic_beanstalk_resource_name = "#{app_name}BeanstalkApp"

  resource elastic_beanstalk_resource_name,
           Type: 'AWS::ElasticBeanstalk::Application',
           Properties: properties

  elastic_beanstalk_resource_name
end