fix(infra): secret 読み取り Deny を自アカウントの parameter に絞る - #109
Merged
Conversation
NoSecretValues が Resource "*" だったため、AWS が公開する /aws/service/ami-amazon-linux-latest/* まで巻き込んでいた。account 部が空の ARN なので `*` に含まれ、bastion の AMI 参照 (data.aws_ssm_parameter) が terraform-apply で AccessDenied になる。 これまで踏み台は admin で生やしていたため露見しなかった。人間の経路を CI ロールへ 寄せたことで表に出たもので、CI が bastion を apply する場合も同じ箇所で落ちる。 SSM だけ Resource を arn:aws:ssm:*:<account>:parameter/* に絞る。秘密は全て 自アカウントの parameter にあるので射程は変わらない。secretsmanager と kms は "*" のまま。4 policy で重複していた Deny 文を locals へ括り出す。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
問題
terraform-applyロールで踏み台 (enable_db_bastion=true) を apply すると、AMI 参照で落ちる。NoSecretValuesの Deny がResource: "*"なので、AWS が公開している/aws/service/*まで巻き込んでいた。この ARN はarn:aws:ssm:ap-northeast-1::parameter/aws/service/...で account 部が空だが、*には含まれる。これまで踏み台は
WorkloadAdministratorで生やしていたため露見しなかった。#107 で人間の経路を CI ロールへ寄せたことで表に出た。CI が踏み台を apply する場合も同じ箇所で落ちる。変更内容
SSM の Deny だけ Resource を自アカウント所有の parameter に絞る。
秘密は全て自アカウントの parameter (
/vector/*) にあるので、射程は変わらない。公開パラメータ (AMI ID など) には秘密が無い。あわせて、4 つの policy に重複していた Deny 文を
local.secret_read_statementsへ括り出す。同じ契約・同じ変更理由を持つ重複なので、片方だけ直る状態を作らない。検証
terraform validate/fmt済み。plan は0 to add, 4 to change, 0 to destroyで、4 policy とも Deny 文が 1 つ → 2 つに分かれるだけ。apply 後、踏み台の apply が通ることを実機で確認する。
🤖 Generated with Claude Code