Sha256: 8279294396e1870a5c653664cf6f840f939ccb61d2a71799b8f05cd729a80f7c

Contents?: true

Size: 1.5 KB

Versions: 26

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

#
# Collect Lambda resources
#
class Lambda < Mapper
  def collect
    resources = []

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

      response.functions.each do |function|
        struct = OpenStruct.new(function)
        struct.type = 'function'
        struct.arn = function.function_arn
        struct.vpc_config = function.vpc_config.to_h
        struct.tracing_config = function.tracing_config.to_h
        struct.layers = function.layers ? function.layers.map(&:to_h) : []
        struct.policy = @client.get_policy({ function_name: function.function_name }).policy.parse_policy

      rescue Aws::Lambda::Errors::ResourceNotFoundException => e
        log_error(e.code)
      ensure
        resources.push(struct.to_h)
      end
    end

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

      response.layers.each do |layer|
        struct = OpenStruct.new(layer)
        struct.type = 'layer'
        struct.arn = layer.layer_arn
        struct.latest_matching_version = layer.latest_matching_version.to_h

        # list_layer_versions
        struct.versions = @client.list_layer_versions({ layer_name: layer.layer_name }).layer_versions.map(&:to_h)
        log(response.context.operation_name, 'list_layer_versions')

        resources.push(struct.to_h)
      end
    end

    resources
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
aws_recon-0.5.33 lib/aws_recon/collectors/lambda.rb
aws_recon-0.5.32 lib/aws_recon/collectors/lambda.rb
aws_recon-0.5.31 lib/aws_recon/collectors/lambda.rb
aws_recon-0.5.30 lib/aws_recon/collectors/lambda.rb
aws_recon-0.5.29 lib/aws_recon/collectors/lambda.rb
aws_recon-0.5.28 lib/aws_recon/collectors/lambda.rb
aws_recon-0.5.27 lib/aws_recon/collectors/lambda.rb
aws_recon-0.5.26 lib/aws_recon/collectors/lambda.rb
aws_recon-0.5.25 lib/aws_recon/collectors/lambda.rb
aws_recon-0.5.24 lib/aws_recon/collectors/lambda.rb
aws_recon-0.5.23 lib/aws_recon/collectors/lambda.rb
aws_recon-0.5.22 lib/aws_recon/collectors/lambda.rb
aws_recon-0.5.21 lib/aws_recon/collectors/lambda.rb
aws_recon-0.5.20 lib/aws_recon/collectors/lambda.rb
aws_recon-0.5.19 lib/aws_recon/collectors/lambda.rb
aws_recon-0.5.18 lib/aws_recon/collectors/lambda.rb
aws_recon-0.5.17 lib/aws_recon/collectors/lambda.rb
aws_recon-0.5.16 lib/aws_recon/collectors/lambda.rb
aws_recon-0.5.15 lib/aws_recon/collectors/lambda.rb
aws_recon-0.5.14 lib/aws_recon/collectors/lambda.rb