pulumi / pulumi-aws

An Amazon Web Services (AWS) Pulumi resource package, providing multi-language access to AWS
Apache License 2.0
452 stars 155 forks source link

aws.costexplorer.CostCategory ignores/changes order of rules #3560

Open spock-abadai opened 6 months ago

spock-abadai commented 6 months ago

What happened?

I imported a cost category and the sequence of rules imported into the state was in a different order than the rules actually in AWS. When I then modified the rule order in my stack code and ran pulumi up, the preview claimed no change is necessary.

The order of rules in a cost category is important, as the rules are evaluated in order, and evaluation stops once a rule matches.

Example

  new aws.costexplorer.CostCategory("category-department",{
    rules: [
      {
        type: "INHERITED_VALUE",
        inheritedValue: {
          dimensionKey: "company:cost:owner",
          dimensionName: "TAG"
        },
      },
      {
        type: "REGULAR",
        value: "Production",
        rule: {
          dimension: {
            key: "LINKED_ACCOUNT",
            matchOptions: ["EQUALS"],
            values: [
              "123456789012"
            ]
          },
        },
      },
      {
        type: "REGULAR",
        value: "IT",
        rule: {
          dimension: {
            key: "LINKED_ACCOUNT",
            matchOptions: ["EQUALS"],
            values: [
              "210987654321"
            ]
          },
        },
      },
    ],
    name: "Department",
    ruleVersion: "CostCategoryExpression.v1"
  });

Output of pulumi about

CLI          
Version      3.108.1
Go Version   go1.22.0
Go Compiler  gc

Plugins
NAME    VERSION
nodejs  unknown

Host     
OS       ubuntu
Version  22.04
Arch     x86_64

This project is written in nodejs: executable='<omitted>' version='v18.18.0'

Current Stack: <omitted>

TYPE                                                  URN
pulumi:providers:aws                                  urn:pulumi:common::infra-aws-billing-costs::pulumi:providers:aws::top-level
aws:costexplorer/costCategory:CostCategory            urn:pulumi:common::infra-aws-billing-costs::aws:costexplorer/costCategory:CostCategory::category-department

Found no pending operations associated with common

Backend        
Name           pulumi.com
URL            <omitted>
User           <omitted>
Organizations  <omitted>
Token type     personal

Pulumi locates its logs in /tmp by default

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

iwahbe commented 6 months ago

Hi @spock-abadai. Thanks for letting us know about this. I think this is a bug upstream. It doesn't look like the interface is designed for an ordering on rules.


The upstream provider (terraform-provider-aws) implements rules as a set, which means order independent:

https://github.com/hashicorp/terraform-provider-aws/blob/c7c1bc3e6d88d3d47979ba38c7a44c56e6763449/internal/service/ce/cost_category.go#L65-L66