github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/sns/getTopic.go (about) 1 // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT. 2 // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 4 package sns 5 6 import ( 7 "context" 8 "reflect" 9 10 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 11 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 12 ) 13 14 // Use this data source to get the ARN of a topic in AWS Simple Notification 15 // Service (SNS). By using this data source, you can reference SNS topics 16 // without having to hard code the ARNs as input. 17 // 18 // ## Example Usage 19 // 20 // <!--Start PulumiCodeChooser --> 21 // ```go 22 // package main 23 // 24 // import ( 25 // 26 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/sns" 27 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 28 // 29 // ) 30 // 31 // func main() { 32 // pulumi.Run(func(ctx *pulumi.Context) error { 33 // _, err := sns.LookupTopic(ctx, &sns.LookupTopicArgs{ 34 // Name: "an_example_topic", 35 // }, nil) 36 // if err != nil { 37 // return err 38 // } 39 // return nil 40 // }) 41 // } 42 // 43 // ``` 44 // <!--End PulumiCodeChooser --> 45 func LookupTopic(ctx *pulumi.Context, args *LookupTopicArgs, opts ...pulumi.InvokeOption) (*LookupTopicResult, error) { 46 opts = internal.PkgInvokeDefaultOpts(opts) 47 var rv LookupTopicResult 48 err := ctx.Invoke("aws:sns/getTopic:getTopic", args, &rv, opts...) 49 if err != nil { 50 return nil, err 51 } 52 return &rv, nil 53 } 54 55 // A collection of arguments for invoking getTopic. 56 type LookupTopicArgs struct { 57 // Friendly name of the topic to match. 58 Name string `pulumi:"name"` 59 } 60 61 // A collection of values returned by getTopic. 62 type LookupTopicResult struct { 63 // ARN of the found topic, suitable for referencing in other resources that support SNS topics. 64 Arn string `pulumi:"arn"` 65 // The provider-assigned unique ID for this managed resource. 66 Id string `pulumi:"id"` 67 Name string `pulumi:"name"` 68 } 69 70 func LookupTopicOutput(ctx *pulumi.Context, args LookupTopicOutputArgs, opts ...pulumi.InvokeOption) LookupTopicResultOutput { 71 return pulumi.ToOutputWithContext(context.Background(), args). 72 ApplyT(func(v interface{}) (LookupTopicResult, error) { 73 args := v.(LookupTopicArgs) 74 r, err := LookupTopic(ctx, &args, opts...) 75 var s LookupTopicResult 76 if r != nil { 77 s = *r 78 } 79 return s, err 80 }).(LookupTopicResultOutput) 81 } 82 83 // A collection of arguments for invoking getTopic. 84 type LookupTopicOutputArgs struct { 85 // Friendly name of the topic to match. 86 Name pulumi.StringInput `pulumi:"name"` 87 } 88 89 func (LookupTopicOutputArgs) ElementType() reflect.Type { 90 return reflect.TypeOf((*LookupTopicArgs)(nil)).Elem() 91 } 92 93 // A collection of values returned by getTopic. 94 type LookupTopicResultOutput struct{ *pulumi.OutputState } 95 96 func (LookupTopicResultOutput) ElementType() reflect.Type { 97 return reflect.TypeOf((*LookupTopicResult)(nil)).Elem() 98 } 99 100 func (o LookupTopicResultOutput) ToLookupTopicResultOutput() LookupTopicResultOutput { 101 return o 102 } 103 104 func (o LookupTopicResultOutput) ToLookupTopicResultOutputWithContext(ctx context.Context) LookupTopicResultOutput { 105 return o 106 } 107 108 // ARN of the found topic, suitable for referencing in other resources that support SNS topics. 109 func (o LookupTopicResultOutput) Arn() pulumi.StringOutput { 110 return o.ApplyT(func(v LookupTopicResult) string { return v.Arn }).(pulumi.StringOutput) 111 } 112 113 // The provider-assigned unique ID for this managed resource. 114 func (o LookupTopicResultOutput) Id() pulumi.StringOutput { 115 return o.ApplyT(func(v LookupTopicResult) string { return v.Id }).(pulumi.StringOutput) 116 } 117 118 func (o LookupTopicResultOutput) Name() pulumi.StringOutput { 119 return o.ApplyT(func(v LookupTopicResult) string { return v.Name }).(pulumi.StringOutput) 120 } 121 122 func init() { 123 pulumi.RegisterOutputType(LookupTopicResultOutput{}) 124 }