AWS Marketplace의 AMI 제품에 대한 비용 할당 태그 지정 - AWS Marketplace

AWS Marketplace의 AMI 제품에 대한 비용 할당 태그 지정

AWS Marketplace는 Amazon Machine Image(AMI) 기반 소프트웨어 제품의 비용 할당 태그 지정을 지원합니다. 신규 및 기존 Amazon Elastic Compute Cloud(Amazon EC2) 인스턴스 태그는 해당 AWS Marketplace AMI 사용량에 따라 자동으로 채워집니다. 활성화된 비용 할당 태그를 사용하여 AWS Cost Explorer, AWS Cost & Usage Report, AWS Budgets 또는 기타 클라우드 비용 분석 도구를 통해 AMI 사용량을 확인하고 추적할 수 있습니다.

AMI를 제공한 공급업체는 제품 관련 정보를 기반으로 AMI 기반 제품의 요금 측정에 다른 사용자 지정 태그를 기록할 수도 있습니다. 자세한 내용은 비용 할당 태그 사용를 참조하세요.

태그를 이용하면 리소스를 정리할 수 있고, 비용 할당 태그를 이용하면 AWS 비용을 더 자세히 추적할 수 있습니다. 비용 할당 태그를 활성화하면 AWS은(는) 비용 할당 태그를 이용해 비용 할당 보고서에서 리소스 비용을 정리하기 때문에 사용자는 쉽게 AWS 비용을 분류하고 추적할 수 있습니다.

비용 할당 태그 지정은 과금 정보 및 비용 관리 콘솔에서 태그가 활성화된 시점 이후의 비용만 추적합니다. AWS 계정 소유자, AWS Organizations 관리 계정 소유자 및 적절한 권한이 있는 사용자만 계정의 과금 정보 및 비용 관리 콘솔에 액세스할 수 있습니다. 비용 할당 태그 사용 여부는 청구되는 금액에 영향을 주지 않습니다. 비용 할당 태그 사용 여부는 AMI 기반 소프트웨어 제품의 기능에 영향을 주지 않습니다.

여러 인스턴스에서 단일 AMI에 대한 비용 할당 태그 추적

AWS Marketplace AMI 구독에 대해 시작되는 각 Amazon EC2 인스턴스는 AWS Cost & Usage Report에 해당 AWS Marketplace 소프트웨어 사용 항목이 있습니다. AWS Marketplace 사용량에는 해당 Amazon EC2 인스턴스에 적용된 특정 태그가 항상 반영됩니다. 따라서 인스턴스 수준에서 할당된 다른 값을 기준으로 AWS Marketplace 사용 비용을 구별할 수 있습니다.

또한 태그 기반 사용 비용을 합산하면 Cost Explorer 또는 AWS Cost & Usage Report에서 청구서에 반영된 AMI 소프트웨어 사용 비용과 같습니다.

비용 할당되고 태그 지정된 인스턴스를 사용하여 예산 찾기

과금 정보 및 비용 관리 콘솔의 여러 Amazon EC2 인스턴스에 대한 비용 할당 태그에서 활성 예산을 이미 필터링한 경우 예산을 모두 찾는 것이 어려울 수 있습니다. 다음 Python 스크립트는 현재 AWS 리전의 AWS Marketplace에서 Amazon EC2 인스턴스를 포함하는 예산 목록을 반환합니다.

이 스크립트를 사용하여 예산에 미치는 잠재적 영향과 이 변경으로 인해 오버런이 발생할 수 있는 위치를 파악할 수 있습니다. 청구되는 금액은 변경되지 않지만 예산에 영향을 줄 수 있는 비용 할당이 더 정확하게 반영됩니다.

#! /usr/bin/python import boto3 session = boto3.Session() b3account=boto3.client('sts').get_caller_identity()['Account'] print("using account {} in region {}".format(b3account,session.region_name)) def getBudgetFilters(filtertype): ''' Returns budgets nested within the filter values [filter value][budeget name]. The filtertype is the CostFilter Key such as Region, Service, TagKeyValue. ''' budget_client = session.client('budgets') budgets_paginator = budget_client.get_paginator('describe_budgets') budget_result = budgets_paginator.paginate( AccountId=b3account ).build_full_result() returnval = {} if 'Budgets' in budget_result: for budget in budget_result['Budgets']: for cftype in budget['CostFilters']: if filtertype == cftype: for cfval in budget['CostFilters'][cftype]: if cfval in returnval: if not budget['BudgetName'] in returnval[cfval]: returnval[cfval].append(budget['BudgetName']) else: returnval[cfval] = [ budget['BudgetName'] ] return returnval def getMarketplaceInstances(): ''' Get all the AWS EC2 instances which originated with AWS Marketplace. ''' ec2_client = session.client('ec2') paginator = ec2_client.get_paginator('describe_instances') returnval = paginator.paginate( Filters=[{ 'Name': 'product-code.type', 'Values': ['marketplace'] }] ).build_full_result() return returnval def getInstances(): mp_instances = getMarketplaceInstances() budget_tags = getBudgetFilters("TagKeyValue") cost_instance_budgets = [] for instance in [inst for resrv in mp_instances['Reservations'] for inst in resrv['Instances'] if 'Tags' in inst.keys()]: for tag in instance['Tags']: # combine the tag and value to get the budget filter string str_full = "user:{}${}".format(tag['Key'], tag['Value']) if str_full in budget_tags: for budget in budget_tags[str_full]: if not budget in cost_instance_budgets: cost_instance_budgets.append(budget) print("\r\nBudgets containing tagged Marketplace EC2 instances:") print( '\r\n'.join([budgetname for budgetname in cost_instance_budgets]) ) if __name__ == "__main__": getInstances()

출력 예

Using account 123456789012 in region us-east-2 Budgets containing tagged Marketplace EC2 instances: EC2 simple MP-test-2

자세한 정보는 다음 주제를 참조하세요.