Lambda · Identity

LambdaPermission

Manage resource-based invocation permissions for functions.

Generic driverUniform lifecycle
Scope
Composite
Spec fields
9
Outputs
3
Lookup
Supported

Resource definition

What this resource looks like

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

CUE example
resources: {
  workerSnsPermission: {
  	apiVersion: "praxis.io/alpha"
  	kind:       "LambdaPermission"
  	metadata: name: "\(_naming.prefix)-worker-sns-perm"
  	spec: {
  		region:       _naming.region
  		functionName: "${resources.worker.outputs.functionName}"
  		action:       "lambda:InvokeFunction"
  		principal:    "sns.amazonaws.com"
  		sourceArn:    "${resources.alertTopic.outputs.topicArn}"
  	}
  }
}

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

regionRequired

Region.

string
String
functionNameRequired

Function Name.

string
String
statementIdOptional

Statement ID.

string
String
actionOptional

Action.

string | *"lambda:InvokeFunction"
EnumDefault "lambda:InvokeFunction"
principalRequired

Principal.

string
String
sourceArnOptional

Source ARN.

string
String
sourceAccountOptional

Source Account.

string
String
eventSourceTokenOptional

Event Source Token.

string
String
qualifierOptional

Qualifier.

string
String

Observed values

Outputs

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

statementIdString
functionNameString
statementString

Read without ownership

Data-source lookup

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

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

#LambdaPermission: {
	apiVersion: "praxis.io/alpha"
	kind:       "LambdaPermission"
	metadata: {
		name: =~"^[a-zA-Z0-9][a-zA-Z0-9_-]{0,99}$"
	}
	spec: {
		region:            string
		functionName:      string
		statementId?:      string
		action?:           string | *"lambda:InvokeFunction"
		principal:         string
		sourceArn?:        string
		sourceAccount?:    string
		eventSourceToken?: string
		qualifier?:        string
	}
	outputs?: {
		statementId:  string
		functionName: string
		statement:    string
	}
}

View this schema on GitHub →