説明
CloudWatch Logs の送信先にサブスクリプションフィルターを関連付けられるアカウントを確認します。ポリシーのプリンシパル、許可する操作、適用条件を併せて確認してください。
想定される影響
未承認の送信元がサブスクリプションを設定できると、不要なログが流入し、処理費用が増える可能性があります。
対処方法
許可する範囲を承認済みの送信元アカウントか組織に絞り、対象の送信先 ARN に対する logs:PutSubscriptionFilter のみを許可します。ポリシーを送信先に関連付け、承認した送信元のサブスクリプションからログが届くことを確認してください。保存済みログの読み取り権限は別途管理します。
例
最初の例は現在のアカウントに logs:* を許可しています。2 つ目は送信元と操作を明示します。123456789012 は実際の送信元アカウント ID に置き換えてください。
変更前
hcl
data "aws_iam_policy_document" "example" {
statement {
effect = "Allow"
principals {
type = "AWS"
identifiers = [data.aws_caller_identity.current.id]
}
actions = [
"logs:*",
]
resources = [
aws_cloudwatch_log_destination.test_destination.arn,
]
}
}
変更後
hcl
data "aws_iam_policy_document" "example" {
statement {
effect = "Allow"
principals {
type = "AWS"
identifiers = [
"123456789012",
]
}
actions = [
"logs:PutSubscriptionFilter",
]
resources = [
aws_cloudwatch_log_destination.test_destination.arn,
]
}
}