Skip to content

Commit 4cd3964

Browse files
authored
[Updated] Terraform guides with steps for storing state on OBJ (#7091)
* [Updated] Terraform guides with steps for storing state on OBJ * edit to config file code * copy edit and code block fix
1 parent 523412f commit 4cd3964

File tree

2 files changed

+35
-3
lines changed
  • docs/guides/applications/configuration-management/terraform
    • how-to-build-your-infrastructure-using-terraform-and-linode
    • how-to-use-terraform-with-linode-object-storage

2 files changed

+35
-3
lines changed

docs/guides/applications/configuration-management/terraform/how-to-build-your-infrastructure-using-terraform-and-linode/index.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: 'This article gives you step-by-step instructions on how to use Ter
55
authors: ["Damaso Sanoja"]
66
contributors: ["Damaso Sanoja"]
77
published: 2017-11-06
8-
modified: 2023-07-26
8+
modified: 2024-08-26
99
keywords: ["terraform", "infrastructure", "IaC"]
1010
license: '[CC BY-ND 4.0](https://creativecommons.org/licenses/by-nd/4.0)'
1111
aliases: ['/applications/configuration-management/terraform/how-to-build-your-infrastructure-using-terraform-and-linode/','/applications/configuration-management/how-to-build-your-infrastructure-using-terraform-and-linode/','/platform/how-to-build-your-infrastructure-using-terraform-and-linode/']
@@ -676,4 +676,30 @@ Create a deployment for an imaginary client:
676676
terraform init
677677
terraform plan
678678
terraform apply
679-
```
679+
```
680+
681+
### Use Linode Object Storage to Store State
682+
683+
[State](https://developer.hashicorp.com/terraform/language/state) data files are stored on a [backend](https://developer.hashicorp.com/terraform/language/settings/backends/configuration) by Terraform to log and track metadata, map resources to a configuration, and improve performance. By default, state is stored locally in the `terraform.tfstate` file.
684+
685+
Using the configuration below with the `backend` block, you can set up Terraform to use Linode Object Storage to store state remotely. The `backend` block should be nested within the `terraform` block as noted in [Hashicorp's official backend documentation](https://developer.hashicorp.com/terraform/language/settings/backends/s3). In this guide, the `terraform` block is located in the `main.tf` configuration file.
686+
687+
Note that this module assumes an object storage bucket already exists on your account. Replace values with your bucket and key information:
688+
689+
```file {title="obj-backend.tf"}
690+
# Backend Configuration
691+
backend "s3" {
692+
bucket = "{{< placeholder "YOUR-BUCKET-NAME" >}}" # The bucket name created on your account to which your access_key and secret_key can read and write
693+
key = "{{< placeholder "tf/tfstate" >}}" # The folder ({{< placeholder "tf" >}}) and object ({{< placeholder "tfstate" >}}) in your bucket where you want to write state to
694+
region = "{{< placeholder "us-southeast-1" >}}" # The region where your object storage bucket is at which is the same as the ClusterID Here https://techdocs.akamai.com/cloud-computing/docs/access-buckets-and-files-through-urls#cluster-url-s3-endpoint
695+
access_key = "{{< placeholder "OBJ-ACCESS-KEY" >}}" # You can put your value here inline or add it as an environment variable AWS_ACCESS_KEY_ID see more here https://developer.hashicorp.com/terraform/language/settings/backends/s3#credentials-and-shared-configuration
696+
secret_key = "{{< placeholder "OBJ-SECRET-KEY" >}}" # You can put your value here inline or add it as an environment variable AWS_SECRET_ACCESS_KEY see more here https://developer.hashicorp.com/terraform/language/settings/backends/s3#credentials-and-shared-configuration
697+
skip_region_validation = true # All of these skip_* arguements are used since our object storage doesn't implement these additional endpoints
698+
skip_credentials_validation = true
699+
skip_requesting_account_id = true
700+
skip_s3_checksum = true
701+
endpoints = {
702+
s3 = "{{< placeholder "https://us-southeast-1.linodeobjects.com" >}}" # The endpoint for the s3 API based on the region your bucket is located https://techdocs.akamai.com/cloud-computing/docs/access-buckets-and-files-through-urls#cluster-url-s3-endpoint
703+
}
704+
}
705+
```

docs/guides/applications/configuration-management/terraform/how-to-use-terraform-with-linode-object-storage/index.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: 'This guide provides a brief introduction to Terraform, and explain
66
authors: ["Jeff Novotny"]
77
contributors: ["Jeff Novotny"]
88
published: 2022-10-25
9-
modified: 2022-11-28
9+
modified: 2024-08-26
1010
keywords: ['Linode Terraform','Terraform Linode Object Storage','Install Terraform']
1111
license: '[CC BY-ND 4.0](https://creativecommons.org/licenses/by-nd/4.0)'
1212
external_resources:
@@ -465,6 +465,12 @@ terraform plan
465465
terraform apply
466466
```
467467

468+
## Configure Terraform to Store State on Linode Object Storage
469+
470+
Terraform uses [state](https://developer.hashicorp.com/terraform/language/state) on a [backend](https://developer.hashicorp.com/terraform/language/settings/backends/configuration) to log and track resource information. By default, state is stored locally in a file named `terraform.tfstate`.
471+
472+
For steps on how to use Linode Object Storage as a remote backend to store state, see our guide [Use Terraform to Provision Infrastructure on Linode](/docs/guides/how-to-build-your-infrastructure-using-terraform-and-linode/#use-linode-object-storage-to-store-state).
473+
468474
## Conclusion
469475

470476
Terraform is a powerful and efficient *Infrastructure as Code* (IaC) application. It automates the process of deploying infrastructure. To use Terraform, use the HCL or JSON formats to describe the final state of the network. Use the `terraform plan` command from the Terraform client to preview the changes and `terraform apply` to deploy the configuration.

0 commit comments

Comments
 (0)