AwsSns

Service-level AWS SNS component.

Remarks

This is the primary component resource for the package. It can orchestrate creation of SNS topic, topic policy, topic subscription, and data protection policy capabilities through a single component boundary.

Naming:

  • Type token: ${namespace}:aws:AwsSns. Capability literals are topic, topic-policy, topic-subscription, and data-protection-policy. Roots use ${env}-${projectHash}-<capability>-<sanitised identity> through buildComponentLogicalName. args.topic.name is shared logical/provider identity; args.topicPolicy.identity, args.topicSubscription.identity, and args.dataProtectionPolicy.identity are logical-only. Raw identities retain non-canonical normalisation, including dots.
  • Every child is parented by AwsSns. aws.sns.Topic uses args.topic.name; aws.sns.TopicPolicy uses args.topicPolicy.identity; aws.sns.TopicSubscription uses args.topicSubscription.identity; and aws.sns.DataProtectionPolicy uses args.dataProtectionPolicy.identity. Each ordered readable tuple contains only that raw root identity and renders ${env}-${projectHash}-<sanitised identity>.
  • aws.sns.Topic.name uses stackAndPurpose from args.topic.name: ${env}-${projectHash}-${purpose}. FIFO topics append AWS-required .fifo. SNS permits 256 characters; the purpose is limited to 243 characters for standard topics and 238 characters for FIFO topics so the rendered provider name never exceeds that limit. Provider-name bytes remain unchanged for valid inputs.
  • Topic policy, subscription, and data-protection-policy have no component-controlled provider name. Their semantic ARN comes from topicArn/topic, is trimmed and otherwise forwarded unchanged; the provider owns ARN validation. Logical-only identity is never forwarded.
  • Lambda invoke permissions are owned by the referenced Lambda component. A managed Lambda subscription supplies only args.topicSubscription.identity as its source-side relationship identity; the Lambda component separately adds the function identity and sns service discriminator.

Example

CODE
const topic = new AwsSns({
  topic: {
    name: 'applicationEvents',
    displayName: 'application-events',
  },
});

const topicWithProjectKey = new AwsSns({
  topic: {
    name: 'applicationEventsProjectKey',
    displayName: 'application-events-project-key',
    kmsKey: { identifier: 'alias/myproject/stage' },
  },
});

const topicWithDefaultEncryption = new AwsSns({
  topic: {
    name: 'applicationEventsDefaultEncryption',
    displayName: 'application-events-default-encryption',
  },
});

const topicPolicy = new AwsSns({
  topicPolicy: {
    identity: 'applicationEventsPolicy',
    topicArn: topic.topic!.arn,
    policy: aws.iam.getPolicyDocumentOutput({
      statements: [],
    }).json,
  },
});

const subscription = new AwsSns({
  topicSubscription: {
    identity: 'applicationEventsSubscription',
    topic: topic.topic!.arn,
    protocol: 'sqs',
    endpoint: queue.arn,
  },
});

Constructors

new AwsSns( args: AwsSnsArgs, options?: ComponentResourceOptions, ): AwsSns

Parameters

  • args (AwsSnsArgs) — Service-level SNS capability inputs.The component logical name is derived from capability identity inputs.
  • options (ComponentResourceOptions, optional) — Optional settings controlling resource behaviour.

Returns

AwsSns

Hierarchy

  • ComponentResource
  • AwsSns

Properties

dataProtectionPolicy: AwsSnsDataProtectionPolicy

readonly

Optional SNS data protection policy capability created by this component.

lambdaInvokePermission: Resource

readonly

Optional Lambda invoke permission created for a managed Lambda subscription.

topic: AwsSnsTopic

readonly

Optional SNS topic capability created by this component.

topicPolicy: AwsSnsTopicPolicy

readonly

Optional SNS topic policy capability created by this component.

topicSubscription: AwsSnsTopicSubscription

readonly

Optional SNS topic subscription capability created by this component.

urn: Output<string>

readonly

Inherited from urn

The stable logical URN used to distinctly address a resource, both before and after deployments.

Methods

getData(): Promise<any>

protectedasync

Inherited from getData

Retrieves the data produces by initialize. The data is immediately available in a derived class's constructor after the super(...) call to ComponentResource.

Returns

  • Promise<any>

getProvider(moduleMember: string): ProviderResource | undefined

Inherited from getProvider

Returns the provider for the given module member, if one exists.

Parameters

  • moduleMember (string)

Returns

  • ProviderResource | undefined

initialize( args: Inputs, opts?: ComponentResourceOptions, name?: string, type?: string, ): Promise<any>

protectedasync

Inherited from initialize

Can be overridden by a subclass to asynchronously initialize data for this component automatically when constructed. The data will be available immediately for subclass constructors to use. To access the data use getData.

Parameters

  • args (Inputs)
  • opts (ComponentResourceOptions, optional)
  • name (string, optional)
  • type (string, optional)

Returns

  • Promise<any>

registerOutputs( outputs?: Inputs | Promise<Inputs> | Output<Inputs>, ): void

protected

Inherited from registerOutputs

Registers synthetic outputs that a component has initialized, usually by allocating other child sub-resources and propagating their resulting property values.

Component resources can call this at the end of their constructor to indicate that they are done creating child resources. This is not strictly necessary as this will automatically be called after the initialize method completes.

Parameters

  • outputs (Inputs | Promise<Inputs> | Output<Inputs>, optional)

Returns

  • void

Static Methods

isInstance(obj: any): obj is ComponentResource<any>

static

Inherited from isInstance

Returns true if the given object is a CustomResource. This is designed to work even when multiple copies of the Pulumi SDK have been loaded into the same process.

Parameters

  • obj (any)

Returns

  • obj is ComponentResource<any>