This documentation is for Version 1 of the Amazon CLI only. For documentation related to Version 2 of the Amazon CLI, see the Version 2 User Guide.
License Manager examples using Amazon CLI
The following code examples show you how to perform actions and implement common scenarios by using the Amazon Command Line Interface with License Manager.
Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.
Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.
Topics
Actions
The following code example shows how to use create-license-configuration.
- Amazon CLI
-
Example 1: To create a license configuration
The following
create-license-configurationexample creates a license configuration with a hard limit of 10 cores.aws license-manager create-license-configuration --namemy-license-configuration\ --license-counting-typeCore\ --license-count10\ --license-count-hard-limitOutput:
{ "LicenseConfigurationArn": "arn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-6eb6586f508a786a2ba41EXAMPLE1111" }Example 2: To create a license configuration
The following
create-license-configurationexample creates a license configuration with a soft limit of 100 vCPUs. It uses a rule to enable vCPU optimization.aws license-manager create-license-configuration --namemy-license-configuration--license-counting-typevCPU\ --license-count100\ --license-rules"#honorVcpuOptimization=true"Output:
{ "LicenseConfigurationArn": "arn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-6eb6586f508a786a2ba41EXAMPLE2222" }-
For API details, see CreateLicenseConfiguration
in Amazon CLI Command Reference.
-
The following code example shows how to use delete-license-configuration.
- Amazon CLI
-
To delete a license configuration
The following
delete-license-configurationexample deletes the specified license configuration.aws license-manager delete-license-configuration \ --license-configuration-arnarn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-6eb6586f508a786a2ba4f56c1EXAMPLEThis command produces no output.
-
For API details, see DeleteLicenseConfiguration
in Amazon CLI Command Reference.
-
The following code example shows how to use get-license-configuration.
- Amazon CLI
-
To get license configuration information
The following
get-license-configurationexample displays details for the specified license configuration.aws license-manager get-license-configuration \ --license-configuration-arnarn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-38b658717b87478aaa7c00883EXAMPLEOutput:
{ "LicenseConfigurationId": "lic-38b658717b87478aaa7c00883EXAMPLE", "LicenseConfigurationArn": "arn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-38b658717b87478aaa7c00883EXAMPLE", "Name": "my-license-configuration", "LicenseCountingType": "vCPU", "LicenseRules": [], "LicenseCountHardLimit": false, "ConsumedLicenses": 0, "Status": "AVAILABLE", "OwnerAccountId": "123456789012", "ConsumedLicenseSummaryList": [ { "ResourceType": "EC2_INSTANCE", "ConsumedLicenses": 0 }, { "ResourceType": "EC2_HOST", "ConsumedLicenses": 0 }, { "ResourceType": "SYSTEMS_MANAGER_MANAGED_INSTANCE", "ConsumedLicenses": 0 } ], "ManagedResourceSummaryList": [ { "ResourceType": "EC2_INSTANCE", "AssociationCount": 0 }, { "ResourceType": "EC2_HOST", "AssociationCount": 0 }, { "ResourceType": "EC2_AMI", "AssociationCount": 2 }, { "ResourceType": "SYSTEMS_MANAGER_MANAGED_INSTANCE", "AssociationCount": 0 } ] }-
For API details, see GetLicenseConfiguration
in Amazon CLI Command Reference.
-
The following code example shows how to use get-service-settings.
- Amazon CLI
-
To get the License Manager settings
The following
get-service-settingsexample displays the service settings for License Manager in the current Region.aws license-manager get-service-settingsThe following shows example output if cross-account resource discovery is disabled.
{ "OrganizationConfiguration": { "EnableIntegration": false }, "EnableCrossAccountsDiscovery": false }The following shows example output if cross-account resource discovery is enabled.
{ "S3BucketArn": "arn:aws:s3:::aws-license-manager-service-c22d6279-35c4-47c4-bb", "OrganizationConfiguration": { "EnableIntegration": true }, "EnableCrossAccountsDiscovery": true }-
For API details, see GetServiceSettings
in Amazon CLI Command Reference.
-
The following code example shows how to use list-associations-for-license-configuration.
- Amazon CLI
-
To get associations for a license configuration
The following
list-associations-for-license-configurationexample displays detailed information for the associations of the specified license configuration.aws license-manager list-associations-for-license-configuration \ --license-configuration-arnarn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-38b658717b87478aaa7c00883EXAMPLEOutput:
{ "LicenseConfigurationAssociations": [ { "ResourceArn": "arn:aws:ec2:us-west-2::image/ami-1234567890abcdef0", "ResourceType": "EC2_AMI", "ResourceOwnerId": "123456789012", "AssociationTime": 1568825118.617 }, { "ResourceArn": "arn:aws:ec2:us-west-2::image/ami-0abcdef1234567890", "ResourceType": "EC2_AMI", "ResourceOwnerId": "123456789012", "AssociationTime": 1568825118.946 } ] }-
For API details, see ListAssociationsForLicenseConfiguration
in Amazon CLI Command Reference.
-
The following code example shows how to use list-license-configurations.
- Amazon CLI
-
Example 1: To list all of your license configurations
The following
list-license-configurationsexample lists all your license configurations.aws license-manager list-license-configurationsOutput:
{ "LicenseConfigurations": [ { "LicenseConfigurationId": "lic-6eb6586f508a786a2ba4f56c1EXAMPLE", "LicenseConfigurationArn": "arn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-6eb6586f508a786a2ba4f56c1EXAMPLE", "Name": "my-license-configuration", "LicenseCountingType": "Core", "LicenseRules": [], "LicenseCount": 10, "LicenseCountHardLimit": true, "ConsumedLicenses": 0, "Status": "AVAILABLE", "OwnerAccountId": "123456789012", "ConsumedLicenseSummaryList": [ { "ResourceType": "EC2_INSTANCE", "ConsumedLicenses": 0 }, { "ResourceType": "EC2_HOST", "ConsumedLicenses": 0 }, { "ResourceType": "SYSTEMS_MANAGER_MANAGED_INSTANCE", "ConsumedLicenses": 0 } ], "ManagedResourceSummaryList": [ { "ResourceType": "EC2_INSTANCE", "AssociationCount": 0 }, { "ResourceType": "EC2_HOST", "AssociationCount": 0 }, { "ResourceType": "EC2_AMI", "AssociationCount": 0 }, { "ResourceType": "SYSTEMS_MANAGER_MANAGED_INSTANCE", "AssociationCount": 0 } ] }, { ... } ] }Example 2: To list a specific license configuration
The following
list-license-configurationsexample lists only the specified license configuration.aws license-manager list-license-configurations \ --license-configuration-arnsarn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-38b658717b87478aaa7c00883EXAMPLE-
For API details, see ListLicenseConfigurations
in Amazon CLI Command Reference.
-
The following code example shows how to use list-license-specifications-for-resource.
- Amazon CLI
-
To list the license configurations for a resource
The following
list-license-specifications-for-resourceexample lists the license configurations associated with the specified Amazon Machine Image (AMI).aws license-manager list-license-specifications-for-resource \ --resource-arnarn:aws:ec2:us-west-2::image/ami-1234567890abcdef0Output:
{ "LicenseConfigurationArn": "arn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-38b658717b87478aaa7c00883EXAMPLE" }-
For API details, see ListLicenseSpecificationsForResource
in Amazon CLI Command Reference.
-
The following code example shows how to use list-resource-inventory.
- Amazon CLI
-
To list resources in the resource inventory
The following
list-resource-inventoryexample lists the resources managed using Systems Manager inventory.aws license-manager list-resource-inventoryOutput:
{ "ResourceInventoryList": [ { "Platform": "Red Hat Enterprise Linux Server", "ResourceType": "EC2Instance", "PlatformVersion": "7.4", "ResourceArn": "arn:aws:ec2:us-west-2:1234567890129:instance/i-05d3cdfb05bd36376", "ResourceId": "i-05d3cdfb05bd36376", "ResourceOwningAccountId": "1234567890129" }, { "Platform": "Amazon Linux", "ResourceType": "EC2Instance", "PlatformVersion": "2", "ResourceArn": "arn:aws:ec2:us-west-2:1234567890129:instance/i-0b1d036cfd4594808", "ResourceId": "i-0b1d036cfd4594808", "ResourceOwningAccountId": "1234567890129" }, { "Platform": "Microsoft Windows Server 2019 Datacenter", "ResourceType": "EC2Instance", "PlatformVersion": "10.0.17763", "ResourceArn": "arn:aws:ec2:us-west-2:1234567890129:instance/i-0cdb3b54a2a8246ad", "ResourceId": "i-0cdb3b54a2a8246ad", "ResourceOwningAccountId": "1234567890129" } ] }-
For API details, see ListResourceInventory
in Amazon CLI Command Reference.
-
The following code example shows how to use list-tags-for-resource.
- Amazon CLI
-
To list the tags for a license configuration
The following
list-tags-for-resourceexample lists the tags for the specified license configuration.aws license-manager list-tags-for-resource \ --resource-arnarn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-6eb6586f508a786a2ba4f56c1EXAMPLEOutput:
{ "Tags": [ { "Key": "project", "Value": "lima" } ] }-
For API details, see ListTagsForResource
in Amazon CLI Command Reference.
-
The following code example shows how to use list-usage-for-license-configuration.
- Amazon CLI
-
To list the licenses in use for a license configuration
The following
list-usage-for-license-configurationexample lists information about the resources using licenses for the specified license configuration. For example, if the license type is vCPU, any instances consume one license per vCPU.aws license-manager list-usage-for-license-configuration \ --license-configuration-arnarn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-38b658717b87478aaa7c00883EXAMPLEOutput:
{ "LicenseConfigurationUsageList": [ { "ResourceArn": "arn:aws:ec2:us-west-2:123456789012:instance/i-04a636d18e83cfacb", "ResourceType": "EC2_INSTANCE", "ResourceStatus": "running", "ResourceOwnerId": "123456789012", "AssociationTime": 1570892850.519, "ConsumedLicenses": 2 } ] }-
For API details, see ListUsageForLicenseConfiguration
in Amazon CLI Command Reference.
-
The following code example shows how to use tag-resource.
- Amazon CLI
-
To add a tag a license configuration
The following
tag-resourceexample adds the specified tag (key name and value) to the specified license configuration.aws license-manager tag-resource \ --tagsKey=project,Value=lima\ --resource-arnarn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-6eb6586f508a786a2ba4f56c1EXAMPLEThis command produces no output.
-
For API details, see TagResource
in Amazon CLI Command Reference.
-
The following code example shows how to use untag-resource.
- Amazon CLI
-
To remove tags from a license configuration
The following
untag-resourceexample removes the specified tag (key name and resource) from the specified license configuration.aws license-manager untag-resource \ --tag-keysproject\ --resource-arnarn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-6eb6586f508a786a2ba4f56c1EXAMPLEThis command produces no output.
-
For API details, see UntagResource
in Amazon CLI Command Reference.
-
The following code example shows how to use update-license-configuration.
- Amazon CLI
-
To update a license configuration
The following
update-license-configurationexample updates the specified license configuration to remove the hard limit.aws license-manager update-license-configuration \ --no-license-count-hard-limit \ --license-configuration-arnarn:aws:license-manager:us-west-2:880185128111:license-configuration:lic-6eb6586f508a786a2ba4f56c1EXAMPLEThis command produces no output.
The following
update-license-configurationexample updates the specified license configuration to change its status toDISABLED.aws license-manager update-license-configuration \ --license-configuration-statusDISABLED--license-configuration-arnarn:aws:license-manager:us-west-2:880185128111:license-configuration:lic-6eb6586f508a786a2ba4f56c1EXAMPLEThis command produces no output.
-
For API details, see UpdateLicenseConfiguration
in Amazon CLI Command Reference.
-
The following code example shows how to use update-license-specifications-for-resource.
- Amazon CLI
-
To update the license configurations for a resource
The following
update-license-specifications-for-resourceexample replaces the license configuration associated with the specified Amazon Machine Image (AMI) by removing one license configuration and adding another.aws license-manager update-license-specifications-for-resource \ --resource-arnarn:aws:ec2:us-west-2::image/ami-1234567890abcdef0\ --remove-license-specificationsLicenseConfigurationArn=arn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-38b658717b87478aaa7c00883EXAMPLE\ --add-license-specificationsLicenseConfigurationArn=arn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-42b6deb06e5399a980d555927EXAMPLEThis command produces no output.
-
For API details, see UpdateLicenseSpecificationsForResource
in Amazon CLI Command Reference.
-
The following code example shows how to use update-service-settings.
- Amazon CLI
-
To update the License Manager settings
The following
update-service-settingsexample enables cross-account resource discovery for License Manager in the current Amazon Region. The Amazon S3 bucket is the Resource Data Sync required for Systems Manager inventory.aws license-manager update-service-settings \ --organization-configurationEnableIntegration=true\ --enable-cross-accounts-discovery \ --s3-bucket-arnarn:aws:s3:::aws-license-manager-service-abcd1234EXAMPLEThis command produces no output.
-
For API details, see UpdateServiceSettings
in Amazon CLI Command Reference.
-