github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/resourcegroups/resource.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 resourcegroups
     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 Resource Groups Resource.
    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/ec2"
    28  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/resourcegroups"
    29  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    30  //
    31  // )
    32  //
    33  //	func main() {
    34  //		pulumi.Run(func(ctx *pulumi.Context) error {
    35  //			example, err := ec2.NewDedicatedHost(ctx, "example", &ec2.DedicatedHostArgs{
    36  //				InstanceFamily:   pulumi.String("t3"),
    37  //				AvailabilityZone: pulumi.String("us-east-1a"),
    38  //				HostRecovery:     pulumi.String("off"),
    39  //				AutoPlacement:    pulumi.String("on"),
    40  //			})
    41  //			if err != nil {
    42  //				return err
    43  //			}
    44  //			exampleGroup, err := resourcegroups.NewGroup(ctx, "example", &resourcegroups.GroupArgs{
    45  //				Name: pulumi.String("example"),
    46  //			})
    47  //			if err != nil {
    48  //				return err
    49  //			}
    50  //			_, err = resourcegroups.NewResource(ctx, "example", &resourcegroups.ResourceArgs{
    51  //				GroupArn:    exampleGroup.Arn,
    52  //				ResourceArn: example.Arn,
    53  //			})
    54  //			if err != nil {
    55  //				return err
    56  //			}
    57  //			return nil
    58  //		})
    59  //	}
    60  //
    61  // ```
    62  // <!--End PulumiCodeChooser -->
    63  type Resource struct {
    64  	pulumi.CustomResourceState
    65  
    66  	// The name or the ARN of the resource group to add resources to.
    67  	//
    68  	// The following arguments are optional:
    69  	GroupArn pulumi.StringOutput `pulumi:"groupArn"`
    70  	// The ARN of the resource to be added to the group.
    71  	ResourceArn pulumi.StringOutput `pulumi:"resourceArn"`
    72  	// The resource type of a resource, such as `AWS::EC2::Instance`.
    73  	ResourceType pulumi.StringOutput `pulumi:"resourceType"`
    74  }
    75  
    76  // NewResource registers a new resource with the given unique name, arguments, and options.
    77  func NewResource(ctx *pulumi.Context,
    78  	name string, args *ResourceArgs, opts ...pulumi.ResourceOption) (*Resource, error) {
    79  	if args == nil {
    80  		return nil, errors.New("missing one or more required arguments")
    81  	}
    82  
    83  	if args.GroupArn == nil {
    84  		return nil, errors.New("invalid value for required argument 'GroupArn'")
    85  	}
    86  	if args.ResourceArn == nil {
    87  		return nil, errors.New("invalid value for required argument 'ResourceArn'")
    88  	}
    89  	opts = internal.PkgResourceDefaultOpts(opts)
    90  	var resource Resource
    91  	err := ctx.RegisterResource("aws:resourcegroups/resource:Resource", name, args, &resource, opts...)
    92  	if err != nil {
    93  		return nil, err
    94  	}
    95  	return &resource, nil
    96  }
    97  
    98  // GetResource gets an existing Resource resource's state with the given name, ID, and optional
    99  // state properties that are used to uniquely qualify the lookup (nil if not required).
   100  func GetResource(ctx *pulumi.Context,
   101  	name string, id pulumi.IDInput, state *ResourceState, opts ...pulumi.ResourceOption) (*Resource, error) {
   102  	var resource Resource
   103  	err := ctx.ReadResource("aws:resourcegroups/resource:Resource", name, id, state, &resource, opts...)
   104  	if err != nil {
   105  		return nil, err
   106  	}
   107  	return &resource, nil
   108  }
   109  
   110  // Input properties used for looking up and filtering Resource resources.
   111  type resourceState struct {
   112  	// The name or the ARN of the resource group to add resources to.
   113  	//
   114  	// The following arguments are optional:
   115  	GroupArn *string `pulumi:"groupArn"`
   116  	// The ARN of the resource to be added to the group.
   117  	ResourceArn *string `pulumi:"resourceArn"`
   118  	// The resource type of a resource, such as `AWS::EC2::Instance`.
   119  	ResourceType *string `pulumi:"resourceType"`
   120  }
   121  
   122  type ResourceState struct {
   123  	// The name or the ARN of the resource group to add resources to.
   124  	//
   125  	// The following arguments are optional:
   126  	GroupArn pulumi.StringPtrInput
   127  	// The ARN of the resource to be added to the group.
   128  	ResourceArn pulumi.StringPtrInput
   129  	// The resource type of a resource, such as `AWS::EC2::Instance`.
   130  	ResourceType pulumi.StringPtrInput
   131  }
   132  
   133  func (ResourceState) ElementType() reflect.Type {
   134  	return reflect.TypeOf((*resourceState)(nil)).Elem()
   135  }
   136  
   137  type resourceArgs struct {
   138  	// The name or the ARN of the resource group to add resources to.
   139  	//
   140  	// The following arguments are optional:
   141  	GroupArn string `pulumi:"groupArn"`
   142  	// The ARN of the resource to be added to the group.
   143  	ResourceArn string `pulumi:"resourceArn"`
   144  }
   145  
   146  // The set of arguments for constructing a Resource resource.
   147  type ResourceArgs struct {
   148  	// The name or the ARN of the resource group to add resources to.
   149  	//
   150  	// The following arguments are optional:
   151  	GroupArn pulumi.StringInput
   152  	// The ARN of the resource to be added to the group.
   153  	ResourceArn pulumi.StringInput
   154  }
   155  
   156  func (ResourceArgs) ElementType() reflect.Type {
   157  	return reflect.TypeOf((*resourceArgs)(nil)).Elem()
   158  }
   159  
   160  type ResourceInput interface {
   161  	pulumi.Input
   162  
   163  	ToResourceOutput() ResourceOutput
   164  	ToResourceOutputWithContext(ctx context.Context) ResourceOutput
   165  }
   166  
   167  func (*Resource) ElementType() reflect.Type {
   168  	return reflect.TypeOf((**Resource)(nil)).Elem()
   169  }
   170  
   171  func (i *Resource) ToResourceOutput() ResourceOutput {
   172  	return i.ToResourceOutputWithContext(context.Background())
   173  }
   174  
   175  func (i *Resource) ToResourceOutputWithContext(ctx context.Context) ResourceOutput {
   176  	return pulumi.ToOutputWithContext(ctx, i).(ResourceOutput)
   177  }
   178  
   179  // ResourceArrayInput is an input type that accepts ResourceArray and ResourceArrayOutput values.
   180  // You can construct a concrete instance of `ResourceArrayInput` via:
   181  //
   182  //	ResourceArray{ ResourceArgs{...} }
   183  type ResourceArrayInput interface {
   184  	pulumi.Input
   185  
   186  	ToResourceArrayOutput() ResourceArrayOutput
   187  	ToResourceArrayOutputWithContext(context.Context) ResourceArrayOutput
   188  }
   189  
   190  type ResourceArray []ResourceInput
   191  
   192  func (ResourceArray) ElementType() reflect.Type {
   193  	return reflect.TypeOf((*[]*Resource)(nil)).Elem()
   194  }
   195  
   196  func (i ResourceArray) ToResourceArrayOutput() ResourceArrayOutput {
   197  	return i.ToResourceArrayOutputWithContext(context.Background())
   198  }
   199  
   200  func (i ResourceArray) ToResourceArrayOutputWithContext(ctx context.Context) ResourceArrayOutput {
   201  	return pulumi.ToOutputWithContext(ctx, i).(ResourceArrayOutput)
   202  }
   203  
   204  // ResourceMapInput is an input type that accepts ResourceMap and ResourceMapOutput values.
   205  // You can construct a concrete instance of `ResourceMapInput` via:
   206  //
   207  //	ResourceMap{ "key": ResourceArgs{...} }
   208  type ResourceMapInput interface {
   209  	pulumi.Input
   210  
   211  	ToResourceMapOutput() ResourceMapOutput
   212  	ToResourceMapOutputWithContext(context.Context) ResourceMapOutput
   213  }
   214  
   215  type ResourceMap map[string]ResourceInput
   216  
   217  func (ResourceMap) ElementType() reflect.Type {
   218  	return reflect.TypeOf((*map[string]*Resource)(nil)).Elem()
   219  }
   220  
   221  func (i ResourceMap) ToResourceMapOutput() ResourceMapOutput {
   222  	return i.ToResourceMapOutputWithContext(context.Background())
   223  }
   224  
   225  func (i ResourceMap) ToResourceMapOutputWithContext(ctx context.Context) ResourceMapOutput {
   226  	return pulumi.ToOutputWithContext(ctx, i).(ResourceMapOutput)
   227  }
   228  
   229  type ResourceOutput struct{ *pulumi.OutputState }
   230  
   231  func (ResourceOutput) ElementType() reflect.Type {
   232  	return reflect.TypeOf((**Resource)(nil)).Elem()
   233  }
   234  
   235  func (o ResourceOutput) ToResourceOutput() ResourceOutput {
   236  	return o
   237  }
   238  
   239  func (o ResourceOutput) ToResourceOutputWithContext(ctx context.Context) ResourceOutput {
   240  	return o
   241  }
   242  
   243  // The name or the ARN of the resource group to add resources to.
   244  //
   245  // The following arguments are optional:
   246  func (o ResourceOutput) GroupArn() pulumi.StringOutput {
   247  	return o.ApplyT(func(v *Resource) pulumi.StringOutput { return v.GroupArn }).(pulumi.StringOutput)
   248  }
   249  
   250  // The ARN of the resource to be added to the group.
   251  func (o ResourceOutput) ResourceArn() pulumi.StringOutput {
   252  	return o.ApplyT(func(v *Resource) pulumi.StringOutput { return v.ResourceArn }).(pulumi.StringOutput)
   253  }
   254  
   255  // The resource type of a resource, such as `AWS::EC2::Instance`.
   256  func (o ResourceOutput) ResourceType() pulumi.StringOutput {
   257  	return o.ApplyT(func(v *Resource) pulumi.StringOutput { return v.ResourceType }).(pulumi.StringOutput)
   258  }
   259  
   260  type ResourceArrayOutput struct{ *pulumi.OutputState }
   261  
   262  func (ResourceArrayOutput) ElementType() reflect.Type {
   263  	return reflect.TypeOf((*[]*Resource)(nil)).Elem()
   264  }
   265  
   266  func (o ResourceArrayOutput) ToResourceArrayOutput() ResourceArrayOutput {
   267  	return o
   268  }
   269  
   270  func (o ResourceArrayOutput) ToResourceArrayOutputWithContext(ctx context.Context) ResourceArrayOutput {
   271  	return o
   272  }
   273  
   274  func (o ResourceArrayOutput) Index(i pulumi.IntInput) ResourceOutput {
   275  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Resource {
   276  		return vs[0].([]*Resource)[vs[1].(int)]
   277  	}).(ResourceOutput)
   278  }
   279  
   280  type ResourceMapOutput struct{ *pulumi.OutputState }
   281  
   282  func (ResourceMapOutput) ElementType() reflect.Type {
   283  	return reflect.TypeOf((*map[string]*Resource)(nil)).Elem()
   284  }
   285  
   286  func (o ResourceMapOutput) ToResourceMapOutput() ResourceMapOutput {
   287  	return o
   288  }
   289  
   290  func (o ResourceMapOutput) ToResourceMapOutputWithContext(ctx context.Context) ResourceMapOutput {
   291  	return o
   292  }
   293  
   294  func (o ResourceMapOutput) MapIndex(k pulumi.StringInput) ResourceOutput {
   295  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Resource {
   296  		return vs[0].(map[string]*Resource)[vs[1].(string)]
   297  	}).(ResourceOutput)
   298  }
   299  
   300  func init() {
   301  	pulumi.RegisterInputType(reflect.TypeOf((*ResourceInput)(nil)).Elem(), &Resource{})
   302  	pulumi.RegisterInputType(reflect.TypeOf((*ResourceArrayInput)(nil)).Elem(), ResourceArray{})
   303  	pulumi.RegisterInputType(reflect.TypeOf((*ResourceMapInput)(nil)).Elem(), ResourceMap{})
   304  	pulumi.RegisterOutputType(ResourceOutput{})
   305  	pulumi.RegisterOutputType(ResourceArrayOutput{})
   306  	pulumi.RegisterOutputType(ResourceMapOutput{})
   307  }