Skip to content

fix(infra): 公開 SSM parameter の読み取りを terraform-apply に許可する - #110

Merged
yook11 merged 1 commit into
mainfrom
fix/allow-public-ssm-parameter
Aug 4, 2026
Merged

fix(infra): 公開 SSM parameter の読み取りを terraform-apply に許可する#110
yook11 merged 1 commit into
mainfrom
fix/allow-public-ssm-parameter

Conversation

@yook11

@yook11 yook11 commented Aug 4, 2026

Copy link
Copy Markdown
Owner

問題

#109 で Deny を自アカウントの parameter に絞ったが、それだけでは踏み台の apply が通らない。

Error: reading SSM Parameter (/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-arm64):
AccessDeniedException: ... is not authorized to perform: ssm:GetParameter
because no identity-based policy allows the ssm:GetParameter action

  with data.aws_ssm_parameter.bastion_ami[0], on bastion.tf line 173

terraform-apply が持つ SSM の Allow は RegionalInfrassm:DescribeParameters だけで、GetParameter の Allow がどこにも無い。#109 で explicit deny は消えたが、今度は Allow の欠落で落ちる。

変更内容

AWS が公開する /aws/service/* に限って ssm:GetParameter / GetParameters を許可する。

Resource = "arn:aws:ssm:ap-northeast-1::parameter/aws/service/*"
                                       ↑ account 部が空 = AWS 公開分のみ

この ARN は #109 で入れた Deny (arn:aws:ssm:*:<account>:parameter/*) と重ならないため、自アカウントの /vector/* は引き続き読めない。この namespace に居るのは AMI ID などの公開値だけで、秘密は含まれない。

経緯

この commit は #109 の merge 直後に同じブランチへ push してしまい、PR に取り込まれなかった。内容は #109 のレビュー時に想定していたものと同じで、main へ入れ直すための PR。

検証

terraform validate / fmt 済み。plan は 0 to add, 1 to change, 0 to destroy で、apply policy に Allow 文が 1 つ増えるだけ。

apply 後、踏み台の apply が通ることを実機で確認する。

🤖 Generated with Claude Code

Deny を絞っただけでは apply が通らなかった。RegionalInfra が持つのは
ssm:DescribeParameters だけで、GetParameter の Allow がどこにも無いため
bastion の AMI 参照が「no identity-based policy allows」で落ちる。

読めるのは AWS 公開の /aws/service/* に限る。この ARN は account 部が空で、
自アカウントの parameter を落とす Deny とは重ならない。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@yook11
yook11 merged commit dc94f0c into main Aug 4, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant