SNS · Data

SNSSubscription

Connect SNS topics to HTTP, queue, email, or Lambda endpoints.

Generic driverUniform lifecycle
Scope
Composite
Spec fields
10
Outputs
5
Lookup
Supported

Resource definition

What this resource looks like

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

CUE example
resources: {
  alertToQueueSub: {
  	apiVersion: "praxis.io/alpha"
  	kind:       "SNSSubscription"
  	metadata: name: "\(_naming.prefix)-alert-to-dlq"
  	spec: {
  		region:             _naming.region
  		topicArn:           "${resources.alertTopic.outputs.topicArn}"
  		protocol:           "sqs"
  		endpoint:           "${resources.dlq.outputs.queueArn}"
  		rawMessageDelivery: true
  	}
  }
}

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

regionRequired

Region.

string
String
topicArnRequired

Topic ARN.

string & (=~"^arn:aws:sns:[a-z0-9-]+:[0-9]{12}:.+$" | =~"^\\$\\{resources\\..+\\}$")
Enum
protocolRequired

Protocol.

"http" | "https" | "email" | "email-json" | "sms" | "sqs" | "lambda" | "firehose" | "application"
Enum
endpointRequired

Endpoint.

string
String
filterPolicyOptional

Omitted optional attributes are declarative defaults/absence. Re-applying a spec without a previously configured value removes that provider value.

string
String
filterPolicyScopeOptional

Filter Policy Scope.

"MessageAttributes" | "MessageBody"
Enum
rawMessageDeliveryOptional

Raw Message Delivery.

bool
Boolean
deliveryPolicyOptional

Delivery Policy.

string
String
redrivePolicyOptional

Redrive Policy.

string
String
subscriptionRoleArnOptional

Subscription Role ARN.

string
String

Observed values

Outputs

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

subscriptionArnString
topicArnString
protocolString
endpointString
ownerString

Read without ownership

Data-source lookup

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

CLI
praxis import SNSSubscription \
  --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/sns/subscription.cue
package sns

#SNSSubscription: {
	apiVersion: "praxis.io/alpha"
	kind:       "SNSSubscription"

	metadata: {
		name: string & =~"^[a-zA-Z0-9][a-zA-Z0-9._-]{0,254}$"
		labels: [string]: string
	}

	spec: {
		region: string

		topicArn: string & (=~"^arn:aws:sns:[a-z0-9-]+:[0-9]{12}:.+$" | =~"^\\$\\{resources\\..+\\}$")

		protocol: "http" | "https" | "email" | "email-json" | "sms" | "sqs" | "lambda" | "firehose" | "application"

		endpoint: string

		// Omitted optional attributes are declarative defaults/absence. Re-applying
		// a spec without a previously configured value removes that provider value.
		filterPolicy?: string

		filterPolicyScope?: "MessageAttributes" | "MessageBody"

		rawMessageDelivery?: bool

		deliveryPolicy?: string

		redrivePolicy?: string

		subscriptionRoleArn?: string
	}

	outputs?: {
		subscriptionArn: string
		topicArn:        string
		protocol:        string
		endpoint:        string
		owner:           string
	}
}

View this schema on GitHub →