github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/licensemanager/association.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 licensemanager
     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  // Provides a License Manager association.
    16  //
    17  // > **Note:** License configurations can also be associated with launch templates by specifying the `licenseSpecifications` block for an `ec2.LaunchTemplate`.
    18  //
    19  // ## Example 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/licensemanager"
    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.LookupAmi(ctx, &ec2.LookupAmiArgs{
    36  //				MostRecent: pulumi.BoolRef(true),
    37  //				Owners: []string{
    38  //					"amazon",
    39  //				},
    40  //				Filters: []ec2.GetAmiFilter{
    41  //					{
    42  //						Name: "name",
    43  //						Values: []string{
    44  //							"amzn-ami-vpc-nat*",
    45  //						},
    46  //					},
    47  //				},
    48  //			}, nil)
    49  //			if err != nil {
    50  //				return err
    51  //			}
    52  //			exampleInstance, err := ec2.NewInstance(ctx, "example", &ec2.InstanceArgs{
    53  //				Ami:          pulumi.String(example.Id),
    54  //				InstanceType: pulumi.String(ec2.InstanceType_T2_Micro),
    55  //			})
    56  //			if err != nil {
    57  //				return err
    58  //			}
    59  //			exampleLicenseConfiguration, err := licensemanager.NewLicenseConfiguration(ctx, "example", &licensemanager.LicenseConfigurationArgs{
    60  //				Name:                pulumi.String("Example"),
    61  //				LicenseCountingType: pulumi.String("Instance"),
    62  //			})
    63  //			if err != nil {
    64  //				return err
    65  //			}
    66  //			_, err = licensemanager.NewAssociation(ctx, "example", &licensemanager.AssociationArgs{
    67  //				LicenseConfigurationArn: exampleLicenseConfiguration.Arn,
    68  //				ResourceArn:             exampleInstance.Arn,
    69  //			})
    70  //			if err != nil {
    71  //				return err
    72  //			}
    73  //			return nil
    74  //		})
    75  //	}
    76  //
    77  // ```
    78  // <!--End PulumiCodeChooser -->
    79  //
    80  // ## Import
    81  //
    82  // Using `pulumi import`, import license configurations using `resource_arn,license_configuration_arn`. For example:
    83  //
    84  // ```sh
    85  // $ pulumi import aws:licensemanager/association:Association example arn:aws:ec2:eu-west-1:123456789012:image/ami-123456789abcdef01,arn:aws:license-manager:eu-west-1:123456789012:license-configuration:lic-0123456789abcdef0123456789abcdef
    86  // ```
    87  type Association struct {
    88  	pulumi.CustomResourceState
    89  
    90  	// ARN of the license configuration.
    91  	LicenseConfigurationArn pulumi.StringOutput `pulumi:"licenseConfigurationArn"`
    92  	// ARN of the resource associated with the license configuration.
    93  	ResourceArn pulumi.StringOutput `pulumi:"resourceArn"`
    94  }
    95  
    96  // NewAssociation registers a new resource with the given unique name, arguments, and options.
    97  func NewAssociation(ctx *pulumi.Context,
    98  	name string, args *AssociationArgs, opts ...pulumi.ResourceOption) (*Association, error) {
    99  	if args == nil {
   100  		return nil, errors.New("missing one or more required arguments")
   101  	}
   102  
   103  	if args.LicenseConfigurationArn == nil {
   104  		return nil, errors.New("invalid value for required argument 'LicenseConfigurationArn'")
   105  	}
   106  	if args.ResourceArn == nil {
   107  		return nil, errors.New("invalid value for required argument 'ResourceArn'")
   108  	}
   109  	opts = internal.PkgResourceDefaultOpts(opts)
   110  	var resource Association
   111  	err := ctx.RegisterResource("aws:licensemanager/association:Association", name, args, &resource, opts...)
   112  	if err != nil {
   113  		return nil, err
   114  	}
   115  	return &resource, nil
   116  }
   117  
   118  // GetAssociation gets an existing Association resource's state with the given name, ID, and optional
   119  // state properties that are used to uniquely qualify the lookup (nil if not required).
   120  func GetAssociation(ctx *pulumi.Context,
   121  	name string, id pulumi.IDInput, state *AssociationState, opts ...pulumi.ResourceOption) (*Association, error) {
   122  	var resource Association
   123  	err := ctx.ReadResource("aws:licensemanager/association:Association", name, id, state, &resource, opts...)
   124  	if err != nil {
   125  		return nil, err
   126  	}
   127  	return &resource, nil
   128  }
   129  
   130  // Input properties used for looking up and filtering Association resources.
   131  type associationState struct {
   132  	// ARN of the license configuration.
   133  	LicenseConfigurationArn *string `pulumi:"licenseConfigurationArn"`
   134  	// ARN of the resource associated with the license configuration.
   135  	ResourceArn *string `pulumi:"resourceArn"`
   136  }
   137  
   138  type AssociationState struct {
   139  	// ARN of the license configuration.
   140  	LicenseConfigurationArn pulumi.StringPtrInput
   141  	// ARN of the resource associated with the license configuration.
   142  	ResourceArn pulumi.StringPtrInput
   143  }
   144  
   145  func (AssociationState) ElementType() reflect.Type {
   146  	return reflect.TypeOf((*associationState)(nil)).Elem()
   147  }
   148  
   149  type associationArgs struct {
   150  	// ARN of the license configuration.
   151  	LicenseConfigurationArn string `pulumi:"licenseConfigurationArn"`
   152  	// ARN of the resource associated with the license configuration.
   153  	ResourceArn string `pulumi:"resourceArn"`
   154  }
   155  
   156  // The set of arguments for constructing a Association resource.
   157  type AssociationArgs struct {
   158  	// ARN of the license configuration.
   159  	LicenseConfigurationArn pulumi.StringInput
   160  	// ARN of the resource associated with the license configuration.
   161  	ResourceArn pulumi.StringInput
   162  }
   163  
   164  func (AssociationArgs) ElementType() reflect.Type {
   165  	return reflect.TypeOf((*associationArgs)(nil)).Elem()
   166  }
   167  
   168  type AssociationInput interface {
   169  	pulumi.Input
   170  
   171  	ToAssociationOutput() AssociationOutput
   172  	ToAssociationOutputWithContext(ctx context.Context) AssociationOutput
   173  }
   174  
   175  func (*Association) ElementType() reflect.Type {
   176  	return reflect.TypeOf((**Association)(nil)).Elem()
   177  }
   178  
   179  func (i *Association) ToAssociationOutput() AssociationOutput {
   180  	return i.ToAssociationOutputWithContext(context.Background())
   181  }
   182  
   183  func (i *Association) ToAssociationOutputWithContext(ctx context.Context) AssociationOutput {
   184  	return pulumi.ToOutputWithContext(ctx, i).(AssociationOutput)
   185  }
   186  
   187  // AssociationArrayInput is an input type that accepts AssociationArray and AssociationArrayOutput values.
   188  // You can construct a concrete instance of `AssociationArrayInput` via:
   189  //
   190  //	AssociationArray{ AssociationArgs{...} }
   191  type AssociationArrayInput interface {
   192  	pulumi.Input
   193  
   194  	ToAssociationArrayOutput() AssociationArrayOutput
   195  	ToAssociationArrayOutputWithContext(context.Context) AssociationArrayOutput
   196  }
   197  
   198  type AssociationArray []AssociationInput
   199  
   200  func (AssociationArray) ElementType() reflect.Type {
   201  	return reflect.TypeOf((*[]*Association)(nil)).Elem()
   202  }
   203  
   204  func (i AssociationArray) ToAssociationArrayOutput() AssociationArrayOutput {
   205  	return i.ToAssociationArrayOutputWithContext(context.Background())
   206  }
   207  
   208  func (i AssociationArray) ToAssociationArrayOutputWithContext(ctx context.Context) AssociationArrayOutput {
   209  	return pulumi.ToOutputWithContext(ctx, i).(AssociationArrayOutput)
   210  }
   211  
   212  // AssociationMapInput is an input type that accepts AssociationMap and AssociationMapOutput values.
   213  // You can construct a concrete instance of `AssociationMapInput` via:
   214  //
   215  //	AssociationMap{ "key": AssociationArgs{...} }
   216  type AssociationMapInput interface {
   217  	pulumi.Input
   218  
   219  	ToAssociationMapOutput() AssociationMapOutput
   220  	ToAssociationMapOutputWithContext(context.Context) AssociationMapOutput
   221  }
   222  
   223  type AssociationMap map[string]AssociationInput
   224  
   225  func (AssociationMap) ElementType() reflect.Type {
   226  	return reflect.TypeOf((*map[string]*Association)(nil)).Elem()
   227  }
   228  
   229  func (i AssociationMap) ToAssociationMapOutput() AssociationMapOutput {
   230  	return i.ToAssociationMapOutputWithContext(context.Background())
   231  }
   232  
   233  func (i AssociationMap) ToAssociationMapOutputWithContext(ctx context.Context) AssociationMapOutput {
   234  	return pulumi.ToOutputWithContext(ctx, i).(AssociationMapOutput)
   235  }
   236  
   237  type AssociationOutput struct{ *pulumi.OutputState }
   238  
   239  func (AssociationOutput) ElementType() reflect.Type {
   240  	return reflect.TypeOf((**Association)(nil)).Elem()
   241  }
   242  
   243  func (o AssociationOutput) ToAssociationOutput() AssociationOutput {
   244  	return o
   245  }
   246  
   247  func (o AssociationOutput) ToAssociationOutputWithContext(ctx context.Context) AssociationOutput {
   248  	return o
   249  }
   250  
   251  // ARN of the license configuration.
   252  func (o AssociationOutput) LicenseConfigurationArn() pulumi.StringOutput {
   253  	return o.ApplyT(func(v *Association) pulumi.StringOutput { return v.LicenseConfigurationArn }).(pulumi.StringOutput)
   254  }
   255  
   256  // ARN of the resource associated with the license configuration.
   257  func (o AssociationOutput) ResourceArn() pulumi.StringOutput {
   258  	return o.ApplyT(func(v *Association) pulumi.StringOutput { return v.ResourceArn }).(pulumi.StringOutput)
   259  }
   260  
   261  type AssociationArrayOutput struct{ *pulumi.OutputState }
   262  
   263  func (AssociationArrayOutput) ElementType() reflect.Type {
   264  	return reflect.TypeOf((*[]*Association)(nil)).Elem()
   265  }
   266  
   267  func (o AssociationArrayOutput) ToAssociationArrayOutput() AssociationArrayOutput {
   268  	return o
   269  }
   270  
   271  func (o AssociationArrayOutput) ToAssociationArrayOutputWithContext(ctx context.Context) AssociationArrayOutput {
   272  	return o
   273  }
   274  
   275  func (o AssociationArrayOutput) Index(i pulumi.IntInput) AssociationOutput {
   276  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Association {
   277  		return vs[0].([]*Association)[vs[1].(int)]
   278  	}).(AssociationOutput)
   279  }
   280  
   281  type AssociationMapOutput struct{ *pulumi.OutputState }
   282  
   283  func (AssociationMapOutput) ElementType() reflect.Type {
   284  	return reflect.TypeOf((*map[string]*Association)(nil)).Elem()
   285  }
   286  
   287  func (o AssociationMapOutput) ToAssociationMapOutput() AssociationMapOutput {
   288  	return o
   289  }
   290  
   291  func (o AssociationMapOutput) ToAssociationMapOutputWithContext(ctx context.Context) AssociationMapOutput {
   292  	return o
   293  }
   294  
   295  func (o AssociationMapOutput) MapIndex(k pulumi.StringInput) AssociationOutput {
   296  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Association {
   297  		return vs[0].(map[string]*Association)[vs[1].(string)]
   298  	}).(AssociationOutput)
   299  }
   300  
   301  func init() {
   302  	pulumi.RegisterInputType(reflect.TypeOf((*AssociationInput)(nil)).Elem(), &Association{})
   303  	pulumi.RegisterInputType(reflect.TypeOf((*AssociationArrayInput)(nil)).Elem(), AssociationArray{})
   304  	pulumi.RegisterInputType(reflect.TypeOf((*AssociationMapInput)(nil)).Elem(), AssociationMap{})
   305  	pulumi.RegisterOutputType(AssociationOutput{})
   306  	pulumi.RegisterOutputType(AssociationArrayOutput{})
   307  	pulumi.RegisterOutputType(AssociationMapOutput{})
   308  }