Class: Glue

Inherits:
Mapper show all
Defined in:
lib/aws_recon/collectors/glue.rb

Overview

Collect Glue resources

Constant Summary

Constants inherited from Mapper

Mapper::SINGLE_REGION_SERVICES

Instance Method Summary collapse

Methods inherited from Mapper

#initialize

Constructor Details

This class inherits a constructor from Mapper

Instance Method Details

#collectObject

Returns an array of resources.



10
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
65
66
67
68
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
110
111
112
113
114
115
# File 'lib/aws_recon/collectors/glue.rb', line 10

def collect
  resources = []
  #
  # get_data_catalog_encryption_settings
  #
  @client.get_data_catalog_encryption_settings.each_with_index do |response, page|
    log(response.context.operation_name, page)

    struct = OpenStruct.new(response.to_h)
    struct.type = 'catalog_encryption_settings'
    struct.arn = "arn:aws:glue:#{@region}:#{@account}:data-catalog-encryption-settings" # no true ARN
    resources.push(struct.to_h)
  end

  #
  # get_security_configurations
  #
  @client.get_security_configurations.each_with_index do |response, page|
    log(response.context.operation_name, page)

    response.security_configurations.each do |security_configuration|
      struct = OpenStruct.new(security_configuration.to_h)
      struct.type = 'security_configuration'
      struct.arn = "arn:aws:glue:#{@region}:#{@account}:security-configuration/#{security_configuration.name}" # no true ARN
      resources.push(struct.to_h)
    end
  end

  #
  # get_databases
  #
  @client.get_databases.each_with_index do |response, page|
    log(response.context.operation_name, page)

    response.database_list.each do |database|
      struct = OpenStruct.new(database.to_h)
      struct.type = 'database'
      struct.arn = "arn:aws:glue:#{@region}:#{@account}:database/#{database.name}"

      #
      # get_tables
      #
      tables = @client.get_tables({ database_name: database.name })
      struct.tables = tables.to_h

      resources.push(struct.to_h)
    end
  end

  #
  # get_jobs
  #
  @client.get_jobs.each_with_index do |response, page|
    log(response.context.operation_name, page)

    response.jobs.each do |job|
      struct = OpenStruct.new(job.to_h)
      struct.type = 'job'
      struct.arn = "arn:aws:glue:#{@region}:#{@account}:job/#{job.name}"
      resources.push(struct.to_h)
    end
  end

  #
  # get_dev_endpoints
  #
  @client.get_dev_endpoints.each_with_index do |response, page|
    log(response.context.operation_name, page)

    response.dev_endpoints.each do |dev_endpoint|
      struct = OpenStruct.new(dev_endpoint.to_h)
      struct.type = 'dev_endpoint'
      struct.arn = "arn:aws:glue:#{@region}:#{@account}:devEndpoint/#{dev_endpoint.endpoint_name}"
      resources.push(struct.to_h)
    end
  end

  #
  # get_crawlers
  #
  @client.get_crawlers.each_with_index do |response, page|
    log(response.context.operation_name, page)

    response.crawlers.each do |crawler|
      struct = OpenStruct.new(crawler.to_h)
      struct.type = 'crawler'
      struct.arn = "arn:aws:glue:#{@region}:#{@account}:crawler/#{crawler.name}"
      resources.push(struct.to_h)
    end
  end

  #
  # get_connections
  #
  @client.get_connections.each_with_index do |response, page|
    log(response.context.operation_name, page)

    response.connection_list.each do |connection|
      struct = OpenStruct.new(connection.to_h)
      struct.type = 'connection'
      struct.arn = "arn:aws:glue:#{@region}:#{@account}:connection/#{connection.name}"
      resources.push(struct.to_h)
    end
  end
  resources
end