Lambda · Compute

EventSourceMapping

Connect Lambda functions to streams and queues.

Generic driverUniform lifecycle
Scope
Composite
Spec fields
17
Outputs
6
Lookup
Supported

Resource definition

What this resource looks like

This is the CUE shape a Praxis template uses to declare a EventSourceMapping. The resource key is local to the template; metadata.name supplies its stable Praxis identity.

CUE example
resources: {
  workerDlqTrigger: {
  	apiVersion: "praxis.io/alpha"
  	kind:       "EventSourceMapping"
  	metadata: name: "\(_naming.prefix)-worker-sqs-trigger"
  	spec: {
  		region:                           _naming.region
  		functionName:                     "${resources.worker.outputs.functionName}"
  		eventSourceArn:                   "${resources.dlq.outputs.queueArn}"
  		batchSize:                        10
  		maximumBatchingWindowInSeconds:    60
  		enabled:                          true
  		functionResponseTypes: ["ReportBatchItemFailures"]
  	}
  }
}

Excerpted from examples/stacks/end-to-end.cue. Open the complete example for its variables and related resources.

Complete examples in the repository

Desired state

Configuration

The spec block accepts 17 fields. 3 are required by the schema; fields with defaults can be omitted.

regionRequired

Region.

string
String
functionNameRequired

Function Name.

string
String
eventSourceArnRequired

Event Source ARN.

string
String
enabledOptional

Enabled.

bool | *true
BooleanDefault true
batchSizeOptional

Batch Size.

int & >=1 & <=10000
Integer
maximumBatchingWindowInSecondsOptional

Maximum Batching Window In Seconds.

int & >=0 & <=300
Integer
startingPositionOptional

Starting Position.

"TRIM_HORIZON" | "LATEST" | "AT_TIMESTAMP"
Enum
startingPositionTimestampOptional

Starting Position Timestamp.

string
String
filterCriteriaOptional

Filter Criteria.

filters: [...{ pattern: string }]
Object
bisectBatchOnFunctionErrorOptional

Bisect Batch On Function Error.

bool
Boolean
maximumRetryAttemptsOptional

Maximum Retry Attempts.

int & >=-1 & <=10000
Integer
maximumRecordAgeInSecondsOptional

Maximum Record Age In Seconds.

int & >=-1 & <=604800
Integer
parallelizationFactorOptional

Parallelization Factor.

int & >=1 & <=10
Integer
tumblingWindowInSecondsOptional

Tumbling Window In Seconds.

int & >=0 & <=900
Integer
destinationConfigOptional

Destination Config.

onFailure: destinationArn: string
Object
scalingConfigOptional

Scaling Config.

maximumConcurrency: int & >=2 & <=1000
Object
functionResponseTypesOptional

Function Response Types.

[...("ReportBatchItemFailures")]
List

Observed values

Outputs

Praxis records these values after observation. A dependent resource can read one with ${resources.<name>.outputs.<field>}.

uuidString
eventSourceArnString
functionArnString
stateString
lastModifiedString
batchSizeInteger

Read without ownership

Data-source lookup

A data block reads an existing EventSourceMapping and exposes its outputs without storing lifecycle state. The generic filter surface accepts id, name, and tag; supported combinations depend on the AWS identity used by this resource.

CUE data source
data: existing: {
  kind: "EventSourceMapping"
  region: "us-west-2"
  filter: {
    name: "replace-with-provider-name"
  }
}

Understand data sources and filters →

Adopt existing infrastructure

Import

Import persists Praxis state for an existing AWS resource. For this kind, supply: Provider identifier for the existing EventSourceMapping. The example starts in observed mode so Praxis reports drift without correcting it.

CLI
praxis import EventSourceMapping \
  --id <provider-identifier> \
  --region us-west-2 \
  --account production \
  --observe

Choose managed or observed ownership →

Canonical contract

Complete CUE schema

The field guide above is derived from this definition. The schema remains the source of truth for accepted values, defaults, validation constraints, and outputs in the current alpha revision.

Show the complete schema
schemas/aws/lambda/event_source_mapping.cue
package lambda

#EventSourceMapping: {
	apiVersion: "praxis.io/alpha"
	kind:       "EventSourceMapping"
	metadata: {
		name: =~"^[a-zA-Z0-9][a-zA-Z0-9._-]{0,254}$"
	}
	spec: {
		region:                          string
		functionName:                    string
		eventSourceArn:                  string
		enabled?:                        bool | *true
		batchSize?:                      int & >=1 & <=10000
		maximumBatchingWindowInSeconds?: int & >=0 & <=300
		startingPosition?:               "TRIM_HORIZON" | "LATEST" | "AT_TIMESTAMP"
		startingPositionTimestamp?:      string
		filterCriteria?: filters: [...{
			pattern: string
		}]
		bisectBatchOnFunctionError?: bool
		maximumRetryAttempts?:       int & >=-1 & <=10000
		maximumRecordAgeInSeconds?:  int & >=-1 & <=604800
		parallelizationFactor?:      int & >=1 & <=10
		tumblingWindowInSeconds?:    int & >=0 & <=900
		destinationConfig?: onFailure: destinationArn: string
		scalingConfig?: maximumConcurrency: int & >=2 & <=1000
		functionResponseTypes?: [...("ReportBatchItemFailures")]
	}
	outputs?: {
		uuid:           string
		eventSourceArn: string
		functionArn:    string
		state:          string
		lastModified:   string
		batchSize:      int
	}
}

View this schema on GitHub →