AWS Classic

v5.21.1 published on Thursday, Nov 17, 2022 by Pulumi

Association

Provides a License Manager association.

Note: License configurations can also be associated with launch templates by specifying the license_specifications block for an aws.ec2.LaunchTemplate.

Example Usage

using System.Collections.Generic;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var exampleAmi = Aws.Ec2.GetAmi.Invoke(new()
    {
        MostRecent = true,
        Owners = new[]
        {
            "amazon",
        },
        Filters = new[]
        {
            new Aws.Ec2.Inputs.GetAmiFilterInputArgs
            {
                Name = "name",
                Values = new[]
                {
                    "amzn-ami-vpc-nat*",
                },
            },
        },
    });

    var exampleInstance = new Aws.Ec2.Instance("exampleInstance", new()
    {
        Ami = exampleAmi.Apply(getAmiResult => getAmiResult.Id),
        InstanceType = "t2.micro",
    });

    var exampleLicenseConfiguration = new Aws.LicenseManager.LicenseConfiguration("exampleLicenseConfiguration", new()
    {
        LicenseCountingType = "Instance",
    });

    var exampleAssociation = new Aws.LicenseManager.Association("exampleAssociation", new()
    {
        LicenseConfigurationArn = exampleLicenseConfiguration.Arn,
        ResourceArn = exampleInstance.Arn,
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2"
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/licensemanager"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		exampleAmi, err := ec2.LookupAmi(ctx, &ec2.LookupAmiArgs{
			MostRecent: pulumi.BoolRef(true),
			Owners: []string{
				"amazon",
			},
			Filters: []ec2.GetAmiFilter{
				ec2.GetAmiFilter{
					Name: "name",
					Values: []string{
						"amzn-ami-vpc-nat*",
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		exampleInstance, err := ec2.NewInstance(ctx, "exampleInstance", &ec2.InstanceArgs{
			Ami:          pulumi.String(exampleAmi.Id),
			InstanceType: pulumi.String("t2.micro"),
		})
		if err != nil {
			return err
		}
		exampleLicenseConfiguration, err := licensemanager.NewLicenseConfiguration(ctx, "exampleLicenseConfiguration", &licensemanager.LicenseConfigurationArgs{
			LicenseCountingType: pulumi.String("Instance"),
		})
		if err != nil {
			return err
		}
		_, err = licensemanager.NewAssociation(ctx, "exampleAssociation", &licensemanager.AssociationArgs{
			LicenseConfigurationArn: exampleLicenseConfiguration.Arn,
			ResourceArn:             exampleInstance.Arn,
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.Ec2Functions;
import com.pulumi.aws.ec2.inputs.GetAmiArgs;
import com.pulumi.aws.ec2.Instance;
import com.pulumi.aws.ec2.InstanceArgs;
import com.pulumi.aws.licensemanager.LicenseConfiguration;
import com.pulumi.aws.licensemanager.LicenseConfigurationArgs;
import com.pulumi.aws.licensemanager.Association;
import com.pulumi.aws.licensemanager.AssociationArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var exampleAmi = Ec2Functions.getAmi(GetAmiArgs.builder()
            .mostRecent(true)
            .owners("amazon")
            .filters(GetAmiFilterArgs.builder()
                .name("name")
                .values("amzn-ami-vpc-nat*")
                .build())
            .build());

        var exampleInstance = new Instance("exampleInstance", InstanceArgs.builder()        
            .ami(exampleAmi.applyValue(getAmiResult -> getAmiResult.id()))
            .instanceType("t2.micro")
            .build());

        var exampleLicenseConfiguration = new LicenseConfiguration("exampleLicenseConfiguration", LicenseConfigurationArgs.builder()        
            .licenseCountingType("Instance")
            .build());

        var exampleAssociation = new Association("exampleAssociation", AssociationArgs.builder()        
            .licenseConfigurationArn(exampleLicenseConfiguration.arn())
            .resourceArn(exampleInstance.arn())
            .build());

    }
}
import pulumi
import pulumi_aws as aws

example_ami = aws.ec2.get_ami(most_recent=True,
    owners=["amazon"],
    filters=[aws.ec2.GetAmiFilterArgs(
        name="name",
        values=["amzn-ami-vpc-nat*"],
    )])
example_instance = aws.ec2.Instance("exampleInstance",
    ami=example_ami.id,
    instance_type="t2.micro")
example_license_configuration = aws.licensemanager.LicenseConfiguration("exampleLicenseConfiguration", license_counting_type="Instance")
example_association = aws.licensemanager.Association("exampleAssociation",
    license_configuration_arn=example_license_configuration.arn,
    resource_arn=example_instance.arn)
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const exampleAmi = aws.ec2.getAmi({
    mostRecent: true,
    owners: ["amazon"],
    filters: [{
        name: "name",
        values: ["amzn-ami-vpc-nat*"],
    }],
});
const exampleInstance = new aws.ec2.Instance("exampleInstance", {
    ami: exampleAmi.then(exampleAmi => exampleAmi.id),
    instanceType: "t2.micro",
});
const exampleLicenseConfiguration = new aws.licensemanager.LicenseConfiguration("exampleLicenseConfiguration", {licenseCountingType: "Instance"});
const exampleAssociation = new aws.licensemanager.Association("exampleAssociation", {
    licenseConfigurationArn: exampleLicenseConfiguration.arn,
    resourceArn: exampleInstance.arn,
});
resources:
  exampleInstance:
    type: aws:ec2:Instance
    properties:
      ami: ${exampleAmi.id}
      instanceType: t2.micro
  exampleLicenseConfiguration:
    type: aws:licensemanager:LicenseConfiguration
    properties:
      licenseCountingType: Instance
  exampleAssociation:
    type: aws:licensemanager:Association
    properties:
      licenseConfigurationArn: ${exampleLicenseConfiguration.arn}
      resourceArn: ${exampleInstance.arn}
variables:
  exampleAmi:
    Fn::Invoke:
      Function: aws:ec2:getAmi
      Arguments:
        mostRecent: true
        owners:
          - amazon
        filters:
          - name: name
            values:
              - amzn-ami-vpc-nat*

Create Association Resource

new Association(name: string, args: AssociationArgs, opts?: CustomResourceOptions);
@overload
def Association(resource_name: str,
                opts: Optional[ResourceOptions] = None,
                license_configuration_arn: Optional[str] = None,
                resource_arn: Optional[str] = None)
@overload
def Association(resource_name: str,
                args: AssociationArgs,
                opts: Optional[ResourceOptions] = None)
func NewAssociation(ctx *Context, name string, args AssociationArgs, opts ...ResourceOption) (*Association, error)
public Association(string name, AssociationArgs args, CustomResourceOptions? opts = null)
public Association(String name, AssociationArgs args)
public Association(String name, AssociationArgs args, CustomResourceOptions options)
type: aws:licensemanager:Association
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args AssociationArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args AssociationArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args AssociationArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args AssociationArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args AssociationArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Association Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The Association resource accepts the following input properties:

LicenseConfigurationArn string

ARN of the license configuration.

ResourceArn string

ARN of the resource associated with the license configuration.

LicenseConfigurationArn string

ARN of the license configuration.

ResourceArn string

ARN of the resource associated with the license configuration.

licenseConfigurationArn String

ARN of the license configuration.

resourceArn String

ARN of the resource associated with the license configuration.

licenseConfigurationArn string

ARN of the license configuration.

resourceArn string

ARN of the resource associated with the license configuration.

license_configuration_arn str

ARN of the license configuration.

resource_arn str

ARN of the resource associated with the license configuration.

licenseConfigurationArn String

ARN of the license configuration.

resourceArn String

ARN of the resource associated with the license configuration.

Outputs

All input properties are implicitly available as output properties. Additionally, the Association resource produces the following output properties:

Id string

The provider-assigned unique ID for this managed resource.

Id string

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

id string

The provider-assigned unique ID for this managed resource.

id str

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

Look up Existing Association Resource

Get an existing Association resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: AssociationState, opts?: CustomResourceOptions): Association
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        license_configuration_arn: Optional[str] = None,
        resource_arn: Optional[str] = None) -> Association
func GetAssociation(ctx *Context, name string, id IDInput, state *AssociationState, opts ...ResourceOption) (*Association, error)
public static Association Get(string name, Input<string> id, AssociationState? state, CustomResourceOptions? opts = null)
public static Association get(String name, Output<String> id, AssociationState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
LicenseConfigurationArn string

ARN of the license configuration.

ResourceArn string

ARN of the resource associated with the license configuration.

LicenseConfigurationArn string

ARN of the license configuration.

ResourceArn string

ARN of the resource associated with the license configuration.

licenseConfigurationArn String

ARN of the license configuration.

resourceArn String

ARN of the resource associated with the license configuration.

licenseConfigurationArn string

ARN of the license configuration.

resourceArn string

ARN of the resource associated with the license configuration.

license_configuration_arn str

ARN of the license configuration.

resource_arn str

ARN of the resource associated with the license configuration.

licenseConfigurationArn String

ARN of the license configuration.

resourceArn String

ARN of the resource associated with the license configuration.

Import

License configurations can be imported in the form resource_arn,license_configuration_arn, e.g.,

 $ 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

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes

This Pulumi package is based on the aws Terraform Provider.