steampipe plugin install aws

Table: aws_lambda_event_source_mapping - Query AWS Lambda Event Source Mappings using SQL

The AWS Lambda Event Source Mapping is a service that enables the connection of a Lambda function to specific AWS services as an event source, triggering the function when records are available. This service allows you to read batches of records from the event source and invoke your function synchronously with an event that contains stream records. This mapping service is integral for applications that need to respond to data modifications in Amazon DynamoDB tables, Amazon Kinesis streams, and Amazon Simple Queue Service queues.

Table Usage Guide

The aws_lambda_event_source_mapping table in Steampipe provides you with information about event source mappings within AWS Lambda. This table allows you, as a DevOps engineer, to query mapping-specific details, including the source ARN, function ARN, batch size, and last processing result. You can utilize this table to gather insights on mappings, such as those with errors, the state of the mapping, the maximum record age, and more. The schema outlines for you the various attributes of the event source mapping, including the UUID, creation date, and associated tags.

Examples

Basic Info

Explore the status and configuration of AWS Lambda event source mappings to understand the efficiency of your serverless architecture. This can help identify any potential issues or bottlenecks in your application's event-driven processing.

select
arn,
function_arn,
function_name,
last_processing_result,
parallelization_factor,
state,
destination_config
from
aws_lambda_event_source_mapping;
select
arn,
function_arn,
function_name,
last_processing_result,
parallelization_factor,
state,
destination_config
from
aws_lambda_event_source_mapping;

List lambda event source mappings that are disabled

Identify instances where Lambda event source mappings are disabled to understand the areas in your AWS infrastructure that might not be processing events as expected.

select
function_name,
state,
last_modified,
state_transition_reason
from
aws_lambda_event_source_mapping
where
state = 'Disabled';
select
function_name,
state,
last_modified,
state_transition_reason
from
aws_lambda_event_source_mapping
where
state = 'Disabled';

Retrieve bootstrap server endpoints from a self-managed Kafka cluster integrated with AWS Lambda

Identify the bootstrap server endpoints within a self-managed Kafka cluster that's integrated with AWS Lambda. This can be useful for gaining insights into the event source mapping of your AWS Lambda functions. -- Returns the list of bootstrap servers for your Kafka brokers

-- function_name | jsonb_array_elements_text -- ---------------+--------------------------- -- myFunction | abc.xyz.com:xxxx -- myFunction | abc2.xyz.com:xxxx

select
function_name,
jsonb_array_elements_text(
jsonb_extract_path(
self_managed_event_source,
'Endpoints',
'KAFKA_BOOTSTRAP_SERVERS'
)
)
from
aws_lambda_event_source_mapping;
select
function_name,
json_extract(
json_extract(self_managed_event_source, '$.Endpoints'),
'$.KAFKA_BOOTSTRAP_SERVERS'
)
from
aws_lambda_event_source_mapping;

Get source access configuration of event source mappings

Discover the configurations of event source access in your AWS Lambda setup. This query is useful to understand the types and URLs of source access, which can help in managing and troubleshooting your Lambda functions.

select
uuid,
arn,
a ->> 'Type' as source_access_type,
a ->> 'URL' as source_access_url
from
aws_lambda_event_source_mapping,
jsonb_array_elements(source_access_configurations) as a;
select
uuid,
arn,
json_extract(a.value, '$.Type') as source_access_type,
json_extract(a.value, '$.URL') as source_access_url
from
aws_lambda_event_source_mapping,
json_each(source_access_configurations) as a;

Get scaling configuration details of event source mappings

Analyze the scaling configuration of event source mappings to understand the maximum concurrency level. This is useful in managing and optimizing the performance of AWS Lambda functions.

select
uuid,
arn,
scaling_config ->> 'MaximumConcurrency' as maximum_concurrency
from
aws_lambda_event_source_mapping;
select
uuid,
arn,
json_extract(scaling_config, '$.MaximumConcurrency') as maximum_concurrency
from
aws_lambda_event_source_mapping;

Get destionation configuration of event source mappings

Explore the success and failure configurations of event source mappings in AWS Lambda. This could be useful to understand how your system behaves under different outcomes of the event source mapping.

select
uuid,
function_name,
destination_config ->> 'OnFailure' as on_failure,
destination_config ->> 'OnSuccess' as on_success
from
aws_lambda_event_source_mapping;
select
uuid,
function_name,
json_extract(destination_config, '$.OnFailure') as on_failure,
json_extract(destination_config, '$.OnSuccess') as on_success
from
aws_lambda_event_source_mapping;

List AWS Lambda event source mappings with specific filter criteria patterns

Determine the areas in which specific filter criteria patterns are applied in AWS Lambda event source mappings. This can be useful to pinpoint specific locations where certain metadata patterns are used, allowing for more targeted management and optimization of serverless computing services.

select
uuid,
arn,
function_arn,
state,
filter ->> 'Pattern' as filter_criteria_pattern
from
aws_lambda_event_source_mapping,
jsonb_array_elements(filter_criteria -> 'Filters') as filter
where
filter ->> 'Pattern' like '{ \"Metadata\" : [ 1, 2 ]}';
select
uuid,
arn,
function_arn,
state,
json_extract(filter.value, '$.Pattern') as filter_criteria_pattern
from
aws_lambda_event_source_mapping,
json_each(filter_criteria, '$.Filters') as filter
where
json_extract(filter.value, '$.Pattern') like '{ "Metadata" : [ 1, 2 ]}';

Get lambda function details of each event source mapping

Explore the relationship between Lambda functions and their respective event source mappings in AWS to understand how they interact. This is particularly useful for auditing and optimizing your serverless architecture.

select
m.arn,
m.function_arn,
f.runtime,
f.handler,
f.architectures
from
aws_lambda_event_source_mapping as m,
aws_lambda_function as f
where
f.name = m.function_name;
select
m.arn,
m.function_arn,
f.runtime,
f.handler,
f.architectures
from
aws_lambda_event_source_mapping as m
join aws_lambda_function as f on f.name = m.function_name;

Schema for aws_lambda_event_source_mapping

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form.
account_idtext=, !=, ~~, ~~*, !~~, !~~*The AWS Account ID in which the resource is located.
amazon_managed_kafka_event_source_configjsonbSpecific configuration settings for an Amazon Managed Streaming for Apache Kafka.
arntext=The Amazon Resource Name (ARN) of the event source.
batch_sizebigintThe maximum number of records in each batch that Lambda pulls from your stream or queue and sends to your function.
bisect_batch_on_function_errorbooleanIf the function returns an error, split the batch in two and retry.
destination_configjsonbAn Amazon SQS queue or Amazon SNS topic destination for discarded records.
filter_criteriajsonbAn object that defines the filter criteria that determine whether Lambda should process an event.
function_arntext=The ARN of the Lambda function.
function_nametext=The name of the Lambda function.
function_response_typesjsonbA list of current response type enums applied to the event source mapping.
last_modifiedtimestamp with time zoneThe date that the event source mapping was last updated or that its state changed.
last_processing_resulttextThe result of the last Lambda invocation of your function.
maximum_batching_window_in_secondsbigintThe maximum amount of time, in seconds, that Lambda spends gathering records before invoking the function.
maximum_record_age_in_secondsbigintDiscard records older than the specified age.
maximum_retry_attemptsbigintDiscard records after the specified number of retries.
parallelization_factorbigintThe number of batches to process concurrently from each shard.
partitiontextThe AWS partition in which the resource is located (aws, aws-cn, or aws-us-gov).
queuesjsonbThe name of the Amazon MQ broker destination queue to consume.
regiontextThe AWS Region in which the resource is located.
scaling_configjsonbThe scaling configuration for the event source.
self_managed_event_sourcejsonbThe self-managed Apache Kafka cluster for your event source.
self_managed_kafka_event_source_configjsonbSpecific configuration settings for a self-managed Apache Kafka event source.
source_access_configurationsjsonbAn array of the authentication protocol, VPC components, or virtual host to secure and define your event source.
sp_connection_nametext=, !=, ~~, ~~*, !~~, !~~*Steampipe connection name.
sp_ctxjsonbSteampipe context in JSON form.
starting_positiontextThe position in a stream from which to start reading. Required for Amazon Kinesis and Amazon DynamoDB Stream event sources. AT_TIMESTAMP is supported only for Amazon Kinesis streams, Amazon DocumentDB, Amazon MSK, and self-managed Apache Kafka.
starting_position_timestamptimestamp with time zoneThe position in a stream from which to start reading. With StartingPosition set to AT_TIMESTAMP, the time from which to start reading, in Unix time seconds. StartingPositionTimestamp cannot be in the future.
statetextThe state of the event source mapping.
state_transition_reasontextIndicates whether a user or Lambda made the last change to the event source mapping.
titletextTitle of the resource.
topicsjsonbThe name of the Kafka topic.
tumbling_window_in_secondsbigintThe duration in seconds of a processing window for DynamoDB and Kinesis Streams event sources. A value of 0 seconds indicates no tumbling window.
uuidtext=The identifier of the event source mapping.

Export

This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- aws

You can pass the configuration to the command with the --config argument:

steampipe_export_aws --config '<your_config>' aws_lambda_event_source_mapping