AWS Cost Explorerのアクセス制御をする方法

目次
1.はじめに
2.AWS Cost Explorer
3.検証内容
4.検証手順
4-1.IAMユーザーに請求情報を公開
4-2.IAMポリシーの作成
4-3.IAMユーザーの設定
4-4.動作確認
5.まとめ
6.付録
1.はじめに
こんにちは。今回記事を書くTSです。
本記事ではAWS Cost Explorer のアクセス制御をする方法について記載します。
AWS Cost Explorer はBilling and Cost Management (請求情報)の一部で、AWSのサービス利用
コストや使用状況を可視化・分析できるサービスです。
AWSアカウントの利用者が増えるにつれ、細かくユーザーのアクセス制御をする必要があります。
特にお金回り(請求情報)の権限はシビアです。
そのため今回は請求情報の中のAWS Cost Explorer のアクセス制御方法を紹介します。
2.AWS Cost Explorer
AWS Cost Explorer はBilling and Cost Management (請求情報)のサービスの一部です。Billing and Cost Management では支払い設定や請求書の取得などが可能なサービスです。AWS Cost Explorer ではAWS のコストと使用状況を視覚化、管理することが出来ます。カスタムレポートを作成することでコストや使用量を分析することも可能です。
また、マネジメントコンソール にアクセスしたときに表示される「コストと使用状況」もAWS Cost Explorerの情報を表示しています。
デフォルトの設定ではAWS Cost Explorer を含むBilling and Cost Management (請求情報)のすべてのサービスについてAWSアカウント(rootアカウント)からのみ使用することが可能です。
3.検証内容
AWSアカウントを運用する中で、IAMユーザーに利用状況を共有したい場面があるかと思います。
例えば、経理担当の社員が自社のAWS環境の利用料を把握するためや、構築ベンダーに現在の利用
状況を把握してもらいコスト削減を提案いただくことなどが考えられます。
しかし、AWS Cost ExplorerをIAMユーザーが利用可能な状態に設定する際に、Billing and Cost Management (請求情報)全体も利用可能にする必要があります。そのため、IAMユーザーで厳密に
アクセス制御をしない場合は、想定していないユーザーが支払い設定を変更や請求書をダウンロードが可能です。そのようなことが起こらないよう、今回はAWS Cost Explorerのみがアクセス可能になるよう検証したため紹介します。
4.検証手順
4-1.IAMユーザーに請求情報を公開
最初にIAMユーザーからBilling and Cost Management (請求情報)へアクセスできるよう、
設定します。
①AWSアカウントにてログイン後、右上のアカウント名より「アカウント」を選択する。

②「IAM ユーザーおよびロールによる請求情報へのアクセス」の編集で「IAM アクセスをアクティブ化」にチェックを入れて更新をする。

4-2.IAMポリシーの作成
IAMにてアクセス制御をする際はIAMポリシーにてアクセス制御のルールを作成します。
①AWSのマネジメントコンソールにログイン後、IAMのポリシーにて「ポリシーの作成」を
選択する。
②ポリシーエディタのビジュアルまたはJSONにてポリシーを作成する。
※検証時では下記ポリシーを使用
※下記ポリシーはAWS Cost Explorerの閲覧権限のみ付与
※この後の動作確認では下記ポリシーを使用している想定
ポリシーの参考例
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ce:DescribeNotificationSubscription",
"ce:DescribeReport",
"ce:GetCostAndUsage",
"ce:GetCostAndUsageWithResources",
"ce:GetCostCategories",
"ce:GetCostForecast",
"ce:GetDimensionValues",
"ce:GetTags",
"ce:ListTagsForResource"
],
"Resource": "*"
},
{
"Effect": "Deny",
"Action": [
"account:CloseAccount",
"account:DeleteAlternateContact",
"account:GetAccountInformation",
"account:GetAlternateContact",
"account:GetChallengeQuestions",
"account:GetContactInformation",
"account:PutAlternateContact",
"account:PutChallengeQuestions",
"account:PutContactInformation",
"billing:GetBillingData",
"billing:GetBillingDetails",
"billing:GetBillingNotifications",
"billing:GetBillingPreferences",
"billing:GetContractInformation",
"billing:GetCredits",
"billing:GetIAMAccessPreference",
"billing:GetSellerOfRecord",
"billing:ListBillingViews",
"billing:PutContractInformation",
"billing:RedeemCredits",
"billing:UpdateBillingPreferences",
"billing:UpdateIAMAccessPreference",
"ce:CreateAnomalyMonitor",
"ce:CreateAnomalySubscription",
"ce:CreateNotificationSubscription",
"ce:CreateReport",
"ce:DeleteAnomalyMonitor",
"ce:DeleteAnomalySubscription",
"ce:DeleteNotificationSubscription",
"ce:DeleteReport",
"ce:GetAnomalies",
"ce:GetAnomalyMonitors",
"ce:GetAnomalySubscriptions",
"ce:GetPreferences",
"ce:GetReservationCoverage",
"ce:GetReservationPurchaseRecommendation",
"ce:GetReservationUtilization",
"ce:GetRightsizingRecommendation",
"ce:GetSavingsPlansCoverage",
"ce:GetSavingsPlansPurchaseRecommendation",
"ce:GetSavingsPlansUtilization",
"ce:GetSavingsPlansUtilizationDetails",
"ce:GetUsageForecast",
"ce:ListCostAllocationTags",
"ce:ListSavingsPlansPurchaseRecommendationGeneration",
"ce:ProvideAnomalyFeedback",
"ce:StartSavingsPlansPurchaseRecommendationGeneration",
"ce:UpdateAnomalyMonitor",
"ce:UpdateAnomalySubscription",
"ce:UpdateCostAllocationTagsStatus",
"ce:UpdateNotificationSubscription",
"ce:UpdatePreferences",
"ce:UpdateReport",
"ce:UpdateCostCategoryDefinition",
"ce:UntagResource",
"ce:TagResource",
"ce:ListCostCategoryDefinitions",
"ce:DescribeCostCategoryDefinition",
"ce:DeleteCostCategoryDefinition",
"ce:CreateCostCategoryDefinition",
"consolidatedbilling:GetAccountBillingRole",
"consolidatedbilling:ListLinkedAccounts",
"cur:GetClassicReport",
"cur:GetClassicReportPreferences",
"cur:GetUsageReport",
"cur:PutClassicReportPreferences",
"cur:ValidateReportDestination",
"freetier:GetFreeTierAlertPreference",
"freetier:GetFreeTierUsage",
"freetier:PutFreeTierAlertPreference",
"invoicing:GetInvoiceEmailDeliveryPreferences",
"invoicing:GetInvoicePDF",
"invoicing:ListInvoiceSummaries",
"invoicing:PutInvoiceEmailDeliveryPreferences",
"payments:CreatePaymentInstrument",
"payments:DeletePaymentInstrument",
"payments:GetPaymentInstrument",
"payments:GetPaymentStatus",
"payments:ListPaymentPreferences",
"payments:MakePayment",
"payments:UpdatePaymentPreferences",
"purchase-orders:AddPurchaseOrder",
"purchase-orders:DeletePurchaseOrder",
"purchase-orders:GetPurchaseOrder",
"purchase-orders:ListPurchaseOrderInvoices",
"purchase-orders:ListPurchaseOrders",
"purchase-orders:UpdatePurchaseOrder",
"purchase-orders:UpdatePurchaseOrderStatus",
"tax:BatchPutTaxRegistration",
"tax:DeleteTaxRegistration",
"tax:GetTaxInheritance",
"tax:GetTaxRegistrationDocument",
"tax:ListTaxRegistrations",
"tax:PutTaxInheritance"
],
"Resource": [
"*"
]
}
]
}
③ポリシー名を入力し、「ポリシーの作成」をクリックする。
4-3.IAMユーザーの設定
動作確認用のIAMユーザーを作成します。
動作確認用のユーザーのためIAMグループは作らず、IAMポリシーを直接アタッチします。
①AWSのマネジメントコンソールにログイン後、IAMのユーザーにて「ユーザーの作成」を
選択する。
②ユーザー名を入力後、「AWS マネジメントコンソールへのユーザーアクセスを提供する」に
チェックを入れ、「次へ」を選択する。
③許可のオプションにて「ポリシーを直接アタッチする」を選択する。
④先ほど「4.2 IAMポリシーの作成」にて作成したIAMポリシーにチェックを入れて「次へ」を
クリックする。
⑤「ユーザーの作成」をクリックする。
⑥作成したユーザーのパスワードを確認する。
4-4.動作確認
①作成したIAMユーザーでAWSのマネジメントコンソールにログインする。
②コンソールのホームにて「コストと使用状況」にコストが記載されていることを確認する。
右側のグラフでは使用しているリソースの割合が確認可能。

③Billing and Cost Management に移動し、ホームにて各コストが表示されることを確認する。

④Cost Explorer にて各種コストとグラフが表示されること、レポートパラメータが変更可能な
ことを確認する。

⑤支払い設定に移動し、権限不足によりアクセス不可であることを確認する。

5.まとめ
今回の記事ではAWS Cost Explorerのアクセスを制御する方法について紹介しました。
例のポリシーではAWS Cost Explorerの閲覧権限のみ付与しましたが、レポートの作成/修正権限など他にもAWS Cost Explorerについての権限があります。
各用途に応じて必要な権限を付与いただくと想定通りのアクセス制御が実現できると思います。
また、実際に運用する際はIAMグループに作成したポリシーをアタッチし、管理を容易にしたり、
拒否ルールを作成し、絶対にBilling and Cost Management (請求情報)にアクセスできないように
するなどの工夫が必要です。
6.付録
IAMポリシーにてBilling and Cost Management (請求情報)のサービス名は以下となっています。
ce | Cost Explorer関連 |
billing | 請求関連 |
consolidatedbilling | AWS Organizationsの請求関連 |
cur | 使用状況レポート関連 |
invoicing | 請求書設定関連 |
payments | 支払い関連 |
purchase-orders | 発注書関連 |
tax | 税金関連 |
各アクションの名前は下記ドキュメントにて確認することが出来ます。