{"id":43571642,"url":"https://github.com/tqer39/terraform-aws","last_synced_at":"2026-02-03T22:16:44.998Z","repository":{"id":37022659,"uuid":"487128885","full_name":"tqer39/terraform-aws","owner":"tqer39","description":"Configure AWS resources with Terraform.","archived":false,"fork":false,"pushed_at":"2025-12-02T18:45:49.000Z","size":1082,"stargazers_count":3,"open_issues_count":14,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-12-05T18:25:02.427Z","etag":null,"topics":["aws","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tqer39.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-04-29T22:47:34.000Z","updated_at":"2025-06-26T15:27:34.000Z","dependencies_parsed_at":"2023-09-23T00:05:09.847Z","dependency_job_id":"f553ca3c-8819-4116-9f25-7b31b54d1ca6","html_url":"https://github.com/tqer39/terraform-aws","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/tqer39/terraform-aws","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tqer39%2Fterraform-aws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tqer39%2Fterraform-aws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tqer39%2Fterraform-aws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tqer39%2Fterraform-aws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tqer39","download_url":"https://codeload.github.com/tqer39/terraform-aws/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tqer39%2Fterraform-aws/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29059542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T20:13:53.544Z","status":"ssl_error","status_checked_at":"2026-02-03T20:13:40.507Z","response_time":96,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","terraform"],"created_at":"2026-02-03T22:16:43.235Z","updated_at":"2026-02-03T22:16:44.991Z","avatar_url":"https://github.com/tqer39.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# terraform-aws\n\nAWS のリソースを Terraform で構成する。\n\n## GitHub Actions Status badges\n\n| Name | Environment | Result |\n| :--- | :--- | :--- |\n| Linterなどによる検証 | pre-commit | ![pre-commit](https://github.com/tqer39/terraform-aws/actions/workflows/pre-commit.yml/badge.svg) |\n| AWS 検証環境 | Sandbox | ![Terraform - sandbox](https://github.com/tqer39/terraform-aws/actions/workflows/_terraform-aws-sandbox.yml/badge.svg) |\n| AWS ポートフォリオ | Management | ![Terraform - management](https://github.com/tqer39/terraform-aws/actions/workflows/_terraform-aws-portfolio.yml/badge.svg) |\n| AWS 全体管理 | Management | ![Terraform - management](https://github.com/tqer39/terraform-aws/actions/workflows/_terraform-aws-management.yml/badge.svg) |\n\n## ブランチ設計\n\n```mermaid\ngitGraph\n    commit\n    branch feature/update-readme\n    commit\n    commit\n    commit\n    checkout main\n    merge feature/update-readme\n    commit\n    commit\n```\n\n1. GitHub Flow で運用します。\n2. `main` がデフォルトブランチです。\n3. `main` ブランチにマージされると GitHub Actions で `terraform apply` でインフラが更新されます。\n   - **マージのタイミングがデプロイに相当します。**\n\n## module 化しないリソース\n\n| リソース | 理由 |\n| :--- | :--- |\n| [aws_iam_role_policy_attachment](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | パラメータが少なすぎて module 化するメリットがない |\n| [aws_route53_record](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | リソースの種類が多く汎用的な module にするコストに見合うメリットがない |\n\n## セキュリティポリシー\n\n### AWS の認証方法\n\n- GitHub Actions から AWS のリソースをデプロイするときの認証方式は OIDC です。\n- Credential は管理面の手間がかかるため採用していません。\n\n## EditorConfig 設定\n\n包括的なコーディング規約として EditorConfig を使用しているため、[公式ページの Download a Plugin](https://editorconfig.org/#download) のエディタ・IDE を使用している場合は、プラグインを追加してください。\n\n## Setup\n\n### Homebrew\n\n```bash\n# install brew see: https://brew.sh/index_ja\n/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\"\n\n# install software\nbrew bundle\n```\n\n### anyenv\n\n#### zsh\n\n```bash\nanyenv init\nanyenv install --init\necho 'eval \"$(anyenv init -)\"' \u003e\u003e ~/.zshrc\nexec $SHELL -l\nmkdir -p \"$(anyenv root)/plugins\"\ngit clone https://github.com/znz/anyenv-update.git \"$(anyenv root)/plugins/anyenv-update\"\n```\n\n#### fish\n\n```bash\nanyenv init - fish | source\nanyenv install --init\nset -Ux fish_user_paths $HOME/.anyenv/bin $fish_user_paths\necho 'set -x PATH ~/.anyenv/bin $PATH' \u003e\u003e ~/.config/fish/config.fish\necho 'eval (anyenv init - | source)' \u003e\u003e ~/.config/fish/config.fish\nexec fish -l\nmkdir -p (anyenv root)/plugins\ngit clone https://github.com/znz/anyenv-update.git (anyenv root)/plugins/anyenv-update\nwhich anyenv\n```\n\n### tfenv\n\n```bash\nanyenv install tfenv\nwhich tfenv\n```\n\n### Terraform\n\n```bash\ntfenv install\nwhich terraform\nterraform install\nterraform -version\n```\n\n### Rancher Desktop\n\n#### Linux\n\nsee [Rancher Desktop - Linux](https://docs.rancherdesktop.io/getting-started/installation/#linux)\n\n```bash\ncurl -s https://download.opensuse.org/repositories/isv:/Rancher:/stable/deb/Release.key | gpg --dearmor | sudo dd status=none of=/usr/share/keyrings/isv-rancher-stable-archive-keyring.gpg\necho 'deb [signed-by=/usr/share/keyrings/isv-rancher-stable-archive-keyring.gpg] https://download.opensuse.org/repositories/isv:/Rancher:/stable/deb/ ./' | sudo dd status=none of=/etc/apt/sources.list.d/isv-rancher-stable.list\nsudo apt update\nsudo apt install rancher-desktop\n```\n\nos reboot.\n\n### Session Manager Plugin\n\nsee: [(オプション) AWS CLI 用の Session Manager プラグインをインストールする](https://docs.aws.amazon.com/ja_jp/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html)\n\n#### Linux (Debian | amd64)\n\n```bash\ncurl \"https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_64bit/session-manager-plugin.deb\" -o \"session-manager-plugin.deb\"\nsudo dpkg -i session-manager-plugin.deb\nrm -rf session-manager-plugin.deb\n```\n\n### pre-commit\n\n```bash\n# setup\npre-commit install --install-hooks\n```\n\n### ローカルから Terraform CLI を実行する方法\n\n#### AWS Profile の設定\n\nこれは Makefile の aws-vault で使用されます。\n下記の内容を `~/.aws/config` に設定します。\n\n```bash\n[profile terraform-aws-management]\nsso_start_url = https://tqer39-management.awsapps.com/start/\nsso_region = ap-northeast-1\nsso_account_id = 577523824419\nsso_role_name = \u003cAWS SSO Role Name\u003e\nregion = ap-northeast-1\noutput = json\n```\n\n### Terraform のセットアップ\n\n```bash\ntfenv install\nterraform -v\n```\n\nコマンドのフォーマット\n\n- `AWS CLI (SSO) の profile`: 前項で設定した AWS CLI の profile\n- `実行先のパス`: Terraform CLI を実行するパス\n- `Terraform コマンド`: `terraform` に続くコマンド\n\n```bash\n# Format:\naws-vault exec \"${AWS CLI (SSO) の profile}\" -- terraform -chdir=\"${実行先のパス}\" \"${Terraform コマンド}\"\n```\n\n#### terraform init（初期化）\n\n```bash\n# Example:\naws-vault exec terraform-aws-management -- terraform -chdir=./terraform/environments/dev/base_apne1 init\n```\n\n#### terraform validate\n\n```bash\n# Example:\naws-vault exec terraform-aws-management -- terraform -chdir=./terraform/environments/dev/base_apne1 validate\n```\n\n#### terraform plan\n\n```bash\n# Example:\naws-vault exec terraform-aws-management -- terraform -chdir=./terraform/environments/dev/base_apne1 plan\n```\n\n#### terraform apply\n\n**※ローカルからのデプロイは原則禁止です。**\n\n```bash\n# Example:\naws-vault exec terraform-aws-management -- terraform -chdir=./terraform/environments/dev/base_apne1 apply -auto-approve\n```\n\n## 新しい環境の作成方法\n\n手動で s3 バケットを作成。\nリソースを作成。\n\n```txt\n.github/workflows/terraform-aws-\u003c環境名\u003e.yml\n.github/labeler.yml\nterraform/environments/\u003c環境名\u003e/base/main.tf\nterraform/environments/\u003c環境名\u003e/base/provider.tf\nterraform/environments/\u003c環境名\u003e/base/terraform.tf\nterraform/environments/\u003c環境名\u003e/base/shared-locals.tf\nterraform/environments/\u003c環境名\u003e/shared/locals.tf\n```\n\n```zsh\n# https://xxxxx.awsapps.com/start#/\nexport AWS_ACCESS_KEY_ID=\"XXXXXXXXXX\"\nexport AWS_SECRET_ACCESS_KEY=\"XXXXXXXXXX\"\nexport AWS_SESSION_TOKEN=\"XXXXXXXXXX\"\n\nterraform -chdir=terraform/environments/\u003c環境名\u003e/base init\n```\n\n手動で作成した s3 バケットを import。\n\n```zsh\n$TF_PATH=\"terraform/environments/\u003c環境名\u003e/base\"\nterraform -chdir=\"$TF_PATH\" import module.terraform-backend.module.s3-bucket.aws_s3_bucket.this \u003cバケット名\u003e\nterraform -chdir=\"$TF_PATH\" import module.terraform-backend.module.s3-bucket.aws_s3_bucket_acl.this \u003cバケット名\u003e\nterraform -chdir=\"$TF_PATH\" import module.terraform-backend.module.s3-bucket.aws_s3_bucket_public_access_block.this \u003cバケット名\u003e\nterraform -chdir=\"$TF_PATH\" import module.terraform-backend.module.s3-bucket.aws_s3_bucket_versioning.this \u003cバケット名\u003e\n```\n\nOIDC 関連のリソースの新規作成と s3 バケットのパラメータ更新を行います。\n\n```zsh\n$TF_PATH=\"terraform/environments/\u003c環境名\u003e/base\"\nterraform -chdir=\"$TF_PATH\" fmt\nterraform -chdir=\"$TF_PATH\" validate\nterraform -chdir=\"$TF_PATH\" plan\nterraform -chdir=\"$TF_PATH\" apply -auto-approve\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftqer39%2Fterraform-aws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftqer39%2Fterraform-aws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftqer39%2Fterraform-aws/lists"}