Skip to content

Commit

Permalink
docs: add terraform lock document (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
orangekame3 authored Oct 9, 2024
1 parent d09f595 commit 20b9c1f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/en/operation/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ First, let's explain the procedure to deploy the infrastructure environment, suc
aws s3api create-bucket --bucket tfstate.oqtopus-example-dev --profile example-dev --region ap-northeast-1 --create-bucket-configuration LocationConstraint=ap-northeast-1
```

Next, create a DynamoDB table to lock the Terraform state file.

```bash
aws dynamodb create-table --table-name terraform-lock --attribute-definitions AttributeName=LockID,AttributeType=S --key-schema AttributeName=LockID,KeyType=HASH --billing-mode PAY_PER_REQUEST --profile example-dev --region ap-northeast-1
```

Next, prepare the Terraform configuration files. Create the following two files.

```hcl:infrastructure/example-dev/example-dev.tfbackend
Expand All @@ -47,6 +53,7 @@ key = "infrastructure.tfstate"
encrypt = true
profile = "example-dev"
region = "ap-northeast-1"
dynamodb_table = "terraform-lock"
```

```hcl:infrastructure/example-dev/terraform.tfvars
Expand Down Expand Up @@ -85,6 +92,7 @@ key = "service.tfstate"
encrypt = true
profile = "example-dev"
region = "ap-northeast-1"
dynamodb_table = "terraform-lock"
```

```hcl:service/example-dev/terraform.tfvars
Expand Down
8 changes: 8 additions & 0 deletions docs/ja/operation/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ stateファイルはS3で管理されるため、S3バケットを作成する
aws s3api create-bucket --bucket tfstate.oqtopus-example-dev --profile example-dev --region ap-northeast-1 --create-bucket-configuration LocationConstraint=ap-northeast-1
```

次にTerraformのStateフアイルをロックするためのDynamoDBテーブルを作成します。

```bash
aws dynamodb create-table --table-name terraform-lock --attribute-definitions AttributeName=LockID,AttributeType=S --key-schema AttributeName=LockID,KeyType=HASH --billing-mode PAY_PER_REQUEST --profile example-dev --region ap-northeast-1
```

次に、terraformの設定ファイルを用意します。以下の2つのファイルを作成します。

```hcl:infrastructure/example-dev/example-dev.tfbackend
Expand All @@ -50,6 +56,7 @@ key = "infrastructure.tfstate"
encrypt = true
profile = "example-dev"
region = "ap-northeast-1"
dynamodb_table = "terraform-lock"
```

```hcl:infrastructure/example-dev/terraform.tfvars
Expand Down Expand Up @@ -88,6 +95,7 @@ key = "service.tfstate"
encrypt = true
profile = "example-dev"
region = "ap-northeast-1"
dynamodb_table = "terraform-lock"
```

```hcl:service/example-dev/terraform.tfvars
Expand Down

0 comments on commit 20b9c1f

Please sign in to comment.