困ったこと
AWS Organizationsのメンバーアカウントで予算設定をしようとしたところ、先にpayer account(AWS Organizationsの管理アカウント)側でbudgetsを有効化するようにというメッセージが出てエラーになりました。
BUDGET_CONFIG_JSON=' { "BudgetName": "Example Budget", "BudgetType": "COST", "BudgetLimit": { "Amount": "100", "Unit": "USD" }, "TimeUnit": "MONTHLY" }' aws budgets create-budget \ --account-id 999999999999 \ --budget "${BUDGET_CONFIG_JSON}"
発生したエラー内容
An error occurred (AccessDeniedException) when calling the CreateBudget operation: Account 999999999999 is a linked account. To enable budgets for your account, ask the payer account to enable budgets first.
解決方法
エラーメッセージには、ask the payer account to enable budgets first.
とありましたが、実機で確認したところ正確には管理アカウントでAWS Cost Explorerを有効化
する必要がありました。
管理アカウントのAWS Cost Explorerの有効化方法
AWS Organizationsの管理アカウントにアクセスします。
AWS Cost Explorerは、マネコンでAWS Cost Explorerを起動することで有効化されます。CLI(API)によるAWS Cost Explorer有効化はできません。*1
メンバーアカウントでのBudget作成
- Budgetを作成したメンバーアカウントにアクセスできるようにします(マネコン/CLIどちらでも可)
- Budgetを作成する
BUDGET_CONFIG_JSON=' { "BudgetName": "Example Budget", "BudgetType": "COST", "BudgetLimit": { "Amount": "100", "Unit": "USD" }, "TimeUnit": "MONTHLY" }' aws budgets create-budget \ --account-id 999999999999 \ --budget "${BUDGET_CONFIG_JSON}"
- 作成したBudgetを確認する
aws budgets describe-budgets --account-id 999999999999 { "Budgets": [ { "BudgetName": "Example Budget", "BudgetLimit": { "Amount": "100.0", "Unit": "USD" }, "CostTypes": { "IncludeTax": true, "IncludeSubscription": true, "UseBlended": false, "IncludeRefund": true, "IncludeCredit": true, "IncludeUpfront": true, "IncludeRecurring": true, "IncludeOtherSubscription": true, "IncludeSupport": true, "IncludeDiscount": true, "UseAmortized": false }, "TimeUnit": "MONTHLY", "TimePeriod": { "Start": "2021-09-01T09:00:00+09:00", "End": "2087-06-15T09:00:00+09:00" }, "CalculatedSpend": { "ActualSpend": { "Amount": "0.048", "Unit": "USD" } }, "BudgetType": "COST", "LastUpdatedTime": "2021-09-05T15:37:34.817000+09:00" } ] }