1. Packages
  2. AWS
  3. API Docs
  4. sns
  5. getTopic
AWS v6 v6.83.2 published on Thursday, Nov 20, 2025 by Pulumi
aws-v6 logo
AWS v6 v6.83.2 published on Thursday, Nov 20, 2025 by Pulumi

    Use this data source to get the ARN of a topic in AWS Simple Notification Service (SNS). By using this data source, you can reference SNS topics without having to hard code the ARNs as input.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const example = aws.sns.getTopic({
        name: "an_example_topic",
    });
    
    import pulumi
    import pulumi_aws as aws
    
    example = aws.sns.get_topic(name="an_example_topic")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/sns"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := sns.LookupTopic(ctx, &sns.LookupTopicArgs{
    			Name: "an_example_topic",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Aws.Sns.GetTopic.Invoke(new()
        {
            Name = "an_example_topic",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.sns.SnsFunctions;
    import com.pulumi.aws.sns.inputs.GetTopicArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var example = SnsFunctions.getTopic(GetTopicArgs.builder()
                .name("an_example_topic")
                .build());
    
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: aws:sns:getTopic
          arguments:
            name: an_example_topic
    

    Using getTopic

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getTopic(args: GetTopicArgs, opts?: InvokeOptions): Promise<GetTopicResult>
    function getTopicOutput(args: GetTopicOutputArgs, opts?: InvokeOptions): Output<GetTopicResult>
    def get_topic(name: Optional[str] = None,
                  tags: Optional[Mapping[str, str]] = None,
                  opts: Optional[InvokeOptions] = None) -> GetTopicResult
    def get_topic_output(name: Optional[pulumi.Input[str]] = None,
                  tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
                  opts: Optional[InvokeOptions] = None) -> Output[GetTopicResult]
    func LookupTopic(ctx *Context, args *LookupTopicArgs, opts ...InvokeOption) (*LookupTopicResult, error)
    func LookupTopicOutput(ctx *Context, args *LookupTopicOutputArgs, opts ...InvokeOption) LookupTopicResultOutput

    > Note: This function is named LookupTopic in the Go SDK.

    public static class GetTopic 
    {
        public static Task<GetTopicResult> InvokeAsync(GetTopicArgs args, InvokeOptions? opts = null)
        public static Output<GetTopicResult> Invoke(GetTopicInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetTopicResult> getTopic(GetTopicArgs args, InvokeOptions options)
    public static Output<GetTopicResult> getTopic(GetTopicArgs args, InvokeOptions options)
    
    fn::invoke:
      function: aws:sns/getTopic:getTopic
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Name string
    Friendly name of the topic to match.
    Tags Dictionary<string, string>
    Map of tags for the resource.
    Name string
    Friendly name of the topic to match.
    Tags map[string]string
    Map of tags for the resource.
    name String
    Friendly name of the topic to match.
    tags Map<String,String>
    Map of tags for the resource.
    name string
    Friendly name of the topic to match.
    tags {[key: string]: string}
    Map of tags for the resource.
    name str
    Friendly name of the topic to match.
    tags Mapping[str, str]
    Map of tags for the resource.
    name String
    Friendly name of the topic to match.
    tags Map<String>
    Map of tags for the resource.

    getTopic Result

    The following output properties are available:

    Arn string
    ARN of the found topic, suitable for referencing in other resources that support SNS topics.
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    Tags Dictionary<string, string>
    Map of tags for the resource.
    Arn string
    ARN of the found topic, suitable for referencing in other resources that support SNS topics.
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    Tags map[string]string
    Map of tags for the resource.
    arn String
    ARN of the found topic, suitable for referencing in other resources that support SNS topics.
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    tags Map<String,String>
    Map of tags for the resource.
    arn string
    ARN of the found topic, suitable for referencing in other resources that support SNS topics.
    id string
    The provider-assigned unique ID for this managed resource.
    name string
    tags {[key: string]: string}
    Map of tags for the resource.
    arn str
    ARN of the found topic, suitable for referencing in other resources that support SNS topics.
    id str
    The provider-assigned unique ID for this managed resource.
    name str
    tags Mapping[str, str]
    Map of tags for the resource.
    arn String
    ARN of the found topic, suitable for referencing in other resources that support SNS topics.
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    tags Map<String>
    Map of tags for the resource.

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws-v6 logo
    AWS v6 v6.83.2 published on Thursday, Nov 20, 2025 by Pulumi
      Meet Neo: Your AI Platform Teammate