Class: Dev::Template::Aws::Services::Route53

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

Overview

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

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_dns_logging_activate_task!Object

Create the rake task for the hosted zone method



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

def create_dns_logging_activate_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?(:dns_logging)

      namespace :hosted_zone do
        namespace :dns_logging do
          desc 'Activates query logging for all hosted zones by default.' \
               'This command should be run from the account the hosted zone(s) reside.' \
               "\n\t(Required) Specify LOG_GROUP_ARN='arn:aws:logs:REGION:ACCOUNT_ID:' to specify the ARN of the target log group." \
               "\n\toptionally specify DOMAINS='foo.com,foobar.com' to specify the hosted zones to activate." \
               "\n\t\tComma delimited list."
          task activate: %w(ensure_aws_credentials) do
            route53 = Dev::Aws::Route53.new(ENV['DOMAINS'].to_s.strip.split(','))
            # Use user defined log group.
            log_group = ENV.fetch('LOG_GROUP_ARN', nil)
            raise 'The Hosted Zone Log Group ARN, LOG_GROUP_ARN, is required' unless log_group

            route53.activate_query_logging(log_group)
          end
        end
      end
    end
  end
end

#create_dns_logging_deactivate_task!Object

Create the rake task for the hosted zone method



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/firespring_dev_commands/templates/aws/services/route53.rb', line 54

def create_dns_logging_deactivate_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?(:dns_logging)

      namespace :hosted_zone do
        namespace :dns_logging do
          desc 'Deactivates query logging for all hosted zones by default. ' \
               'This command should be run from the account the hosted zone(s) reside.' \
               "\n\toptionally specify DOMAINS='foo.com,foobar.com' to specify the hosted zones to activate." \
               "\n\t\tComma delimited list."
          task deactivate: %w(ensure_aws_credentials) do
            route53 = Dev::Aws::Route53.new(ENV['DOMAINS'].to_s.strip.split(','))
            route53.deactivate_query_logging
          end
        end
      end
    end
  end
end

#create_ensure_credentials_task!Object

Create the rake task which ensures active credentials are present



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/firespring_dev_commands/templates/aws/services/route53.rb', line 10

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_list_query_config_task!Object

Create the rake task for the hosted zone method



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/firespring_dev_commands/templates/aws/services/route53.rb', line 79

def create_list_query_config_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?(:dns_logging)

      namespace :hosted_zone do
        namespace :dns_logging do
          desc 'Lists the current config for domain(s). ' \
               'This command should be run from the account the hosted zone(s) reside.' \
               "\n\toptionally specify DOMAINS='foo.com,foobar.com' to specify the hosted zones to activate." \
               "\n\t\tComma delimited list."
          task list_query_configs: %w(ensure_aws_credentials) do
            route53 = Dev::Aws::Route53.new(ENV['DOMAINS'].to_s.strip.split(','))
            route53.list_query_configs
          end
        end
      end
    end
  end
end