Class: Dev::Template::Aws

Inherits:
BaseInterface show all
Defined in:
lib/firespring_dev_commands/templates/aws.rb,
lib/firespring_dev_commands/templates/ci.rb,
lib/firespring_dev_commands/templates/aws/services/route53.rb

Overview

Class contains rake templates for managing your AWS settings and logging in

Defined Under Namespace

Modules: Services Classes: Ci

Instance Attribute Summary

Attributes inherited from BaseInterface

#exclude

Instance Method Summary collapse

Methods inherited from BaseInterface

#create_tasks!, #initialize

Constructor Details

This class inherits a constructor from Dev::Template::BaseInterface

Instance Method Details

#create_ensure_credentials_task!Object

Create the rake task which ensures active credentials are present



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/firespring_dev_commands/templates/aws.rb', line 8

def create_ensure_credentials_task!
  # Have to set a local variable to be accessible inside of the instance_eval block
  exclude = @exclude

  DEV_COMMANDS_TOP_LEVEL.instance_eval do
    return if exclude.include?(:ensure_aws_credentials)

    task ensure_aws_credentials: %w(init) do
      raise 'AWS Credentials not found / expired' unless Dev::Aws::Credentials.new.active?
    end
  end
end

#create_eol_task!Object

Create the rake task for the eol method



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/firespring_dev_commands/templates/aws.rb', line 112

def create_eol_task!
  # Have to set a local variable to be accessible inside of the instance_eval block
  exclude = @exclude

  DEV_COMMANDS_TOP_LEVEL.instance_eval do
    return if exclude.include?(:eol)

    task eol: [:'eol:aws'] do
      # This is just a placeholder to execute the dependencies
    end

    namespace :eol do
      desc 'Compares the current date to the EOL date for supported aws resources'
      task aws: %w(init ensure_aws_credentials) do
        next if ENV.fetch('CHECK_AWS', nil).to_s.strip == 'false'

        aws_products = Dev::EndOfLife::Aws.new.default_products
        next if aws_products.empty?

        puts
         = Dev::Aws::Profile.new.current
         = Dev::Aws::Account.new.()
        puts "AWS product versions (in account #{} / #{})".light_yellow
        Dev::EndOfLife.new(product_versions: aws_products).status
      end
    end
  end
end

#create_login_task!Object

Create the rake task for the aws credentials setup and login method



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/firespring_dev_commands/templates/aws.rb', line 69

def 
  # Have to set a local variable to be accessible inside of the instance_eval block
  exclude = @exclude

  DEV_COMMANDS_TOP_LEVEL.instance_eval do
    namespace :aws do
      return if exclude.include?(:login)

      namespace :configure do
        desc 'Configure the default AWS login settings'
        task default: %w(init default:credentials default:config) do
          puts
        end

        namespace :default do
          desc 'Configure the default AWS login credentials' \
               "\n\t(primarily used for rotating access keys)"
          task credentials: %w(init) do
            Dev::Aws::Credentials.new.base_setup!
          end

          task config: %w(init) do
            Dev::Aws::Account.new.base_setup!
          end
        end

        Dev::Aws::Account.new.children.each do ||
          desc "Configure the #{.name} account login settings"
          task .id => %w(init) do
            Dev::Aws::Account.new.setup!(.id)
          end
        end
      end

      desc 'Select the account you wish to log in to'
      task login: %w(init) do
        Dev::Aws::Login.new.login!
      end
    end
  end
end

#create_profile_task!Object

Create the rake task for the aws profile method



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
# File 'lib/firespring_dev_commands/templates/aws.rb', line 38

def create_profile_task!
  # Have to set a local variable to be accessible inside of the instance_eval block
  exclude = @exclude

  DEV_COMMANDS_TOP_LEVEL.instance_eval do
    namespace :aws do
      return if exclude.include?(:profile)

      desc 'Show the current profile/aws account you are configured to use'
      task profile: %w(init) do
        Dev::Aws::Profile.new.info
      end

      namespace :profile do
        desc 'Return the commands to export your AWS credentials into your environment'
        task :export do
          # Turn off all logging except for errors
          LOG.level = Logger::ERROR

          # Run the init
          Rake::Task[:init].invoke

          # Print the export info
          Dev::Aws::Profile.new.export_info
        end
      end
    end
  end
end

#create_show_account_info_task!Object

Create the rake task which shows the current AWS account information



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/firespring_dev_commands/templates/aws.rb', line 22

def 
  # Have to set a local variable to be accessible inside of the instance_eval block
  exclude = @exclude

  DEV_COMMANDS_TOP_LEVEL.instance_eval do
    return if exclude.include?(:show_account_info)

    task show_account_info: %w(init ensure_aws_credentials) do
       = Dev::Aws::Credentials.new.
       = Dev::Aws::Account.new.()
      LOG.info "\n  Current AWS Account is #{} (#{})\n".light_yellow
    end
  end
end