Skip to content

feat: IaC 코드 최신화 & tfstate에 대한 S3 백엔드화 & Github Actrion 워크플로우 생성#25

Open
Hexeong wants to merge 15 commits intomainfrom
feat/24-change-tfstate-global
Open

feat: IaC 코드 최신화 & tfstate에 대한 S3 백엔드화 & Github Actrion 워크플로우 생성#25
Hexeong wants to merge 15 commits intomainfrom
feat/24-change-tfstate-global

Conversation

@Hexeong
Copy link
Copy Markdown
Contributor

@Hexeong Hexeong commented Apr 28, 2026

관련 이슈

작업 내용

1. tfstate S3 Remote Backend 전환 (bootstrap/, environment/*/provider.tf)

각 환경의 tfstate를 로컬 파일 대신 S3 버킷(solid-connection-tfstate)에서 관리하도록 전환했습니다.

  • Terraform 1.10+ S3 네이티브 락 사용 (DynamoDB 불필요)
  • bootstrap/ 환경에 S3 버킷, 버저닝, SSE-S3 암호화, HTTPS 전용 버킷 정책 정의
  • environment/global, prod, stage, monitoring 모두 S3 백엔드로 마이그레이션 완료

2. IAM 정책 정의 (bootstrap/iam.tf)

  • GitHub Actions용 (OIDC): tfstate 전체 접근 + AWS 인프라 관리 권한 부여

3. GitHub Actions 워크플로우 정의 (.github/workflows/)

  • terraform-plan.yml: PR 생성/업데이트 시 변경된 환경에 대해서만 terraform plan 실행 후 결과를 PR 댓글로 게시 (dorny/paths-filter 사용)
  • terraform-apply.yml: main 머지 시 변경된 환경에 대해서만 terraform apply 자동 실행
  • prod 환경: MySQL provider 연결을 위해 SSM Port Forwarding으로 RDS에 터널링 (AWS-StartPortForwardingSessionToRemoteHost)

4. app_stack 모듈 RDS 선택적 활성화 (modules/app_stack/)

stage 환경의 RDS → Docker 컨테이너 전환에 맞춰 enable_rds 변수를 추가했습니다.

  • enable_rds = false이면 RDS, DB Security Group, MySQL 유저/권한 리소스 모두 생성하지 않음
  • MySQL provider를 모듈에서 제거하고 prod 환경 레벨로 이동 (stage에서 MySQL 연결 시도 방지)

5. Lambda 버킷 참조 수정 (modules/shared_resources/lambda.tf)

Lambda 실행 권한 및 S3 트리거가 잘못된 버킷(solid-connection-bucket)을 참조하던 문제를 solid-connection-upload-bucket으로 수정했습니다.

6. CodeRabbit 설정 (.coderabbit.yaml)

Terraform plan 결과를 반영한 코드 리뷰가 이루어지도록 설정했습니다.

  • 자동 리뷰 비활성화 (auto_review: false)
  • 모든 plan 잡 완료 후 @coderabbitai review 트리거 → plan 댓글이 모두 달린 뒤 리뷰 시작
  • .tf 파일 리뷰 시 plan 결과 확인, destroy/replace, IAM 최소 권한 등 중점 검토 지시 추가

특이 사항

  • 로컬 apply 불가: 개발자 IAM Policy는 tfstate PutObject 권한이 없으므로 로컬에서 terraform apply가 불가합니다. apply는 GitHub Actions에서만 실행됩니다. 해당 pr이 반영되는 대로 개발자 IAM 작업은 수동으로 진행하려고 합니다.
  • prod MySQL 터널링 필요: 로컬에서 prod plan 실행 시 SSH 터널로 RDS 3306 포트를 포워딩한 상태에서 실행해야 합니다. CI에서는 SSM Port Forwarding으로 자동
    처리됩니다.
  • bootstrap apply 순서: bootstrap → 나머지 환경 순으로 apply가 선행되어야 합니다. GitHub Actions Role과 S3 버킷이 먼저 존재해야 합니다.
  • submodule 필요: config/secrets/는 private submodule입니다. git submodule update --init --recursive 후 plan을 실행하세요.

리뷰 요구사항 (선택)

Hexeong added 6 commits April 28, 2026 15:27
- app_stack에서 rds 부분에 대한 enable_rds 변수 선언
- 그에 따른 prod/stage에 대한 rds 존재 여부 설정
- pr에 대한 terraform plan 결과 생성
- pr 머지에 대한 terraform apply 잡 생성
- coderabbitai에 대한 자동 코드 리뷰 비활성화 및 terraform plan 이후 코드 리뷰 트리거 발동
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • ✅ Review completed - (🔄 Check again to review again)

Walkthrough

이 PR은 CodeRabbit 설정(.coderabbit.yaml)을 추가하고, Terraform Plan/Apply를 실행하는 GitHub Actions 워크플로(.github/workflows/terraform-plan.yml, .github/workflows/terraform-apply.yml)를 도입합니다. bootstrap에 S3 tfstate 버킷, IAM 역할 및 OIDC 공급자, 출력과 provider 구성이 추가됩니다. 환경별(environment: global, monitoring, prod, stage)로 Terraform required_version 및 S3 백엔드가 설정되며, prod 환경에는 로컬 포트로 RDS 접근을 위한 SSM 포트포워딩이 포함됩니다. 모듈 변경으로 EC2에 iam_instance_profile 입력이 추가되고, RDS 관련 리소스와 변수는 var.enable_rds로 조건부화되거나 제거/이동되었습니다. 일부 MySQL provider 설정은 제거되고 모듈 내 보안 그룹/알림 대상 참조가 조정되었습니다.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • wibaek
  • whqtker
  • JAEHEE25
  • lsy1307
  • sukangpunch
  • Gyuhyeok99
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed PR 설명이 required template 구조를 모두 준수하고 있으며, 관련 이슈, 작업 내용(6개 항목), 특이 사항이 명확하게 기술되어 있습니다.
Title check ✅ Passed PR 제목은 주요 변경 사항들을 정확하게 요약합니다: tfstate S3 백엔드 전환, IAM 정책 추가, GitHub Actions 워크플로우 생성이 모두 포함되어 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/24-change-tfstate-global

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🧹 Nitpick comments (2)
bootstrap/iam.tf (1)

57-77: IAM 리소스에 공통 태그 누락

코딩 가이드라인에 따르면 모든 AWS 리소스에 Project = "solid-connection"Env 태그를 적용해야 합니다. aws_iam_role.github_actionsaws_iam_policy 리소스들에 태그가 누락되었습니다.

🏷️ 태그 추가 예시
 resource "aws_iam_role" "github_actions" {
   name        = "GitHubActionsTerraformRole"
   description = "IAM Role for GitHub Actions terraform plan/apply via OIDC"
+
+  tags = {
+    Project = "solid-connection"
+    Env     = "bootstrap"
+  }

   assume_role_policy = jsonencode({
 resource "aws_iam_policy" "github_actions_infra" {
   name        = "GitHubActionsTerraformInfraPolicy"
   description = "For GitHub Actions terraform apply: AWS infrastructure management"
+
+  tags = {
+    Project = "solid-connection"
+    Env     = "bootstrap"
+  }

   policy = jsonencode({

As per coding guidelines: "Apply common tags to all AWS resources: Project = "solid-connection" and Env = "<environment-name>" for tracking and organization"

Also applies to: 103-146

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bootstrap/iam.tf` around lines 57 - 77, The IAM resources are missing the
required common tags; update aws_iam_role.github_actions to include a tags block
setting Project = "solid-connection" and Env = var.env (or the appropriate
environment variable), and likewise add the same tags block to the
aws_iam_policy resources referenced later (aws_iam_policy resource(s) around
lines 103-146); ensure you merge these tags with any existing tags rather than
overwriting, and use the same tag keys/values consistently across these IAM
resources.
modules/app_stack/variables.tf (1)

49-60: db_username/db_password 기본값을 빈 문자열 대신 null로 변경 권장

빈 문자열 ""은 유효한 값으로 간주될 수 있어 enable_rds = true일 때 실제 자격증명 누락을 탐지하기 어렵습니다. null 기본값을 사용하면 변수 미설정 시 Terraform의 타입 검증이 더 명확해집니다.

♻️ 제안 수정
 variable "db_username" {
   description = "DB 마스터 사용자명"
   type        = string
-  default     = ""
+  default     = null
 }

 variable "db_password" {
   description = "DB 마스터 비밀번호"
   type        = string
   sensitive   = true
-  default     = ""
+  default     = null
 }

또는 enable_rds = true일 때 자격증명 필수 입력을 강제하는 validation 블록 추가를 고려해 주세요.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@modules/app_stack/variables.tf` around lines 49 - 60, Change the
db_username/db_password variable defaults from empty string to null and add
validation that enforces credentials when enable_rds is true: set default = null
for variable "db_username" and "db_password", then add a validation block that
checks when var.enable_rds is true then var.db_username and var.db_password are
not null/empty (e.g., var.enable_rds ? (var.db_username != null &&
length(var.db_username) > 0 && var.db_password != null &&
length(var.db_password) > 0) : true) so missing credentials are caught during
plan/app.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/terraform-apply.yml:
- Around line 118-138: The step that starts the SSM tunnel is too optimistic:
ensure EC2_ID and RDS_HOST are non-empty and fail fast if they are; start the
SSM session (the aws ssm start-session invocation that backgrounded writes
SSM_PID to GITHUB_ENV) and immediately verify the session is still running (use
the saved SSM_PID) and the forwarded socket is reachable by actually testing a
MySQL/TCP handshake against 127.0.0.1:3306 rather than only nc -z, with a
configurable timeout; if the session dies or the port never accepts connections
within the timeout, exit non-zero so the job fails early. Reference symbols to
change: EC2_ID, RDS_HOST, aws ssm start-session (document-name
AWS-StartPortForwardingSessionToRemoteHost), SSM_PID, and the timeout/nc
readiness check.
- Around line 47-50: The pipeline allows
apply-global/apply-prod/apply-stage/apply-monitoring to run before
apply-bootstrap finishes when both bootstrap/** and env dirs change; update each
of those jobs (symbols: apply-global, apply-prod, apply-stage, apply-monitoring)
to declare needs: [detect-changes, apply-bootstrap] and keep their existing if
conditions (e.g., needs.detect-changes.outputs.<env> == 'true') so they will
wait for apply-bootstrap to complete when bootstrap changes; apply the same
change to all repeated job blocks referenced in the comment.

In @.github/workflows/terraform-plan.yml:
- Around line 74-86: The workflow currently reads the full
bootstrap/plan_output.txt and posts it directly via the "Post Plan Comment" step
using github.rest.issues.createComment (variable truncated), which can leak
secrets; change this to never post raw plan text: instead either (A) upload the
full plan as a workflow artifact and post only a short safe summary, or (B) run
a redaction pass over the plan content (detect common sensitive keys like
"password", "secret", "token", "private_key", "aws_secret_access_key",
provider-specific sensitive markers) and replace values with "[REDACTED]" before
assigning to truncated and calling github.rest.issues.createComment; ensure
bootstrap/plan_output.txt is written with terraform plan -out and terraform show
-json if using structured redaction, and update the script referencing truncated
and github.rest.issues.createComment to use the sanitized summary or artifact
link instead of the raw plan.
- Around line 157-177: 현재 단계는 로컬 포트(127.0.0.1:3306)만 확인하고 SSM 세션의 실제 생존이나 조회
결과(RDS_HOST, EC2_ID)가 유효한지 검사하지 않으므로 세션이 바로 종료되거나 조회가 빈값일 때 이후 terraform plan에서
실패할 수 있습니다; 수정 방법은 start-session을 실행하기 전에 EC2_ID와 RDS_HOST 값이 비어있지 않은지 검사하고(참조:
EC2_ID, RDS_HOST), aws ssm start-session 호출의 성공 여부와 반환된 세션/프로세스 상태(참조: SSM_PID 및
AWS-StartPortForwardingSessionToRemoteHost)를 확인하여 백그라운드 프로세스가 즉시 종료되지 않았는지 검사하고,
로컬 포트 체크 외에 aws ssm describe-sessions 또는 해당 PID가 살아있는지로 세션 지속성을 검증한 뒤 실패 시 워크플로를
중단하도록 변경하세요.

In `@bootstrap/iam.tf`:
- Around line 102-146: The aws_iam_policy resource github_actions_infra
currently grants overly broad privileges (wildcard Actions like "s3:*", "ec2:*",
"rds:*", combined with Resource = "*"); update the policy in the
github_actions_infra resource to follow least-privilege: replace wildcard
Actions with only the specific API calls required by your GitHub Actions
terraform workflows, restrict Resource values to exact ARNs (or scoped prefixes)
instead of "*", and split high-risk permissions (e.g., IAM, KMS, SSM) into
separate narrowly-scoped statements; if full wildcard access is intentional, add
a clear comment/ADR referencing the risk acceptance and justification.
- Around line 51-55: The aws_iam_openid_connect_provider resource
(aws_iam_openid_connect_provider.github) currently hardcodes a single thumbprint
in thumbprint_list which is brittle for certificate rotation; update the
thumbprint_list to include both known GitHub OIDC thumbprints so AWS has a
fallback during rotation (e.g., add the second thumbprint alongside
"6938fd4d..."), ensuring the list is non-empty and contains the additional
thumbprint "1c58a3a8..."; modify only the thumbprint_list attribute on the
aws_iam_openid_connect_provider.github resource to include both values.

In `@bootstrap/provider.tf`:
- Around line 23-27: 현재 provider.tf의 default_tags 블록(tags = { Project =
"solid-connection" })에 Env 태그가 누락되어 있으므로 default_tags.tags에 Env 키를 추가하고 값은 환경별
변수로 설정하세요 (예: use var.env); 만약 변수 env가 정의되어 있지 않다면 variable "env" (type =
string, 설명 포함) 를 추가하고 필요한 tfvars/워크스페이스 값으로 전달하도록 수정하세요; 변경 대상 식별자:
default_tags, tags, 변수명 env.

In `@bootstrap/s3.tf`:
- Around line 1-7: The S3 tfstate resource aws_s3_bucket.tfstate is missing the
required common tags; add a tags block to that resource with Project =
"solid-connection" and Env set from the environment variable used elsewhere
(e.g., var.env or local.env) so it follows the tagging convention; update the
resource aws_s3_bucket.tfstate to include tags { Project = "solid-connection"
Env = <existing env variable> } ensuring you reuse the same variable name used
across other resources.

---

Nitpick comments:
In `@bootstrap/iam.tf`:
- Around line 57-77: The IAM resources are missing the required common tags;
update aws_iam_role.github_actions to include a tags block setting Project =
"solid-connection" and Env = var.env (or the appropriate environment variable),
and likewise add the same tags block to the aws_iam_policy resources referenced
later (aws_iam_policy resource(s) around lines 103-146); ensure you merge these
tags with any existing tags rather than overwriting, and use the same tag
keys/values consistently across these IAM resources.

In `@modules/app_stack/variables.tf`:
- Around line 49-60: Change the db_username/db_password variable defaults from
empty string to null and add validation that enforces credentials when
enable_rds is true: set default = null for variable "db_username" and
"db_password", then add a validation block that checks when var.enable_rds is
true then var.db_username and var.db_password are not null/empty (e.g.,
var.enable_rds ? (var.db_username != null && length(var.db_username) > 0 &&
var.db_password != null && length(var.db_password) > 0) : true) so missing
credentials are caught during plan/app.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ea51b116-161b-4b7e-a4c9-f6a9ea85ed45

📥 Commits

Reviewing files that changed from the base of the PR and between 0b8da36 and bac30ef.

📒 Files selected for processing (22)
  • .coderabbit.yaml
  • .github/workflows/terraform-apply.yml
  • .github/workflows/terraform-plan.yml
  • bootstrap/iam.tf
  • bootstrap/outputs.tf
  • bootstrap/provider.tf
  • bootstrap/s3.tf
  • config/secrets
  • environment/global/provider.tf
  • environment/monitoring/provider.tf
  • environment/prod/main.tf
  • environment/prod/provider.tf
  • environment/prod/variables.tf
  • environment/stage/main.tf
  • environment/stage/provider.tf
  • environment/stage/variables.tf
  • modules/app_stack/ec2.tf
  • modules/app_stack/provider.tf
  • modules/app_stack/rds.tf
  • modules/app_stack/security_groups.tf
  • modules/app_stack/variables.tf
  • modules/shared_resources/lambda.tf
💤 Files with no reviewable changes (1)
  • modules/app_stack/provider.tf

Comment thread .github/workflows/terraform-apply.yml
Comment thread .github/workflows/terraform-apply.yml Outdated
Comment thread .github/workflows/terraform-plan.yml
Comment thread .github/workflows/terraform-plan.yml Outdated
Comment thread bootstrap/iam.tf
Comment thread bootstrap/iam.tf Outdated
Comment thread bootstrap/provider.tf
Comment thread bootstrap/s3.tf
Hexeong added 2 commits April 28, 2026 23:38
- stage 환경의 ingress rule에 대한 tfstate 최신화
- monitoring 환경에 대한 서브모듈 참조 부분 수정
- bootstrap 환경에서의 iam 정책 설정 부분 제거 및 해당 부분에 대한 수동 관리 적용
- 기존 terraform-plan 워크플로우가 새로운 커밋이 추가되었을 때 기존 댓글을 덮어씌우는 방식으로 변경
- 방어적 코딩으로 aws oidc에 대한 thumbprint 추가
- terraform plan 워크플로우의 결과 전문이 pr 댓글로 보이지 않도록 변경
- terraform apply 워크플로우에 대한 bootstrap 의존성 순서 선언
- SSM 터널링에 대한 에러 케이스 핸들링 로직 추가
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 28, 2026

Terraform Plan: monitoring

No changes. Your infrastructure matches the configuration.

전체 plan 결과는 보안을 위해 댓글에 포함되지 않습니다. 워크플로우 실행 아티팩트를 확인하세요.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 28, 2026

Terraform Plan: stage

No changes. Your infrastructure matches the configuration.

전체 plan 결과는 보안을 위해 댓글에 포함되지 않습니다. 워크플로우 실행 아티팩트를 확인하세요.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 28, 2026

Terraform Plan: global

No changes. Your infrastructure matches the configuration.

전체 plan 결과는 보안을 위해 댓글에 포함되지 않습니다. 워크플로우 실행 아티팩트를 확인하세요.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 28, 2026

Terraform Plan: bootstrap

No changes. Your infrastructure matches the configuration.

전체 plan 결과는 보안을 위해 댓글에 포함되지 않습니다. 워크플로우 실행 아티팩트를 확인하세요.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@solid-connection solid-connection deleted a comment from github-actions Bot Apr 28, 2026
@solid-connection solid-connection deleted a comment from github-actions Bot Apr 28, 2026
@solid-connection solid-connection deleted a comment from github-actions Bot Apr 28, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@solid-connection solid-connection deleted a comment from github-actions Bot Apr 28, 2026
@solid-connection solid-connection deleted a comment from github-actions Bot Apr 28, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@bootstrap/iam.tf`:
- Around line 34-37: Both aws_iam_openid_connect_provider.github and
aws_iam_role.github_actions are missing common tags; add a tags block to each
resource including Project = "solid-connection" and Env = "bootstrap" (e.g., add
a tags map on aws_iam_openid_connect_provider.github and on
aws_iam_role.github_actions so both resources include those two key/value
pairs).
- Around line 48-50: The OIDC subject condition in the StringLike map (key
"token.actions.githubusercontent.com:sub") is too broad—replace the wildcard
value "repo:solid-connection/solid-connection-infra:*" with explicit, minimal
patterns for the intended workflows (e.g., restrict to branch deploys and PRs).
Update the StringLike entries used in the IAM role/trust policy (look for the
StringLike block and the "token.actions.githubusercontent.com:sub" key) to
include only the specific subjects you need such as
"repo:solid-connection/solid-connection-infra:ref:refs/heads/main" for
main-branch actions and
"repo:solid-connection/solid-connection-infra:pull_request" for PR workflows,
removing the wildcard to enforce least privilege.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 954fd180-2e70-433f-b0ab-bd9c21a7916e

📥 Commits

Reviewing files that changed from the base of the PR and between bac30ef and d62a9ea.

📒 Files selected for processing (6)
  • .github/workflows/terraform-apply.yml
  • .github/workflows/terraform-plan.yml
  • bootstrap/iam.tf
  • bootstrap/outputs.tf
  • bootstrap/provider.tf
  • modules/app_stack/security_groups.tf
🚧 Files skipped from review as they are similar to previous changes (5)
  • bootstrap/provider.tf
  • modules/app_stack/security_groups.tf
  • bootstrap/outputs.tf
  • .github/workflows/terraform-plan.yml
  • .github/workflows/terraform-apply.yml

Comment thread bootstrap/iam.tf
Comment thread bootstrap/iam.tf
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
.github/workflows/terraform-plan.yml (1)

414-427: CodeRabbit 트리거 댓글이 계속 누적됩니다.

여기는 매 실행마다 새 댓글을 만들어서 PR이 길어질수록 노이즈가 쌓입니다. plan 댓글처럼 marker를 두고 update하거나, detect-changes 결과가 전부 false면 아예 생략하는 쪽이 관리하기 좋습니다.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/terraform-plan.yml around lines 414 - 427, The
trigger-coderabbit step currently creates a new PR comment every run via
actions/github-script@v7 and github.rest.issues.createComment, causing duplicate
noise; change it to (a) detect whether you should post at all (skip when your
detect-changes job returns all false) and (b) if posting, search for an existing
marker comment (e.g., look for a comment body containing the unique marker
string "@coderabbitai review" or a marker token) using
github.rest.issues.listComments and then update that comment with
github.rest.issues.updateComment (or create a new one only if none found);
update the step that references github.rest.issues.createComment and the job
trigger-coderabbit logic to implement these checks and update-vs-create
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/terraform-apply.yml:
- Around line 156-169: The SSM tunnel wait loop uses a hardcoded 30-second retry
(for i in $(seq 1 30)) and an immediate failure if nc still can't connect, which
makes runs flaky; change this to read a timeout/retry count from an environment
variable (e.g., SSM_TUNNEL_TIMEOUT or SSM_TUNNEL_RETRIES) and use that variable
in the seq loop and the final nc check so both plan and apply can share the same
value; ensure references to SSM_PID, the nc -z 127.0.0.1 3306 checks, and the
sleep 1 remain unchanged except for replacing the hardcoded 30 with the
env-backed variable and add a sensible default when the env var is not set.

In @.github/workflows/terraform-plan.yml:
- Around line 57-60: The workflow uses a full-privilege role via
aws-actions/configure-aws-credentials@v4 with role-to-assume: ${{
secrets.AWS_ROLE_ARN }} for all plan jobs (plan-bootstrap, plan-global,
plan-prod, plan-stage, plan-monitoring); change each plan job to assume a
dedicated read-only/lock-only plan role (e.g. a new secret like ${{
secrets.AWS_TERRAFORM_PLAN_ROLE_ARN }}) that only grants read access to state
and PutObject/DeleteObject for the .tflock object(s) (no infrastructure write
permissions), and update the aws-actions/configure-aws-credentials usage in
those job definitions to reference that new plan-only role secret so
pull_request plan runs cannot modify real infra.
- Around line 53-56: The checkout step uses actions/checkout@v4 which defaults
to persist-credentials: true leaving GH_PAT in git config; for each workflow job
that checks out code (e.g., the jobs named plan-bootstrap, plan-global,
plan-prod, plan-stage, plan-monitoring) update the checkout step to explicitly
set persist-credentials: false after submodule checkout so credentials are not
persisted into later steps; locate every occurrence of the actions/checkout@v4
block and add the persist-credentials: false setting in the with: section
alongside submodules/token entries.

---

Nitpick comments:
In @.github/workflows/terraform-plan.yml:
- Around line 414-427: The trigger-coderabbit step currently creates a new PR
comment every run via actions/github-script@v7 and
github.rest.issues.createComment, causing duplicate noise; change it to (a)
detect whether you should post at all (skip when your detect-changes job returns
all false) and (b) if posting, search for an existing marker comment (e.g., look
for a comment body containing the unique marker string "@coderabbitai review" or
a marker token) using github.rest.issues.listComments and then update that
comment with github.rest.issues.updateComment (or create a new one only if none
found); update the step that references github.rest.issues.createComment and the
job trigger-coderabbit logic to implement these checks and update-vs-create
behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9ceeb13e-301c-4d16-9e99-c0d7e1b18836

📥 Commits

Reviewing files that changed from the base of the PR and between d62a9ea and b9e3fd9.

📒 Files selected for processing (3)
  • .github/workflows/terraform-apply.yml
  • .github/workflows/terraform-plan.yml
  • bootstrap/iam.tf
🚧 Files skipped from review as they are similar to previous changes (1)
  • bootstrap/iam.tf

Comment thread .github/workflows/terraform-apply.yml Outdated
Comment thread .github/workflows/terraform-plan.yml
Comment thread .github/workflows/terraform-plan.yml
@github-actions
Copy link
Copy Markdown

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions
Copy link
Copy Markdown

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 28, 2026

Terraform Plan: prod

No changes. Your infrastructure matches the configuration.

전체 plan 결과는 보안을 위해 댓글에 포함되지 않습니다. 워크플로우 실행 아티팩트를 확인하세요.

@github-actions
Copy link
Copy Markdown

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
.github/workflows/terraform-plan.yml (1)

48-418: plan 잡 구성이 너무 많이 복제돼 있습니다.

checkout / AWS 인증 / Terraform setup / artifact / PR comment 패턴이 5번 반복돼서, 방금 같은 예외 처리 수정도 한 곳 빠뜨리기 쉽습니다. matrix + 공통 스텝(또는 reusable workflow)로 묶어두면 이후 drift를 많이 줄일 수 있습니다.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/terraform-plan.yml around lines 48 - 418, The plan jobs
(plan-bootstrap, plan-global, plan-prod, plan-stage, plan-monitoring) duplicate
common steps (checkout, aws-actions/configure-aws-credentials,
hashicorp/setup-terraform, Terraform Init/Plan pattern, Upload Plan Artifact,
Post Plan Comment) and should be consolidated: extract the repeated sequence
into a single reusable workflow or a matrix-driven job that accepts parameters
(working-directory, marker, artifact name, var-files, extra pre/post steps),
move the Plan step logic (id: plan) and comment logic (Post Plan Comment using
marker) into that shared workflow, and call it with per-environment params; keep
prod-specific SSM Tunnel/Install Session Manager Plugin steps as an optional
pre-step parameter or separate step that runs only for the prod invocation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/terraform-plan.yml:
- Around line 420-433: The trigger-coderabbit step is posting the same
'@coderabbitai review' comment every run because it uses if: always() plus
github.rest.issues.createComment without deduplication; modify the step to
either (a) check for and update an existing comment instead of always creating a
new one by using github.rest.issues.listComments to find a comment with body
containing '@coderabbitai review' and then call github.rest.issues.updateComment
if found or createComment if not, referencing the
github.rest.issues.createComment and
github.rest.issues.updateComment/listComments APIs, or (b) tighten the condition
from if: always() to only run when the plan job actually ran/succeeded (remove
always() and use a needs-based condition) so the comment is only posted for real
plan executions.
- Around line 80-88: The Post Plan Comment step currently calls
fs.readFileSync('plan_output.txt') unguarded which throws if the file doesn't
exist; wrap the read in a safe check/try-catch (or use fs.existsSync) and set a
sensible default like '(plan output missing)' so the script still posts a
helpful comment instead of crashing. Specifically, update the Post Plan Comment
action's script around the marker, output and summary variables: replace the
direct fs.readFileSync call with guarded logic that catches errors and assigns a
fallback output string, then continue computing summary from that fallback;
apply the same fix to the other identical script blocks mentioned (the other
Post Plan Comment occurrences).

---

Nitpick comments:
In @.github/workflows/terraform-plan.yml:
- Around line 48-418: The plan jobs (plan-bootstrap, plan-global, plan-prod,
plan-stage, plan-monitoring) duplicate common steps (checkout,
aws-actions/configure-aws-credentials, hashicorp/setup-terraform, Terraform
Init/Plan pattern, Upload Plan Artifact, Post Plan Comment) and should be
consolidated: extract the repeated sequence into a single reusable workflow or a
matrix-driven job that accepts parameters (working-directory, marker, artifact
name, var-files, extra pre/post steps), move the Plan step logic (id: plan) and
comment logic (Post Plan Comment using marker) into that shared workflow, and
call it with per-environment params; keep prod-specific SSM Tunnel/Install
Session Manager Plugin steps as an optional pre-step parameter or separate step
that runs only for the prod invocation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: aef5f5b1-0fd1-41d1-a97c-52563dd6ed01

📥 Commits

Reviewing files that changed from the base of the PR and between b9e3fd9 and 5ec981d.

📒 Files selected for processing (2)
  • .github/workflows/terraform-apply.yml
  • .github/workflows/terraform-plan.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/terraform-apply.yml

Comment thread .github/workflows/terraform-plan.yml Outdated
Comment thread .github/workflows/terraform-plan.yml
@github-actions
Copy link
Copy Markdown

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
.github/workflows/terraform-apply.yml (1)

230-259: 파일 끝에 개행 문자가 없습니다.

POSIX 표준에 따라 파일은 개행 문자로 끝나야 합니다.

🔧 수정 제안
           terraform apply -auto-approve \
             -var-file="../../config/secrets/monitoring.tfvars" \
             -var-file="../../config/secrets/monitoring_stack.tfvars"
+
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/terraform-apply.yml around lines 230 - 259, The workflow
file ends without a trailing newline (POSIX requires a final newline); open the
workflow that contains the apply-monitoring job (look for the "apply-monitoring"
job and the "Terraform Apply" step) and add a single newline character at the
end of the file so the final line is terminated, then save and commit the
change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.github/workflows/terraform-apply.yml:
- Around line 230-259: The workflow file ends without a trailing newline (POSIX
requires a final newline); open the workflow that contains the apply-monitoring
job (look for the "apply-monitoring" job and the "Terraform Apply" step) and add
a single newline character at the end of the file so the final line is
terminated, then save and commit the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 179d305a-b2b4-4dc7-bdbf-c3363ca19a14

📥 Commits

Reviewing files that changed from the base of the PR and between 5ec981d and 1e636ab.

📒 Files selected for processing (2)
  • .github/workflows/terraform-apply.yml
  • .github/workflows/terraform-plan.yml
✅ Files skipped from review due to trivial changes (1)
  • .github/workflows/terraform-plan.yml

@github-actions
Copy link
Copy Markdown

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@solid-connection solid-connection deleted a comment from github-actions Bot Apr 28, 2026
@solid-connection solid-connection deleted a comment from github-actions Bot Apr 28, 2026
@solid-connection solid-connection deleted a comment from github-actions Bot Apr 28, 2026
@solid-connection solid-connection deleted a comment from github-actions Bot Apr 28, 2026
@Hexeong Hexeong changed the title feat: SolidConnection IaC 코드 최신화 & tfstate에 대한 S3 백엔드화 & Github Actrion 워크플로우 생성 feat: IaC 코드 최신화 & tfstate에 대한 S3 백엔드화 & Github Actrion 워크플로우 생성 Apr 28, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
.github/workflows/terraform-plan.yml (1)

54-57: plan-bootstrap에서 persist-credentials: false 설정이 누락되었습니다.

다른 모든 plan 작업(global, prod, stage, monitoring)에는 persist-credentials: false가 설정되어 있으나, plan-bootstrap만 누락되어 일관성이 없습니다. 이전 리뷰에서 논의된 대로, checkout 후 GH_PAT이 git config에 남지 않도록 명시적으로 제거하는 것이 보안상 권장됩니다.

♻️ 수정 제안
       - uses: actions/checkout@v4
         with:
           submodules: recursive
           token: ${{ secrets.GH_PAT }}
+          persist-credentials: false
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/terraform-plan.yml around lines 54 - 57, The
plan-bootstrap job is missing the persist-credentials: false option on the
actions/checkout@v4 step; update the checkout step in the plan-bootstrap job
(the uses: actions/checkout@v4 block) to include with: persist-credentials:
false (matching the other plan jobs) so the GH_PAT is not left in git config
after checkout.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.github/workflows/terraform-plan.yml:
- Around line 54-57: The plan-bootstrap job is missing the persist-credentials:
false option on the actions/checkout@v4 step; update the checkout step in the
plan-bootstrap job (the uses: actions/checkout@v4 block) to include with:
persist-credentials: false (matching the other plan jobs) so the GH_PAT is not
left in git config after checkout.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5c6fbcc7-bb87-4119-a02f-584ddea86c66

📥 Commits

Reviewing files that changed from the base of the PR and between 5ec981d and 7f078d0.

📒 Files selected for processing (2)
  • .github/workflows/terraform-apply.yml
  • .github/workflows/terraform-plan.yml
✅ Files skipped from review due to trivial changes (1)
  • .github/workflows/terraform-apply.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant