Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create_budget 'CostFilters' doesn't filter cost data with tag and service #4248

Open
yambottle opened this issue Aug 27, 2024 · 3 comments
Open
Assignees
Labels
bug This issue is a confirmed bug. costexplorer A low-level client representing AWS Cost Explorer Service p2 This is a standard priority issue service-api This issue is caused by the service API, not the SDK implementation.

Comments

@yambottle
Copy link

Describe the bug

Following boto3 latest(1.35.6) create_budget doc to create a budget with tag and service filter:

budget.create_budget(
        AccountId=os.getenv("AWS_ID"),
        Budget={
            'BudgetName': f"test_ec2_monthly",
            'BudgetLimit': {
                'Amount': '100.00',
                'Unit': 'USD'
            },
            'CostFilters': {
                # 'Tag': [f'Contract:fmi_luthi'],
                # 'TagKeyValue': [f'Contract$fmi_luthi'],
                'TagKeyValue': [f'user:Contract$fmi_luthi'],
                'Service': [
                    # 'AmazonEC2'
                    # 'Amazon EC2'
                    'EC2-Instances (Elastic Compute Cloud - Compute)', 
                    'EC2-Other'
                ]
            },
            'CostTypes': {
                'IncludeTax': True,
                'IncludeSubscription': True,
                'UseBlended': True,
                'IncludeRefund': False,
                'IncludeCredit': False,
                'IncludeUpfront': True,
                'IncludeRecurring': True,
                'IncludeOtherSubscription': True,
                'IncludeSupport': True,
                'IncludeDiscount': False,
                'UseAmortized': False
            },
            'TimeUnit': 'MONTHLY',
            'BudgetType': 'COST',
        },
        NotificationsWithSubscribers=[
        ]
    )

The test_ec2_monthly budget is created, but wasn't filtered correctly(no cost data at all after applied cost filter).

This budget displays the correct filter on the budget parameter:
Screenshot from 2024-08-27 10-29-42

but there is no cost data in the preview in the edit:
Screenshot from 2024-08-27 10-30-01

However, manually removing and applying the same budget with the same filter through the edit budget console makes it works as expected(cost data showing on the preview).
Screenshot from 2024-08-27 10-33-00

Expected Behavior

create_budget with tag and service filter should filter the cost data correctly:

'CostFilters': {
                # 'Tag': [f'Contract:fmi_luthi'],
                # 'TagKeyValue': [f'Contract$fmi_luthi'],
                'TagKeyValue': [f'user:Contract$fmi_luthi'],
                'Service': [
                    # 'AmazonEC2'
                    # 'Amazon EC2'
                    'EC2-Instances (Elastic Compute Cloud - Compute)', 
                    'EC2-Other'
                ]
            },

Screenshot from 2024-08-27 10-33-00

Current Behavior

create_budget with tag and service showing empty cost data(seems like the cost data has been falsely filtered)

Screenshot from 2024-08-27 10-30-01

Reproduction Steps

  • Create a cost allocate tag Contract
  • Tag EC2 instance and its related resources by this tag Contract:fmi_luthi
  • As a correct behavior comparison, manually create a budget on the AWS console filtered by tag Contract:fmi_luthi and service EC2-Instances (Elastic Compute Cloud - Compute), EC2-Other
  • Use boto3 to create a new budget with the same filter. You'll see this budget has empty cost data once been created by boto3, but if you reapply the same filter on the AWS console by editing this budget, the cost data will show correctly.
budget.create_budget(
        AccountId=os.getenv("AWS_ID"),
        Budget={
            'BudgetName': f"test_ec2_monthly",
            'BudgetLimit': {
                'Amount': '100.00',
                'Unit': 'USD'
            },
            'CostFilters': {
                # 'Tag': [f'Contract:fmi_luthi'],
                # 'TagKeyValue': [f'Contract$fmi_luthi'],
                'TagKeyValue': [f'user:Contract$fmi_luthi'],
                'Service': [
                    # 'AmazonEC2'
                    # 'Amazon EC2'
                    'EC2-Instances (Elastic Compute Cloud - Compute)', 
                    'EC2-Other'
                ]
            },
            'CostTypes': {
                'IncludeTax': True,
                'IncludeSubscription': True,
                'UseBlended': True,
                'IncludeRefund': False,
                'IncludeCredit': False,
                'IncludeUpfront': True,
                'IncludeRecurring': True,
                'IncludeOtherSubscription': True,
                'IncludeSupport': True,
                'IncludeDiscount': False,
                'UseAmortized': False
            },
            'TimeUnit': 'MONTHLY',
            'BudgetType': 'COST',
        },
        NotificationsWithSubscribers=[
        ]
    )

Possible Solution

No response

Additional Information/Context

No response

SDK version used

1.35.6

Environment details (OS name and version, etc.)

Ubuntu 22.04

@yambottle yambottle added bug This issue is a confirmed bug. needs-triage This issue or PR still needs to be triaged. labels Aug 27, 2024
@RyanFitzSimmonsAK RyanFitzSimmonsAK self-assigned this Aug 28, 2024
@RyanFitzSimmonsAK RyanFitzSimmonsAK added costexplorer A low-level client representing AWS Cost Explorer Service p2 This is a standard priority issue investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Aug 28, 2024
@yambottle
Copy link
Author

@RyanFitzSimmonsAK Thanks for checking this issue!

@RyanFitzSimmonsAK
Copy link
Contributor

Hi @yambottle, thanks for reaching out. I was able to reproduce this behavior. I've reached out to the service team for more information, and will let you know when I hear back. In the meantime, as this is a service issue, I've created a tracking issue in our cross-SDK repository (aws/aws-sdk#812). Please refer to that issue for future updates. Thanks!

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

@RyanFitzSimmonsAK RyanFitzSimmonsAK added the service-api This issue is caused by the service API, not the SDK implementation. label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a confirmed bug. costexplorer A low-level client representing AWS Cost Explorer Service p2 This is a standard priority issue service-api This issue is caused by the service API, not the SDK implementation.
Projects
None yet
Development

No branches or pull requests

2 participants