github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/getService.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 aws
     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 compose and decompose AWS service DNS names.
    15  //
    16  // ## Example Usage
    17  //
    18  // ### Get Service DNS Name
    19  //
    20  // <!--Start PulumiCodeChooser -->
    21  // ```go
    22  // package main
    23  //
    24  // import (
    25  //
    26  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
    27  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    28  //
    29  // )
    30  //
    31  //	func main() {
    32  //		pulumi.Run(func(ctx *pulumi.Context) error {
    33  //			current, err := aws.GetRegion(ctx, nil, nil)
    34  //			if err != nil {
    35  //				return err
    36  //			}
    37  //			_, err = aws.GetService(ctx, &aws.GetServiceArgs{
    38  //				Region:    pulumi.StringRef(current.Name),
    39  //				ServiceId: pulumi.StringRef("ec2"),
    40  //			}, nil)
    41  //			if err != nil {
    42  //				return err
    43  //			}
    44  //			return nil
    45  //		})
    46  //	}
    47  //
    48  // ```
    49  // <!--End PulumiCodeChooser -->
    50  //
    51  // ### Use Service Reverse DNS Name to Get Components
    52  //
    53  // <!--Start PulumiCodeChooser -->
    54  // ```go
    55  // package main
    56  //
    57  // import (
    58  //
    59  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
    60  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    61  //
    62  // )
    63  //
    64  //	func main() {
    65  //		pulumi.Run(func(ctx *pulumi.Context) error {
    66  //			_, err := aws.GetService(ctx, &aws.GetServiceArgs{
    67  //				ReverseDnsName: pulumi.StringRef("cn.com.amazonaws.cn-north-1.s3"),
    68  //			}, nil)
    69  //			if err != nil {
    70  //				return err
    71  //			}
    72  //			return nil
    73  //		})
    74  //	}
    75  //
    76  // ```
    77  // <!--End PulumiCodeChooser -->
    78  //
    79  // ### Determine Regional Support for a Service
    80  //
    81  // <!--Start PulumiCodeChooser -->
    82  // ```go
    83  // package main
    84  //
    85  // import (
    86  //
    87  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
    88  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    89  //
    90  // )
    91  //
    92  //	func main() {
    93  //		pulumi.Run(func(ctx *pulumi.Context) error {
    94  //			_, err := aws.GetService(ctx, &aws.GetServiceArgs{
    95  //				ReverseDnsName: pulumi.StringRef("com.amazonaws.us-gov-west-1.waf"),
    96  //			}, nil)
    97  //			if err != nil {
    98  //				return err
    99  //			}
   100  //			return nil
   101  //		})
   102  //	}
   103  //
   104  // ```
   105  // <!--End PulumiCodeChooser -->
   106  func GetService(ctx *pulumi.Context, args *GetServiceArgs, opts ...pulumi.InvokeOption) (*GetServiceResult, error) {
   107  	opts = internal.PkgInvokeDefaultOpts(opts)
   108  	var rv GetServiceResult
   109  	err := ctx.Invoke("aws:index/getService:getService", args, &rv, opts...)
   110  	if err != nil {
   111  		return nil, err
   112  	}
   113  	return &rv, nil
   114  }
   115  
   116  // A collection of arguments for invoking getService.
   117  type GetServiceArgs struct {
   118  	// DNS name of the service (_e.g.,_ `rds.us-east-1.amazonaws.com`). One of `dnsName`, `reverseDnsName`, or `serviceId` is required.
   119  	DnsName *string `pulumi:"dnsName"`
   120  	Id      *string `pulumi:"id"`
   121  	// Region of the service (_e.g.,_ `us-west-2`, `ap-northeast-1`).
   122  	Region *string `pulumi:"region"`
   123  	// Reverse DNS name of the service (_e.g.,_ `com.amazonaws.us-west-2.s3`). One of `dnsName`, `reverseDnsName`, or `serviceId` is required.
   124  	ReverseDnsName *string `pulumi:"reverseDnsName"`
   125  	// Prefix of the service (_e.g.,_ `com.amazonaws` in AWS Commercial, `cn.com.amazonaws` in AWS China).
   126  	ReverseDnsPrefix *string `pulumi:"reverseDnsPrefix"`
   127  	// Service (_e.g.,_ `s3`, `rds`, `ec2`). One of `dnsName`, `reverseDnsName`, or `serviceId` is required.
   128  	ServiceId *string `pulumi:"serviceId"`
   129  }
   130  
   131  // A collection of values returned by getService.
   132  type GetServiceResult struct {
   133  	DnsName          string `pulumi:"dnsName"`
   134  	Id               string `pulumi:"id"`
   135  	Partition        string `pulumi:"partition"`
   136  	Region           string `pulumi:"region"`
   137  	ReverseDnsName   string `pulumi:"reverseDnsName"`
   138  	ReverseDnsPrefix string `pulumi:"reverseDnsPrefix"`
   139  	ServiceId        string `pulumi:"serviceId"`
   140  	// Whether the service is supported in the region's partition. New services may not be listed immediately as supported.
   141  	Supported bool `pulumi:"supported"`
   142  }
   143  
   144  func GetServiceOutput(ctx *pulumi.Context, args GetServiceOutputArgs, opts ...pulumi.InvokeOption) GetServiceResultOutput {
   145  	return pulumi.ToOutputWithContext(context.Background(), args).
   146  		ApplyT(func(v interface{}) (GetServiceResult, error) {
   147  			args := v.(GetServiceArgs)
   148  			r, err := GetService(ctx, &args, opts...)
   149  			var s GetServiceResult
   150  			if r != nil {
   151  				s = *r
   152  			}
   153  			return s, err
   154  		}).(GetServiceResultOutput)
   155  }
   156  
   157  // A collection of arguments for invoking getService.
   158  type GetServiceOutputArgs struct {
   159  	// DNS name of the service (_e.g.,_ `rds.us-east-1.amazonaws.com`). One of `dnsName`, `reverseDnsName`, or `serviceId` is required.
   160  	DnsName pulumi.StringPtrInput `pulumi:"dnsName"`
   161  	Id      pulumi.StringPtrInput `pulumi:"id"`
   162  	// Region of the service (_e.g.,_ `us-west-2`, `ap-northeast-1`).
   163  	Region pulumi.StringPtrInput `pulumi:"region"`
   164  	// Reverse DNS name of the service (_e.g.,_ `com.amazonaws.us-west-2.s3`). One of `dnsName`, `reverseDnsName`, or `serviceId` is required.
   165  	ReverseDnsName pulumi.StringPtrInput `pulumi:"reverseDnsName"`
   166  	// Prefix of the service (_e.g.,_ `com.amazonaws` in AWS Commercial, `cn.com.amazonaws` in AWS China).
   167  	ReverseDnsPrefix pulumi.StringPtrInput `pulumi:"reverseDnsPrefix"`
   168  	// Service (_e.g.,_ `s3`, `rds`, `ec2`). One of `dnsName`, `reverseDnsName`, or `serviceId` is required.
   169  	ServiceId pulumi.StringPtrInput `pulumi:"serviceId"`
   170  }
   171  
   172  func (GetServiceOutputArgs) ElementType() reflect.Type {
   173  	return reflect.TypeOf((*GetServiceArgs)(nil)).Elem()
   174  }
   175  
   176  // A collection of values returned by getService.
   177  type GetServiceResultOutput struct{ *pulumi.OutputState }
   178  
   179  func (GetServiceResultOutput) ElementType() reflect.Type {
   180  	return reflect.TypeOf((*GetServiceResult)(nil)).Elem()
   181  }
   182  
   183  func (o GetServiceResultOutput) ToGetServiceResultOutput() GetServiceResultOutput {
   184  	return o
   185  }
   186  
   187  func (o GetServiceResultOutput) ToGetServiceResultOutputWithContext(ctx context.Context) GetServiceResultOutput {
   188  	return o
   189  }
   190  
   191  func (o GetServiceResultOutput) DnsName() pulumi.StringOutput {
   192  	return o.ApplyT(func(v GetServiceResult) string { return v.DnsName }).(pulumi.StringOutput)
   193  }
   194  
   195  func (o GetServiceResultOutput) Id() pulumi.StringOutput {
   196  	return o.ApplyT(func(v GetServiceResult) string { return v.Id }).(pulumi.StringOutput)
   197  }
   198  
   199  func (o GetServiceResultOutput) Partition() pulumi.StringOutput {
   200  	return o.ApplyT(func(v GetServiceResult) string { return v.Partition }).(pulumi.StringOutput)
   201  }
   202  
   203  func (o GetServiceResultOutput) Region() pulumi.StringOutput {
   204  	return o.ApplyT(func(v GetServiceResult) string { return v.Region }).(pulumi.StringOutput)
   205  }
   206  
   207  func (o GetServiceResultOutput) ReverseDnsName() pulumi.StringOutput {
   208  	return o.ApplyT(func(v GetServiceResult) string { return v.ReverseDnsName }).(pulumi.StringOutput)
   209  }
   210  
   211  func (o GetServiceResultOutput) ReverseDnsPrefix() pulumi.StringOutput {
   212  	return o.ApplyT(func(v GetServiceResult) string { return v.ReverseDnsPrefix }).(pulumi.StringOutput)
   213  }
   214  
   215  func (o GetServiceResultOutput) ServiceId() pulumi.StringOutput {
   216  	return o.ApplyT(func(v GetServiceResult) string { return v.ServiceId }).(pulumi.StringOutput)
   217  }
   218  
   219  // Whether the service is supported in the region's partition. New services may not be listed immediately as supported.
   220  func (o GetServiceResultOutput) Supported() pulumi.BoolOutput {
   221  	return o.ApplyT(func(v GetServiceResult) bool { return v.Supported }).(pulumi.BoolOutput)
   222  }
   223  
   224  func init() {
   225  	pulumi.RegisterOutputType(GetServiceResultOutput{})
   226  }