Skip to content

Conversation

@YakDriver
Copy link
Member

@YakDriver YakDriver commented Oct 31, 2025

Rollback Plan

If a change needs to be reverted, we will publish an updated version of the library.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

Description

Adds support for the aws_invoicing_invoice_unit resource to manage AWS Invoice Units for organizational billing.

AWS Invoice Units are a new organizational billing feature that allows enterprises to separate invoicing within a single AWS Organization, eliminating the need for multiple separate Organizations to achieve complex funding requirements. This resource enables Terraform users to programmatically create and manage invoice units, which group specific AWS accounts together for consolidated billing while sending invoices to designated receiver accounts.

Key Features:

  • Create and manage invoice units with designated receiver accounts
  • Configure linked member accounts for consolidated billing
  • Support for tax inheritance settings and descriptive metadata
  • Full Terraform lifecycle support (create, read, update, delete, import)
  • Comprehensive tagging support

Example Usage:

resource "aws_invoicing_invoice_unit" "example" {
  name             = "production-unit"
  invoice_receiver = "123456789012"
  
  rule {
    linked_accounts = ["098765432109", "567890123456"]
  }
  
  tags = {
    Environment = "production"
  }
}

This addresses a significant pain point for large organizations with complex cost allocation needs, as previously they had to maintain entirely separate AWS Organizations just to achieve separate invoicing.

Relations

Closes #40844
Closes #41824
Relates #40900

References

Output from Acceptance Testing

To run the acceptance test, you'll need an AWS Organizations setup with multiple accounts (can be main org and one linked):

Create member accounts (if needed):

# Create linked account  
aws organizations create-account --email "linked-account@example.com" --account-name "Linked Account"

# List accounts to get account IDs
aws organizations list-accounts --query 'Accounts[?Name==`Invoice Receiver Account` || Name==`Linked Account`].[Id,Name]' --output table

Set environment variables:

export INVOICING_INVOICE_RECEIVER_ACCOUNT_ID="123456789012"  # Account ID that will receive invoices (org acct)
export INVOICING_INVOICE_LINKED_ACCOUNT_ID="098765432109"   # Account ID to be linked to the invoice unit

Note: The test will be skipped if either environment variable is not set. Both accounts must be part of your AWS Organization and you must have appropriate billing permissions in the management account.

% make t T=TestAccInvoicingInvoiceUnit_basic K=invoicing
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
make: Running acceptance tests on branch: 🌿 f-aws_invoicing_invoice_unit 🌿...
TF_ACC=1 go1.24.8 test ./internal/service/invoicing/... -v -count 1 -parallel 20 -run='TestAccInvoicingInvoiceUnit_basic'  -timeout 360m -vet=off
2025/10/31 11:49:37 Creating Terraform AWS Provider (SDKv2-style)...
2025/10/31 11:49:37 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN   TestAccInvoicingInvoiceUnit_basic
=== PAUSE TestAccInvoicingInvoiceUnit_basic
=== CONT  TestAccInvoicingInvoiceUnit_basic
--- PASS: TestAccInvoicingInvoiceUnit_basic (13.08s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/invoicing	18.573s

@YakDriver YakDriver requested a review from a team as a code owner October 31, 2025 15:51
@github-actions github-actions bot added documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. tags Pertains to resource tagging. generators Relates to code generators. service/invoicing Issues and PRs that pertain to the invoicing service. labels Oct 31, 2025
@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 size/XL Managed by automation to categorize the size of a PR. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. labels Oct 31, 2025
@YakDriver YakDriver changed the title New resource: aws_invoicing_invoice_unit New resource: aws_invoicing_invoice_unit Oct 31, 2025
@github-actions github-actions bot added the linter Pertains to changes to or issues with the various linters. label Oct 31, 2025
@YakDriver
Copy link
Member Author

Latest after changes:

% make t T=TestAccInvoicingInvoiceUnit_basic K=invoicing                   
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
make: Running acceptance tests on branch: 🌿 f-aws_invoicing_invoice_unit 🌿...
TF_ACC=1 go1.24.8 test ./internal/service/invoicing/... -v -count 1 -parallel 20 -run='TestAccInvoicingInvoiceUnit_basic'  -timeout 360m -vet=off
2025/10/31 17:35:51 Creating Terraform AWS Provider (SDKv2-style)...
2025/10/31 17:35:51 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN   TestAccInvoicingInvoiceUnit_basic
=== PAUSE TestAccInvoicingInvoiceUnit_basic
=== CONT  TestAccInvoicingInvoiceUnit_basic
--- PASS: TestAccInvoicingInvoiceUnit_basic (13.90s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/invoicing	19.366s

Copy link
Contributor

@gdavison gdavison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments


// @FrameworkResource("aws_invoicing_invoice_unit", name="Invoice Unit")
// @Tags(identifierAttribute="arn")
func newInvoiceUnitResource(_ context.Context) (resource.ResourceWithConfigure, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider implementing Resource Identity. Because of the environment variables used in the tests, you'll likely have to create the tests manually by setting the annotation @Testing(identityTest=false)

YakDriver and others added 2 commits November 3, 2025 13:26
Co-authored-by: Graham Davison <gdavison@hashicorp.com>
Co-authored-by: Graham Davison <gdavison@hashicorp.com>
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. generators Relates to code generators. linter Pertains to changes to or issues with the various linters. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. service/invoicing Issues and PRs that pertain to the invoicing service. size/XL Managed by automation to categorize the size of a PR. tags Pertains to resource tagging. 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.

[New Resource]: Configure an AWS Invoice Unit

3 participants