diff --git a/test/fixtures/budget/outputs.tf b/test/fixtures/budget/outputs.tf index 83fee951..dbf8a8f0 100644 --- a/test/fixtures/budget/outputs.tf +++ b/test/fixtures/budget/outputs.tf @@ -19,6 +19,11 @@ output "project_id" { value = module.budget.project_id } +output "billing_account" { + description = "The billing account where budgets are created" + value = var.billing_account +} + output "parent_project_id" { description = "The project_id of the parent project to add as an additional project for the budget" value = module.budget.parent_project_id diff --git a/test/integration/budget/controls/budget.rb b/test/integration/budget/controls/budget.rb index 4c0403a0..db9cb42f 100644 --- a/test/integration/budget/controls/budget.rb +++ b/test/integration/budget/controls/budget.rb @@ -13,6 +13,7 @@ # limitations under the License. project_id = attribute("project_id") +billing_account = attribute("billing_account") parent_project_id = attribute("parent_project_id") pubsub_topic = attribute("pubsub_topic") main_budget_name = attribute("main_budget_name") @@ -45,8 +46,7 @@ control "project-factory-budget-main" do title "Main Budget" - # Budgets is only available via rest api currently - describe command("curl -s -X GET -H \"Authorization: Bearer \"`gcloud auth print-access-token` https://billingbudgets.googleapis.com/v1beta1/#{main_budget_name}") do + describe command("gcloud alpha billing budgets describe #{main_budget_name} --billing-account=#{billing_account} --format=json") do its("exit_status") { should be 0 } its("stderr") { should eq "" } @@ -60,7 +60,7 @@ it "has expected structure" do expect(metadata).to match(hash_including({ - name: main_budget_name, + name: "billingAccounts/#{billing_account}/budgets/#{main_budget_name}", displayName: "Budget For #{project_id}", budgetFilter: hash_including({creditTypesTreatment: "INCLUDE_ALL_CREDITS"}), amount: hash_including({specifiedAmount: hash_including({units: "#{budget_amount}"})}), @@ -78,8 +78,7 @@ control "project-factory-budget-additional" do title "Additional Budget" - # Budgets is only available via rest api currently - describe command("curl -s -X GET -H \"Authorization: Bearer \"`gcloud auth print-access-token` https://billingbudgets.googleapis.com/v1beta1/#{additional_budget_name}") do + describe command("gcloud alpha billing budgets describe #{additional_budget_name} --billing-account=#{billing_account} --format=json") do its("exit_status") { should be 0 } its("stderr") { should eq "" } @@ -93,7 +92,7 @@ it "has expected structure" do expect(metadata).to match(hash_including({ - name: additional_budget_name, + name: "billingAccounts/#{billing_account}/budgets/#{additional_budget_name}", displayName: "CI/CD Budget for #{project_id}", budgetFilter: hash_including({creditTypesTreatment: budget_credit_types_treatment}), amount: hash_including({specifiedAmount: hash_including({units: "#{budget_amount}"})}), diff --git a/test/integration/budget/inspec.yml b/test/integration/budget/inspec.yml index 0bce1161..eef1e4d0 100644 --- a/test/integration/budget/inspec.yml +++ b/test/integration/budget/inspec.yml @@ -3,6 +3,9 @@ attributes: - name: project_id required: true + - name: billing_account + required: true + - name: parent_project_id required: true