github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/vpclattice/targetGroup.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 vpclattice
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"errors"
    11  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    12  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    13  )
    14  
    15  // Resource for managing an AWS VPC Lattice Target Group.
    16  //
    17  // ## Example Usage
    18  //
    19  // ### Basic Usage
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/vpclattice"
    28  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    29  //
    30  // )
    31  //
    32  //	func main() {
    33  //		pulumi.Run(func(ctx *pulumi.Context) error {
    34  //			_, err := vpclattice.NewTargetGroup(ctx, "example", &vpclattice.TargetGroupArgs{
    35  //				Name: pulumi.String("example"),
    36  //				Type: pulumi.String("INSTANCE"),
    37  //				Config: &vpclattice.TargetGroupConfigArgs{
    38  //					VpcIdentifier: pulumi.Any(exampleAwsVpc.Id),
    39  //					Port:          pulumi.Int(443),
    40  //					Protocol:      pulumi.String("HTTPS"),
    41  //				},
    42  //			})
    43  //			if err != nil {
    44  //				return err
    45  //			}
    46  //			return nil
    47  //		})
    48  //	}
    49  //
    50  // ```
    51  // <!--End PulumiCodeChooser -->
    52  //
    53  // ### Basic usage with Health check
    54  //
    55  // <!--Start PulumiCodeChooser -->
    56  // ```go
    57  // package main
    58  //
    59  // import (
    60  //
    61  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/vpclattice"
    62  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    63  //
    64  // )
    65  //
    66  //	func main() {
    67  //		pulumi.Run(func(ctx *pulumi.Context) error {
    68  //			_, err := vpclattice.NewTargetGroup(ctx, "example", &vpclattice.TargetGroupArgs{
    69  //				Name: pulumi.String("example"),
    70  //				Type: pulumi.String("IP"),
    71  //				Config: &vpclattice.TargetGroupConfigArgs{
    72  //					VpcIdentifier:   pulumi.Any(exampleAwsVpc.Id),
    73  //					IpAddressType:   pulumi.String("IPV4"),
    74  //					Port:            pulumi.Int(443),
    75  //					Protocol:        pulumi.String("HTTPS"),
    76  //					ProtocolVersion: pulumi.String("HTTP1"),
    77  //					HealthCheck: &vpclattice.TargetGroupConfigHealthCheckArgs{
    78  //						Enabled:                    pulumi.Bool(true),
    79  //						HealthCheckIntervalSeconds: pulumi.Int(20),
    80  //						HealthCheckTimeoutSeconds:  pulumi.Int(10),
    81  //						HealthyThresholdCount:      pulumi.Int(7),
    82  //						UnhealthyThresholdCount:    pulumi.Int(3),
    83  //						Matcher: &vpclattice.TargetGroupConfigHealthCheckMatcherArgs{
    84  //							Value: pulumi.String("200-299"),
    85  //						},
    86  //						Path:            pulumi.String("/instance"),
    87  //						Port:            pulumi.Int(80),
    88  //						Protocol:        pulumi.String("HTTP"),
    89  //						ProtocolVersion: pulumi.String("HTTP1"),
    90  //					},
    91  //				},
    92  //			})
    93  //			if err != nil {
    94  //				return err
    95  //			}
    96  //			return nil
    97  //		})
    98  //	}
    99  //
   100  // ```
   101  // <!--End PulumiCodeChooser -->
   102  //
   103  // ### ALB
   104  //
   105  // If the type is ALB, `healthCheck` block is not supported.
   106  //
   107  // <!--Start PulumiCodeChooser -->
   108  // ```go
   109  // package main
   110  //
   111  // import (
   112  //
   113  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/vpclattice"
   114  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
   115  //
   116  // )
   117  //
   118  //	func main() {
   119  //		pulumi.Run(func(ctx *pulumi.Context) error {
   120  //			_, err := vpclattice.NewTargetGroup(ctx, "example", &vpclattice.TargetGroupArgs{
   121  //				Name: pulumi.String("example"),
   122  //				Type: pulumi.String("ALB"),
   123  //				Config: &vpclattice.TargetGroupConfigArgs{
   124  //					VpcIdentifier:   pulumi.Any(exampleAwsVpc.Id),
   125  //					Port:            pulumi.Int(443),
   126  //					Protocol:        pulumi.String("HTTPS"),
   127  //					ProtocolVersion: pulumi.String("HTTP1"),
   128  //				},
   129  //			})
   130  //			if err != nil {
   131  //				return err
   132  //			}
   133  //			return nil
   134  //		})
   135  //	}
   136  //
   137  // ```
   138  // <!--End PulumiCodeChooser -->
   139  //
   140  // ### Lambda
   141  //
   142  // If the type is Lambda, `config` block is not supported.
   143  //
   144  // <!--Start PulumiCodeChooser -->
   145  // ```go
   146  // package main
   147  //
   148  // import (
   149  //
   150  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/vpclattice"
   151  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
   152  //
   153  // )
   154  //
   155  //	func main() {
   156  //		pulumi.Run(func(ctx *pulumi.Context) error {
   157  //			_, err := vpclattice.NewTargetGroup(ctx, "example", &vpclattice.TargetGroupArgs{
   158  //				Name: pulumi.String("example"),
   159  //				Type: pulumi.String("LAMBDA"),
   160  //			})
   161  //			if err != nil {
   162  //				return err
   163  //			}
   164  //			return nil
   165  //		})
   166  //	}
   167  //
   168  // ```
   169  // <!--End PulumiCodeChooser -->
   170  //
   171  // ## Import
   172  //
   173  // Using `pulumi import`, import VPC Lattice Target Group using the `id`. For example:
   174  //
   175  // ```sh
   176  // $ pulumi import aws:vpclattice/targetGroup:TargetGroup example tg-0c11d4dc16ed96bdb
   177  // ```
   178  type TargetGroup struct {
   179  	pulumi.CustomResourceState
   180  
   181  	// ARN of the target group.
   182  	Arn pulumi.StringOutput `pulumi:"arn"`
   183  	// The target group configuration.
   184  	Config TargetGroupConfigPtrOutput `pulumi:"config"`
   185  	// The name of the target group. The name must be unique within the account. The valid characters are a-z, 0-9, and hyphens (-). You can't use a hyphen as the first or last character, or immediately after another hyphen.
   186  	Name pulumi.StringOutput `pulumi:"name"`
   187  	// Status of the target group.
   188  	Status pulumi.StringOutput `pulumi:"status"`
   189  	// Key-value mapping of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   190  	Tags pulumi.StringMapOutput `pulumi:"tags"`
   191  	// Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   192  	//
   193  	// Deprecated: Please use `tags` instead.
   194  	TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
   195  	// The type of target group. Valid Values are `IP` | `LAMBDA` | `INSTANCE` | `ALB`
   196  	//
   197  	// The following arguments are optional:
   198  	Type pulumi.StringOutput `pulumi:"type"`
   199  }
   200  
   201  // NewTargetGroup registers a new resource with the given unique name, arguments, and options.
   202  func NewTargetGroup(ctx *pulumi.Context,
   203  	name string, args *TargetGroupArgs, opts ...pulumi.ResourceOption) (*TargetGroup, error) {
   204  	if args == nil {
   205  		return nil, errors.New("missing one or more required arguments")
   206  	}
   207  
   208  	if args.Type == nil {
   209  		return nil, errors.New("invalid value for required argument 'Type'")
   210  	}
   211  	opts = internal.PkgResourceDefaultOpts(opts)
   212  	var resource TargetGroup
   213  	err := ctx.RegisterResource("aws:vpclattice/targetGroup:TargetGroup", name, args, &resource, opts...)
   214  	if err != nil {
   215  		return nil, err
   216  	}
   217  	return &resource, nil
   218  }
   219  
   220  // GetTargetGroup gets an existing TargetGroup resource's state with the given name, ID, and optional
   221  // state properties that are used to uniquely qualify the lookup (nil if not required).
   222  func GetTargetGroup(ctx *pulumi.Context,
   223  	name string, id pulumi.IDInput, state *TargetGroupState, opts ...pulumi.ResourceOption) (*TargetGroup, error) {
   224  	var resource TargetGroup
   225  	err := ctx.ReadResource("aws:vpclattice/targetGroup:TargetGroup", name, id, state, &resource, opts...)
   226  	if err != nil {
   227  		return nil, err
   228  	}
   229  	return &resource, nil
   230  }
   231  
   232  // Input properties used for looking up and filtering TargetGroup resources.
   233  type targetGroupState struct {
   234  	// ARN of the target group.
   235  	Arn *string `pulumi:"arn"`
   236  	// The target group configuration.
   237  	Config *TargetGroupConfig `pulumi:"config"`
   238  	// The name of the target group. The name must be unique within the account. The valid characters are a-z, 0-9, and hyphens (-). You can't use a hyphen as the first or last character, or immediately after another hyphen.
   239  	Name *string `pulumi:"name"`
   240  	// Status of the target group.
   241  	Status *string `pulumi:"status"`
   242  	// Key-value mapping of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   243  	Tags map[string]string `pulumi:"tags"`
   244  	// Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   245  	//
   246  	// Deprecated: Please use `tags` instead.
   247  	TagsAll map[string]string `pulumi:"tagsAll"`
   248  	// The type of target group. Valid Values are `IP` | `LAMBDA` | `INSTANCE` | `ALB`
   249  	//
   250  	// The following arguments are optional:
   251  	Type *string `pulumi:"type"`
   252  }
   253  
   254  type TargetGroupState struct {
   255  	// ARN of the target group.
   256  	Arn pulumi.StringPtrInput
   257  	// The target group configuration.
   258  	Config TargetGroupConfigPtrInput
   259  	// The name of the target group. The name must be unique within the account. The valid characters are a-z, 0-9, and hyphens (-). You can't use a hyphen as the first or last character, or immediately after another hyphen.
   260  	Name pulumi.StringPtrInput
   261  	// Status of the target group.
   262  	Status pulumi.StringPtrInput
   263  	// Key-value mapping of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   264  	Tags pulumi.StringMapInput
   265  	// Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   266  	//
   267  	// Deprecated: Please use `tags` instead.
   268  	TagsAll pulumi.StringMapInput
   269  	// The type of target group. Valid Values are `IP` | `LAMBDA` | `INSTANCE` | `ALB`
   270  	//
   271  	// The following arguments are optional:
   272  	Type pulumi.StringPtrInput
   273  }
   274  
   275  func (TargetGroupState) ElementType() reflect.Type {
   276  	return reflect.TypeOf((*targetGroupState)(nil)).Elem()
   277  }
   278  
   279  type targetGroupArgs struct {
   280  	// The target group configuration.
   281  	Config *TargetGroupConfig `pulumi:"config"`
   282  	// The name of the target group. The name must be unique within the account. The valid characters are a-z, 0-9, and hyphens (-). You can't use a hyphen as the first or last character, or immediately after another hyphen.
   283  	Name *string `pulumi:"name"`
   284  	// Key-value mapping of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   285  	Tags map[string]string `pulumi:"tags"`
   286  	// The type of target group. Valid Values are `IP` | `LAMBDA` | `INSTANCE` | `ALB`
   287  	//
   288  	// The following arguments are optional:
   289  	Type string `pulumi:"type"`
   290  }
   291  
   292  // The set of arguments for constructing a TargetGroup resource.
   293  type TargetGroupArgs struct {
   294  	// The target group configuration.
   295  	Config TargetGroupConfigPtrInput
   296  	// The name of the target group. The name must be unique within the account. The valid characters are a-z, 0-9, and hyphens (-). You can't use a hyphen as the first or last character, or immediately after another hyphen.
   297  	Name pulumi.StringPtrInput
   298  	// Key-value mapping of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   299  	Tags pulumi.StringMapInput
   300  	// The type of target group. Valid Values are `IP` | `LAMBDA` | `INSTANCE` | `ALB`
   301  	//
   302  	// The following arguments are optional:
   303  	Type pulumi.StringInput
   304  }
   305  
   306  func (TargetGroupArgs) ElementType() reflect.Type {
   307  	return reflect.TypeOf((*targetGroupArgs)(nil)).Elem()
   308  }
   309  
   310  type TargetGroupInput interface {
   311  	pulumi.Input
   312  
   313  	ToTargetGroupOutput() TargetGroupOutput
   314  	ToTargetGroupOutputWithContext(ctx context.Context) TargetGroupOutput
   315  }
   316  
   317  func (*TargetGroup) ElementType() reflect.Type {
   318  	return reflect.TypeOf((**TargetGroup)(nil)).Elem()
   319  }
   320  
   321  func (i *TargetGroup) ToTargetGroupOutput() TargetGroupOutput {
   322  	return i.ToTargetGroupOutputWithContext(context.Background())
   323  }
   324  
   325  func (i *TargetGroup) ToTargetGroupOutputWithContext(ctx context.Context) TargetGroupOutput {
   326  	return pulumi.ToOutputWithContext(ctx, i).(TargetGroupOutput)
   327  }
   328  
   329  // TargetGroupArrayInput is an input type that accepts TargetGroupArray and TargetGroupArrayOutput values.
   330  // You can construct a concrete instance of `TargetGroupArrayInput` via:
   331  //
   332  //	TargetGroupArray{ TargetGroupArgs{...} }
   333  type TargetGroupArrayInput interface {
   334  	pulumi.Input
   335  
   336  	ToTargetGroupArrayOutput() TargetGroupArrayOutput
   337  	ToTargetGroupArrayOutputWithContext(context.Context) TargetGroupArrayOutput
   338  }
   339  
   340  type TargetGroupArray []TargetGroupInput
   341  
   342  func (TargetGroupArray) ElementType() reflect.Type {
   343  	return reflect.TypeOf((*[]*TargetGroup)(nil)).Elem()
   344  }
   345  
   346  func (i TargetGroupArray) ToTargetGroupArrayOutput() TargetGroupArrayOutput {
   347  	return i.ToTargetGroupArrayOutputWithContext(context.Background())
   348  }
   349  
   350  func (i TargetGroupArray) ToTargetGroupArrayOutputWithContext(ctx context.Context) TargetGroupArrayOutput {
   351  	return pulumi.ToOutputWithContext(ctx, i).(TargetGroupArrayOutput)
   352  }
   353  
   354  // TargetGroupMapInput is an input type that accepts TargetGroupMap and TargetGroupMapOutput values.
   355  // You can construct a concrete instance of `TargetGroupMapInput` via:
   356  //
   357  //	TargetGroupMap{ "key": TargetGroupArgs{...} }
   358  type TargetGroupMapInput interface {
   359  	pulumi.Input
   360  
   361  	ToTargetGroupMapOutput() TargetGroupMapOutput
   362  	ToTargetGroupMapOutputWithContext(context.Context) TargetGroupMapOutput
   363  }
   364  
   365  type TargetGroupMap map[string]TargetGroupInput
   366  
   367  func (TargetGroupMap) ElementType() reflect.Type {
   368  	return reflect.TypeOf((*map[string]*TargetGroup)(nil)).Elem()
   369  }
   370  
   371  func (i TargetGroupMap) ToTargetGroupMapOutput() TargetGroupMapOutput {
   372  	return i.ToTargetGroupMapOutputWithContext(context.Background())
   373  }
   374  
   375  func (i TargetGroupMap) ToTargetGroupMapOutputWithContext(ctx context.Context) TargetGroupMapOutput {
   376  	return pulumi.ToOutputWithContext(ctx, i).(TargetGroupMapOutput)
   377  }
   378  
   379  type TargetGroupOutput struct{ *pulumi.OutputState }
   380  
   381  func (TargetGroupOutput) ElementType() reflect.Type {
   382  	return reflect.TypeOf((**TargetGroup)(nil)).Elem()
   383  }
   384  
   385  func (o TargetGroupOutput) ToTargetGroupOutput() TargetGroupOutput {
   386  	return o
   387  }
   388  
   389  func (o TargetGroupOutput) ToTargetGroupOutputWithContext(ctx context.Context) TargetGroupOutput {
   390  	return o
   391  }
   392  
   393  // ARN of the target group.
   394  func (o TargetGroupOutput) Arn() pulumi.StringOutput {
   395  	return o.ApplyT(func(v *TargetGroup) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   396  }
   397  
   398  // The target group configuration.
   399  func (o TargetGroupOutput) Config() TargetGroupConfigPtrOutput {
   400  	return o.ApplyT(func(v *TargetGroup) TargetGroupConfigPtrOutput { return v.Config }).(TargetGroupConfigPtrOutput)
   401  }
   402  
   403  // The name of the target group. The name must be unique within the account. The valid characters are a-z, 0-9, and hyphens (-). You can't use a hyphen as the first or last character, or immediately after another hyphen.
   404  func (o TargetGroupOutput) Name() pulumi.StringOutput {
   405  	return o.ApplyT(func(v *TargetGroup) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   406  }
   407  
   408  // Status of the target group.
   409  func (o TargetGroupOutput) Status() pulumi.StringOutput {
   410  	return o.ApplyT(func(v *TargetGroup) pulumi.StringOutput { return v.Status }).(pulumi.StringOutput)
   411  }
   412  
   413  // Key-value mapping of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   414  func (o TargetGroupOutput) Tags() pulumi.StringMapOutput {
   415  	return o.ApplyT(func(v *TargetGroup) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
   416  }
   417  
   418  // Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   419  //
   420  // Deprecated: Please use `tags` instead.
   421  func (o TargetGroupOutput) TagsAll() pulumi.StringMapOutput {
   422  	return o.ApplyT(func(v *TargetGroup) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)
   423  }
   424  
   425  // The type of target group. Valid Values are `IP` | `LAMBDA` | `INSTANCE` | `ALB`
   426  //
   427  // The following arguments are optional:
   428  func (o TargetGroupOutput) Type() pulumi.StringOutput {
   429  	return o.ApplyT(func(v *TargetGroup) pulumi.StringOutput { return v.Type }).(pulumi.StringOutput)
   430  }
   431  
   432  type TargetGroupArrayOutput struct{ *pulumi.OutputState }
   433  
   434  func (TargetGroupArrayOutput) ElementType() reflect.Type {
   435  	return reflect.TypeOf((*[]*TargetGroup)(nil)).Elem()
   436  }
   437  
   438  func (o TargetGroupArrayOutput) ToTargetGroupArrayOutput() TargetGroupArrayOutput {
   439  	return o
   440  }
   441  
   442  func (o TargetGroupArrayOutput) ToTargetGroupArrayOutputWithContext(ctx context.Context) TargetGroupArrayOutput {
   443  	return o
   444  }
   445  
   446  func (o TargetGroupArrayOutput) Index(i pulumi.IntInput) TargetGroupOutput {
   447  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *TargetGroup {
   448  		return vs[0].([]*TargetGroup)[vs[1].(int)]
   449  	}).(TargetGroupOutput)
   450  }
   451  
   452  type TargetGroupMapOutput struct{ *pulumi.OutputState }
   453  
   454  func (TargetGroupMapOutput) ElementType() reflect.Type {
   455  	return reflect.TypeOf((*map[string]*TargetGroup)(nil)).Elem()
   456  }
   457  
   458  func (o TargetGroupMapOutput) ToTargetGroupMapOutput() TargetGroupMapOutput {
   459  	return o
   460  }
   461  
   462  func (o TargetGroupMapOutput) ToTargetGroupMapOutputWithContext(ctx context.Context) TargetGroupMapOutput {
   463  	return o
   464  }
   465  
   466  func (o TargetGroupMapOutput) MapIndex(k pulumi.StringInput) TargetGroupOutput {
   467  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *TargetGroup {
   468  		return vs[0].(map[string]*TargetGroup)[vs[1].(string)]
   469  	}).(TargetGroupOutput)
   470  }
   471  
   472  func init() {
   473  	pulumi.RegisterInputType(reflect.TypeOf((*TargetGroupInput)(nil)).Elem(), &TargetGroup{})
   474  	pulumi.RegisterInputType(reflect.TypeOf((*TargetGroupArrayInput)(nil)).Elem(), TargetGroupArray{})
   475  	pulumi.RegisterInputType(reflect.TypeOf((*TargetGroupMapInput)(nil)).Elem(), TargetGroupMap{})
   476  	pulumi.RegisterOutputType(TargetGroupOutput{})
   477  	pulumi.RegisterOutputType(TargetGroupArrayOutput{})
   478  	pulumi.RegisterOutputType(TargetGroupMapOutput{})
   479  }