Skip to content
infra-workflow logo

インフラワークフロー

infra-workflow

Terraform/Docker Composeによるインフラ構築のワークフロー、ベストプラクティス、Well-Architected Framework対応を定義

SKILL.md

Full skill instructions

インフラワークフロー

本ドキュメントは、Terraform/​Docker Composeによるインフラ構築のワークフローを定義します。


1. インフラワークフロー概要

flowchart TB
    subgraph INFRA["インフラワークフロー"]
        direction TB
        
        %% インフラ設計
        subgraph DESIGN["インフラ設計フェーズ"]
            D1["インフラ要件確認"]
            D2["インフラ設計書作成<br/>@infra-reviewer"]
            D3{"設計レビュー<br/>9点以上"}
            
            D1 --> D2 --> D3
            D3 -->|"不合格"| D2
        end
        
        %% Terraform
        subgraph TF["Terraform実装フェーズ"]
            TF1["Terraformコード実装"]
            TF2["terraform plan"]
            TF3{"Plan成功?"}
            TF4["セキュリティチェック<br/>@security-reviewer"]
            TF5{"レビュー<br/>9点以上"}
            
            TF1 --> TF2 --> TF3
            TF3 -->|"失敗"| TF1
            TF3 -->|"成功"| TF4 --> TF5
            TF5 -->|"不合格"| TF1
        end
        
        %% Docker Compose
        subgraph DC["Docker Compose実装フェーズ"]
            DC1["Docker Compose作成"]
            DC2["docker-compose up"]
            DC3{"起動成功?"}
            DC4{"レビュー<br/>9点以上"}
            
            DC1 --> DC2 --> DC3
            DC3 -->|"失敗"| DC1
            DC3 -->|"成功"| DC4
            DC4 -->|"不合格"| DC1
        end
        
        %% フロー接続
        D3 -->|"合格"| TF
        D3 -->|"合格"| DC
        TF5 -->|"合格"| TF_OUT[["terraform apply<br/>待機"]]
        DC4 -->|"合格"| DC_OUT[["ローカル環境<br/>準備完了"]]
    end

2. Terraformワークフロー

2.1 フェーズ

#フェーズ内容完了条件
1要件確認インフラ要件の確認要件が明確
2設計インフラ設計書作成レビュー9点以上
3実装Terraformコード実装terraform plan 成功
4セキュリティレビューセキュリティチェックレビュー9点以上
5適用terraform apply(手動)人間の承認後

2.2 Terraform ベストプラクティス

ディレクトリ構成
infrastructure/
├── terraform/
│   ├── environments/
│   │   ├── dev/
│   │   │   ├── main.tf
│   │   │   ├── variables.tf
│   │   │   ├── outputs.tf
│   │   │   └── terraform.tfvars
│   │   ├── staging/
│   │   └── production/
│   │
│   └── modules/
│       ├── networking/
│       │   ├── main.tf
│       │   ├── variables.tf
│       │   └── outputs.tf
│       ├── compute/
│       ├── database/
│       └── security/
│
└── docs/
    └── インフラ設計書.md
命名規則
リソース命名規則例
リソース名{project}-{env}-{resource}myapp-prod-vpc
モジュール名機能を表す単語networking, compute
変数名snake_caseinstance_type
必須設定
# provider バージョン固定
terraform {
  required_version = ">= 1.0.0"
  
  required_providers {
    aws = {
      source  = "hashicorp/​aws"
      version = "~> 5.0"
    }
  }
}

# 全変数にdescription必須
variable "instance_type" {
  type        = string
  description = "EC2インスタンスタイプ"
  default     = "t3.micro"
}

# 重要なoutputにはdescription必須
output "vpc_id" {
  description = "作成されたVPCのID"
  value       = aws_vpc.main.id
}

2.3 セキュリティチェック項目

カテゴリチェック項目
ネットワークセキュリティグループが最小権限か
IAMIAMポリシーが最小権限か
暗号化RDS、S3、EBSが暗号化されているか
ログCloudTrail、VPCフローログが有効か
公開設定S3バケットがパブリックでないか
シークレットSecrets Managerが使用されているか

3. Docker Composeワークフロー

3.1 フェーズ

#フェーズ内容完了条件
1要件確認ローカル環境要件の確認要件が明確
2実装Docker Compose作成docker-compose up 成功
3レビュー設定レビューレビュー9点以上
4ドキュメント化セットアップ手順の記載README更新

3.2 Docker Compose ベストプラクティス

ディレクトリ構成
docker/
├── docker-compose.yml          # 本番用
├── docker-compose.dev.yml      # 開発用(上書き)
├── docker-compose.test.yml     # テスト用
├── .env.example                # 環境変数テンプレート
└── services/
    ├── backend/
    │   └── Dockerfile
    ├── frontend/
    │   └── Dockerfile
    └── nginx/
        └── nginx.conf
必須設定
version: '3.8'

services:
  backend:
    build:
      context: ./​services/​backend
      dockerfile: Dockerfile
    env_file:
      - .env
    networks:
      - app-network
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/​health"]
      interval: 30s
      timeout: 10s
      retries: 3
    depends_on:
      db:
        condition: service_healthy

  db:
    image: postgres:15-alpine
    volumes:
      - db-data:/​var/​lib/​postgresql/​data
    environment:
      POSTGRES_USER: ${DB_USER}
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_DB: ${DB_NAME}
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${DB_USER}"]
      interval: 10s
      timeout: 5s
      retries: 5

networks:
  app-network:
    driver: bridge

volumes:
  db-data:

3.3 開発環境用オーバーライド

# docker-compose.dev.yml
version: '3.8'

services:
  backend:
    volumes:
      - ./​backend:/​app          # ホットリロード用
      - /​app/​node_modules       # node_modules除外
    environment:
      - DEBUG=true
    ports:
      - "3000:3000"
      - "9229:9229"             # デバッグポート

  frontend:
    volumes:
      - ./​frontend:/​app
      - /​app/​node_modules
    ports:
      - "5173:5173"

3.4 チェック項目

カテゴリチェック項目
バージョンversion: '3.8' 以上か
ネットワーク適切なネットワーク分離がされているか
ボリュームデータ永続化が適切に設定されているか
環境変数.env ファイルから参照しているか
ヘルスチェックhealthcheckが設定されているか
依存関係depends_onで適切な依存関係が設定されているか
セキュリティ機密情報がハードコードされていないか

4. Well-Architected Framework対応

4.1 5つの柱

柱確認項目
セキュリティ暗号化、最小権限、ネットワーク分離、監査ログ
信頼性Multi-AZ、Auto Scaling、バックアップ、DR
パフォーマンス効率適切なインスタンスサイズ、キャッシュ、CDN
コスト最適化不要リソース削除、Reserved/​Spot活用
運用上の優秀性IaC、CloudWatch、タグ付け、自動化

4.2 各柱のチェックリスト

セキュリティ
  • 全データの暗号化(at rest / in transit)
  • IAMポリシーは最小権限
  • セキュリティグループは最小権限
  • CloudTrailが有効
  • VPCフローログが有効
  • WAFの設定(該当する場合)
信頼性
  • Multi-AZ構成
  • Auto Scalingの設定
  • RDSの自動バックアップ
  • S3のバージョニング
  • DR計画の文書化
パフォーマンス効率
  • 適切なインスタンスタイプの選択
  • ElastiCacheの活用(該当する場合)
  • CloudFrontの活用(該当する場合)
  • RDSのリードレプリカ(該当する場合)
コスト最適化
  • 不要なリソースの削除
  • Reserved Instancesの検討
  • Spot Instancesの検討
  • S3ライフサイクルポリシー
運用上の優秀性
  • 全リソースにタグ付け
  • CloudWatch Alarmの設定
  • CloudWatch Logsへのログ集約
  • IaCによる完全な管理

5. 環境変数管理

5.1 Terraformからの環境変数出力

# outputs.tf
output "backend_env_vars" {
  description = "バックエンド用環境変数(非機密)"
  value = {
    DATABASE_HOST = aws_db_instance.main.address
    REDIS_HOST    = aws_elasticache_cluster.main.cache_nodes[0].address
    S3_BUCKET     = aws_s3_bucket.main.id
  }
}

output "backend_secrets_arn" {
  description = "Secrets Manager ARN"
  value       = aws_secretsmanager_secret.backend.arn
}

5.2 機密情報の管理

環境管理方法
ローカル.env ファイル(.gitignore)
AWSSecrets Manager
CI/​CDGitHub Secrets / GitLab CI Variables

変更履歴

日付バージョン変更内容
2026-01-021.0.0初版作成(ai-frameworkからの取り込み)

More DevOps & CI/CD skills

Project scaffolding, deployment configuration, and CI/CD setup for Google ADK agents.

6K 472.6K
View

Set up tracing, logging, and monitoring for deployed ADK agents across Cloud Trace, BigQuery, and third-party platforms.

6K 472.6K
View

Enterprise Azure infrastructure architect generating Bicep or Terraform from workload descriptions.

1.5K 454.3K
View
azure-kubernetes logo
DevOps & CI/CD

azure-kubernetes

Plan and configure production-ready Azure Kubernetes Service clusters with Day-0 and Day-1 best practices.

1.5K 447.1K
View

Raw mechanical interfaces fusing Swiss typographic print with military terminal aesthetics. Rigid grids, extreme type scale contrast, utilitarian color, analog degradation effects. For data-heavy dashboards, portfolios, or editorial sites that need to feel like declassified blueprints.

92.7K 354.9K
View
just-scrape logo
DevOps & CI/CD

just-scrape

Web search, scraping, extraction, crawling, and monitoring via ScrapeGraph AI CLI.

69 245K
View

Skill for working with Firebase Hosting (Classic). Use this when you want to deploy static web apps, Single Page Apps (SPAs), or simple microservices. Do NOT use for Firebase App Hosting.

462 159.7K
View

Deploy and manage web apps with Firebase App Hosting. Use this skill when deploying Next.js/Angular apps with backends.

462 159.1K
View
deploy-to-vercel logo
DevOps & CI/CD

deploy-to-vercel

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

31.9K 146.6K
View
programmatic-seo logo
DevOps & CI/CD

programmatic-seo

Build SEO-optimized pages at scale using templates, data, and proven playbook patterns.

53.3K 140.1K
View

Design and build isolated, reusable Convex backend components with clear boundaries and app-facing wrappers.

63 123.5K
View

Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".

31.9K 116.1K
View

Coding & apps AI tools

Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View
I
Coding & apps

Imagica

Build a no-code AI app in minutes.

Freemium
View
E
Coding & apps

Emergent.sh

An IDE for code migration from legacy to modern frameworks through coding agents.

Freemium
View
Wonder Dynamics logo
Coding & apps

Wonder Dynamics

Automate CGI animation in live-action scenes

Paid
View
M
Coding & apps

Mixo

Launch a website in seconds with AI.

Paid
View
AI Code Convert logo
Coding & apps

AI Code Convert

Streamline Your Coding Experience with AI Code Helper

Free
View