Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Kiro Hookを Terraformで検証

Kiro Hookを Terraformで検証

Avatar for ao-inoue

ao-inoue

July 23, 2025
Tweet

Other Decks in Technology

Transcript

  1. 自己紹介 氏名: 井上 碧(いのうえ あおい) 経歴: - 2018-2021: SIer -

    2021-2024: SRE - 2024-現在: SIer 趣味: - 将棋 - ランニング
  2. Kiro • AWSが開発したAI エージェントが備わったIDE • 仕様駆動開発(spec-driven software development)が特徴 • Claude

    Sonnet 4.0搭載* • アイコンが可愛い https://kiro.dev/blog/introducing-kiro/ *2025/7/24時点
  3. .kiroファイルが作られる kiro-sample/ ├── main.tf ├── variables.tf ├── outputs.tf ├── terraform.tfvars.example

    └──.kiro    └── hooks      └── terraform-security-check.kiro.hook # これ
  4. terraform-security-check.kiro.hookの中身 { "name": "Terraform Security Check", "description": ".tfファイル保存時にセキュリティ問題をチェックし、修正案を提示", "trigger": {

    "type": "file_save", "filePattern": "**/*.tf" }, "action": { "type": "agent_execution", "request": "保存された.tfファイルのセキュリティをチェックしてください。以下の項目を確認し、..<省略 >", # コマンドなどは書かれていない "includeFiles": [ "{{triggerFile}}" ] } }
  5. テストコード - セキュリティチェック main.tfにある、ingressの設定を次のように書き換える resource "aws_security_group" "demo" { name_prefix =

    "${var.project_name}-${var.environment}-" description = "Demo security group for Kiro testing" ingress { from_port = 22 to_port = 22 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] # これを検出できるか? } ..<省略>.. }
  6. テストコード - ドキュメント更新 main.tfに以下のコードを追加 # これを検出できるか? resource "aws_db_instance" "main" {

    identifier = "my-database" engine = "mysql" engine_version = "8.0" instance_class = "db.t3.micro" }