-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
501 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Setup | ||
description: setup a job | ||
|
||
inputs: | ||
workload_identity_provider: | ||
description: Workload Identity Provider ID | ||
required: true | ||
service_account: | ||
description: SA for running Terraform CLI | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Setup Terraform CLI | ||
uses: hashicorp/setup-terraform@v3 | ||
with: | ||
terraform_version: "1.7.5" | ||
|
||
- name: Auth for Google Cloud | ||
id: auth-for-google-cloud | ||
uses: google-github-actions/auth@v2 | ||
with: | ||
create_credentials_file: true | ||
workload_identity_provider: ${{ inputs.workload_identity_provider }} | ||
service_account: ${{ inputs.service_account }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# シェルの配列構文で定義する必要がある | ||
modules1: | ||
- network | ||
- github | ||
modules2: | ||
- db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
name: ci/cd | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
types: [opened, synchronize] | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
test-prep: | ||
runs-on: ubuntu-22.04 | ||
env: | ||
TF_VAR_service: ${{ secrets.TEST_SERVICE }} | ||
TF_VAR_env: test | ||
steps: | ||
# - name: Confirm minimum permissions | ||
# uses: GitHubSecurityLab/actions-permissions/monitor@v1 | ||
# with: | ||
# config: ${{ vars.PERMISSIONS_CONFIG }} | ||
|
||
- name: Checkout project | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup job | ||
uses: ./.github/actions/setup | ||
with: | ||
workload_identity_provider: ${{ secrets.TEST_WORKLOAD_IDENTITY_PROVIDER }} | ||
service_account: ${{ secrets.TEST_SERVICE_ACCOUNT }} | ||
|
||
- name: Run apply command to tier1 on test | ||
run: | | ||
./terraform/environments/test/tier1/apply.sh | ||
test: | ||
needs: test-prep | ||
runs-on: ubuntu-22.04 | ||
env: | ||
TF_VAR_service: ${{ secrets.TEST_SERVICE }} | ||
TF_VAR_env: test | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
shard: [modules1, modules2] | ||
steps: | ||
# - name: Confirm minimum permissions | ||
# uses: GitHubSecurityLab/actions-permissions/monitor@v1 | ||
# with: | ||
# config: ${{ vars.PERMISSIONS_CONFIG }} | ||
|
||
- name: Checkout project | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup job | ||
uses: ./.github/actions/setup | ||
with: | ||
workload_identity_provider: ${{ secrets.TEST_WORKLOAD_IDENTITY_PROVIDER }} | ||
service_account: ${{ secrets.TEST_SERVICE_ACCOUNT }} | ||
|
||
- name: Run tests | ||
run: | | ||
while IFS= read MODULE; do | ||
./terraform/modules/$MODULE/test.sh | ||
done <<< "$(yq -r .${{ matrix.shard }}[] ./.github/test_matrix.yaml)" | ||
plan: | ||
needs: test | ||
runs-on: ubuntu-22.04 | ||
env: | ||
TF_VAR_service: ${{ secrets.STG_SERVICE }} | ||
TF_VAR_env: stg | ||
steps: | ||
# - name: Confirm minimum permissions | ||
# uses: GitHubSecurityLab/actions-permissions/monitor@v1 | ||
# with: | ||
# config: ${{ vars.PERMISSIONS_CONFIG }} | ||
|
||
- name: Checkout project | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup job | ||
uses: ./.github/actions/setup | ||
with: | ||
workload_identity_provider: ${{ secrets.STG_WORKLOAD_IDENTITY_PROVIDER }} | ||
service_account: ${{ secrets.STG_SERVICE_ACCOUNT }} | ||
|
||
- name: Run plan command to tier1 on stg | ||
run: | | ||
cd ./terraform/environments/stg/tier1/ | ||
terraform init -backend-config="bucket=${{ env.TF_VAR_service }}-${{ env.TF_VAR_env }}-terraform" | ||
terraform plan | ||
- name: Run plan command to tier2 on stg | ||
run: | | ||
cd ./terraform/environments/stg/tier2/ | ||
terraform init -backend-config="bucket=${{ env.TF_VAR_service }}-${{ env.TF_VAR_env }}-terraform" | ||
terraform plan | ||
- name: Send the results to Slack channel | ||
id: slack | ||
uses: slackapi/[email protected] | ||
with: | ||
payload: | | ||
{ | ||
"key": "value", | ||
"foo": "bar" | ||
} | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
subnet_ip = "10.1.1.0/24" | ||
subnet_ip = "10.1.1.0/24" | ||
peering_network_address = "10.1.2.0" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
data "terraform_remote_state" "tier1" { | ||
backend = "gcs" | ||
config = { | ||
bucket = "${local.project_id}-terraform" | ||
prefix = "terraform/tier1-state" | ||
bucket = "${local.project_id}-terraform" | ||
prefix = "terraform/tier1-state" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
subnet_ip = "10.4.1.0/24" | ||
subnet_ip = "10.4.1.0/24" | ||
peering_network_address = "10.4.2.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.