1. Packages
  2. AWS Classic
  3. API Docs
  4. sns
  5. getTopic

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi

aws.sns.getTopic

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 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,
                  opts: Optional[InvokeOptions] = None) -> GetTopicResult
    def get_topic_output(name: Optional[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)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: aws:sns/getTopic:getTopic
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Name string
    Friendly name of the topic to match.
    Name string
    Friendly name of the topic to match.
    name String
    Friendly name of the topic to match.
    name string
    Friendly name of the topic to match.
    name str
    Friendly name of the topic to match.
    name String
    Friendly name of the topic to match.

    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
    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
    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
    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
    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
    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

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi