Skip to content

Conversation

@kuredev
Copy link
Contributor

@kuredev kuredev commented Oct 22, 2025

Description

Simple data source to reference cost allocation tags. It allows referencing multiple tags using basic attributes like status and tag key.

Basic Usage

data "aws_ce_cost_allocation_tags" "tags" {}

Filter by Status and Type

data "aws_ce_cost_allocation_tags" "inactive_tags" {
  status = "Inactive"
  type   = "UserDefined"
}

Filter by Tag Keys

data "aws_ce_cost_allocation_tags" "tags" {
  tag_keys = ["tag_a", "tag_b"]
}

tfstate sample

tfstate sample
  "resources": [
    {
      "mode": "data",
      "type": "aws_ce_cost_allocation_tags",
      "name": "hoge",
      "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "status": "Inactive",
            "tag_keys": null,
            "tags": [
              {
                "last_updated_date": null,
                "last_used_date": null,
                "status": "Inactive",
                "tag_key": "Memo",
                "type": "UserDefined"
              },
              {
                "last_updated_date": null,
                "last_used_date": "2024-05-01T00:00:00Z",
                "status": "Inactive",
                "tag_key": "AutoMation",
                "type": "UserDefined"
              }
            ],
            "type": "UserDefined"
          },
          "sensitive_attributes": [],
          "identity_schema_version": 0
        }
      ]
    }
  ],

Relations

Closes #31442

References

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ce_cost_allocation_tag

https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_ListCostAllocationTags.html

Output from Acceptance Testing

$ make testacc PKG=ce TESTS='TestAccCostAllocationTagsDataSource_basic'                                                     
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
make: Running acceptance tests on branch: 🌿 f-ce-data-source 🌿...
TF_ACC=1 go1.24.8 test ./internal/service/ce/... -v -count 1 -parallel 20 -run='TestAccCostAllocationTagsDataSource_basic'  -timeout 360m -vet=off
2025/10/22 18:45:40 Creating Terraform AWS Provider (SDKv2-style)...
2025/10/22 18:45:40 Initializing Terraform AWS Provider (SDKv2-style)...
testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ce 0.133s [no tests to run]

@github-actions
Copy link
Contributor

Community Guidelines

This comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀

Voting for Prioritization

  • Please vote on this Pull Request by adding a 👍 reaction to the original post to help the community and maintainers prioritize it.
  • Please see our prioritization guide for additional information on how the maintainers handle prioritization.
  • Please do not leave +1 or other comments that do not add relevant new information or questions; they generate extra noise for others following the Pull Request and do not help prioritize the request.

Pull Request Authors

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. generators Relates to code generators. service/ce Issues and PRs that pertain to the ce service. size/M Managed by automation to categorize the size of a PR. labels Oct 22, 2025
@kuredev kuredev force-pushed the f-ce-data-source branch 3 times, most recently from aefac59 to 8c0021f Compare October 22, 2025 08:32
@github-actions github-actions bot added documentation Introduces or discusses updates to documentation. size/L Managed by automation to categorize the size of a PR. labels Oct 22, 2025
@kuredev kuredev marked this pull request as ready for review October 22, 2025 11:10
@kuredev kuredev requested a review from a team as a code owner October 22, 2025 11:10
@github-actions
Copy link
Contributor

github-actions bot commented Oct 22, 2025

✅ Thank you for correcting the previously detected issues! The maintainers appreciate your efforts to make the review process as smooth as possible.

@kuredev kuredev marked this pull request as draft October 22, 2025 11:11
@kuredev kuredev marked this pull request as ready for review October 22, 2025 12:17
@justinretzolk justinretzolk added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. generators Relates to code generators. service/ce Issues and PRs that pertain to the ce service. size/L Managed by automation to categorize the size of a PR. size/M Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement]: Simple data source for cost allocation tags

2 participants