Class: Stalkedbybean::EnvVars

Inherits:
Object
  • Object
show all
Defined in:
lib/stalkedbybean/env_vars.rb

Class Method Summary collapse

Class Method Details

.parse_options(file_path, options) ⇒ Object



7
8
9
# File 'lib/stalkedbybean/env_vars.rb', line 7

def self.parse_options(file_path, options)
  @options = Stalkedbybean::Parser.parse_options(file_path, options)
end


72
73
74
75
76
# File 'lib/stalkedbybean/env_vars.rb', line 72

def self.print_environment_variables
  system(
   "eb printenv #{@options[:app_name]}-#{@options[:environment]} --profile #{@options[:aws_profile]} -r #{@options[:aws_region]}"
  )
end

.update_configuration_optionsObject



11
12
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
# File 'lib/stalkedbybean/env_vars.rb', line 11

def self.update_configuration_options

  @client = Aws::ElasticBeanstalk::Client.new(region: "#{@options[:aws_region]}", profile: "#{@options[:aws_profile]}")

  resp = @client.update_environment({
    application_name: "#{@options[:app_name]}",
    environment_name: "#{@options[:app_name]}-#{@options[:environment]}",
    platform_arn: "#{@options[:platform_arn]}",
    option_settings: [
      {
          namespace: "aws:ec2:vpc",
          option_name: "VPCId",
          value: "#{@options[:vpc_id]}"
      },
      {
          namespace: "aws:autoscaling:launchconfiguration",
          option_name: "SecurityGroups",
          value: "#{@options[:vpc_security_groups]}"
      },
      {
          namespace: "aws:autoscaling:asg",
          option_name: "MaxSize",
          value: "1"
      },
      {
          namespace: "aws:autoscaling:asg",
          option_name: "MinSize",
          value: "1"
      },
      {
          namespace: "aws:autoscaling:launchconfiguration",
          option_name: "InstanceType",
          value: "#{@options[:instance_size]}"
      },
      {
          namespace: "aws:ec2:vpc",
          option_name: "ELBSubnets",
          value: "#{@options[:vpc_elb_subnets]}"
      },
      {
          namespace: "aws:ec2:vpc",
          option_name: "Subnets",
          value: "#{@options[:vpc_ec2_subnets]}"
      },
      {
          namespace: "aws:autoscaling:launchconfiguration",
          option_name: "EC2KeyName",
          value: "#{@options[:key_name]}"
      },
    ],
  })

  puts "Environment update has started. This will take some time."
end

.update_environment_variablesObject



66
67
68
69
70
# File 'lib/stalkedbybean/env_vars.rb', line 66

def self.update_environment_variables
  system(
   "eb setenv #{@options[:env_vars]} --profile #{@options[:aws_profile]} --region #{@options[:aws_region]}"
  )
end