Lambda · Compute

LambdaLayer

Publish and track reusable Lambda layers.

Generic driverUniform lifecycle
Scope
Regional
Spec fields
8
Outputs
7
Lookup
Supported

Resource definition

What this resource looks like

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

CUE example
resources: {
  sharedLayer: {
  	apiVersion: "praxis.io/alpha"
  	kind:       "LambdaLayer"
  	metadata: name: "\(_naming.prefix)-shared-layer"
  	spec: {
  		region:      _naming.region
  		description: "Shared utilities for \(_naming.prefix) workers"
  		compatibleRuntimes: ["provided.al2023"]
  		compatibleArchitectures: ["x86_64", "arm64"]
  		code: s3: {
  			bucket: "${resources.bucket-assets.outputs.bucketName}"
  			key:    "layers/shared-layer.zip"
  		}
  	}
  }
}

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 8 fields. 2 are required by the schema; fields with defaults can be omitted.

regionRequired

Region.

string
String
accountOptional

Account.

string
String
descriptionOptional

Description.

string
String
licenseInfoOptional

License Info.

string
String
compatibleRuntimesOptional

Compatible Runtimes.

[...string]
List
compatibleArchitecturesOptional

Compatible Architectures.

[..."x86_64" | "arm64"]
List
codeRequired

Code.

{ s3?: { bucket: string key: string objectVersion?: string } zipFile?: string & =~"^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" }
Object
permissionsOptional

Permissions.

{ accountIds?: [...string] public?: bool }
Object

Observed values

Outputs

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

layerArnString
layerVersionArnString
layerNameString
versionInteger
codeSizeInteger
codeSha256String · optional
createdDateString · optional

Read without ownership

Data-source lookup

A data block reads an existing LambdaLayer 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: "LambdaLayer"
  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 LambdaLayer. The example starts in observed mode so Praxis reports drift without correcting it.

CLI
praxis import LambdaLayer \
  --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/layer.cue
package lambda

#LambdaLayer: {
	apiVersion: "praxis.io/alpha"
	kind:       "LambdaLayer"
	metadata: {
		name: =~"^[A-Za-z0-9-_]+$"
	}
	spec: {
		region:       string
		account?:     string
		description?: string
		licenseInfo?: string
		compatibleRuntimes?: [...string]
		compatibleArchitectures?: [..."x86_64" | "arm64"]
		code: {
			s3?: {
				bucket:         string
				key:            string
				objectVersion?: string
			}
			// zipFile must be a base64-encoded deployment package.
			zipFile?: string & =~"^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
		}
		permissions?: {
			accountIds?: [...string]
			public?: bool
		}
	}
	outputs?: {
		layerArn:        string
		layerVersionArn: string
		layerName:       string
		version:         int
		codeSize:        int
		codeSha256?:     string
		createdDate?:    string
	}
}

View this schema on GitHub →