I want to know if the Amazon Elastic Compute Cloud (Amazon EC2) instances in my AWS account are AWS Marketplace resources.
Resolution
Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.
To get the ProductCodeType attribute to confirm that an Amazon EC2 instance is from the AWS Marketplace, use one of the following methods.
Use the AWS API
To check whether an EC2 instance is from the AWS Marketplace, run the DescribeInstances API call.
If the product-code.type value in the output is marketplace, then the instance launched from AWS Marketplace and is an AWS Marketplace resource.
Use the AWS CLI
To check whether an EC2 instance is from AWS Marketplace, run the describe-instances AWS CLI command:
aws ec2 describe-instances --instance-ids instance id
Note: Replace instance id with your instance ID.
To list the EC2 instances in your account that are from AWS Marketplace, run the describe-instances command. Include the following filters:
aws ec2 describe-instances --filters "Name=product-code.type,Values=marketplace"
If the ProductCodeType value in the output is marketplace, then the instance launched from AWS Marketplace and is an AWS Marketplace resource.
Example output:
{
"Reservations": [
{
"Groups": [],
"Instances": [
.
.
.
"InstanceId": "i-047exxxxxxxxxxxxxxx",
"ImageId": "ami-0b1d6xxxxxxxxxxxx",
"State": {
.
.
.
"ProductCodes": [
{
"ProductCodeId": "f2ew2wrz425a1XXXXXXXXXXXX",
"ProductCodeType": "marketplace"
}
],
"PublicDnsName": "<Url>",
"PublicIpAddress": "3.84.45.111",
"State": {
"Code": 16,
"Name": "running"
},
"OwnerId": "<AccountId>",
"ReservationId": "r-09ed6690267346ef8"
}
]
}