Skip to content

Commit 09321fe

Browse files
authored
[Updated] A Beginners Guide to Terraform (#7288)
* [Updated] A Beginners Guide to Terraform * edit provider version, edit distro version, add release version link, edit resources copy
1 parent 0ff5012 commit 09321fe

File tree

1 file changed

+26
-26
lines changed
  • docs/guides/applications/configuration-management/terraform/beginners-guide-to-terraform

1 file changed

+26
-26
lines changed

docs/guides/applications/configuration-management/terraform/beginners-guide-to-terraform/index.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: 'A look into Terraform''s primary components, features, and configu
55
authors: ["Linode"]
66
contributors: ["Linode"]
77
published: 2018-12-21
8-
modified: 2019-08-07
8+
modified: 2025-06-13
99
keywords: ['terraform', 'orchestration', 'linode provider']
1010
license: '[CC BY-ND 4.0](https://creativecommons.org/licenses/by-nd/4.0)'
1111
image: ABeginnersGuidetoTerraform.png
@@ -25,16 +25,14 @@ Terraform's primary job is to create, modify, and destroy servers and other reso
2525

2626
## The Linode Provider
2727

28-
Terraform is a general orchestration tool that can interface with a number of different cloud platforms. These integrations are referred to as *providers*. The Terraform provider for Linode was [officially released](https://blog.linode.com/2018/10/30/now-available-linode-terraform-provider/) in October 2018.
29-
30-
{{< note >}}
31-
The Linode provider relies on Linode's [APIv4](/docs/products/tools/api/), so an API access token is needed to use it. See [Use Terraform to Provision Linode Environments](/docs/guides/how-to-build-your-infrastructure-using-terraform-and-linode/) for instructions on getting an API token and installing Terraform and the Linode provider on your computer.
32-
{{< /note >}}
28+
Terraform is a general orchestration tool that can interface with a number of different cloud platforms. These integrations are referred to as *providers*. The Terraform provider for Linode was [officially released](https://blog.linode.com/2018/10/30/now-available-linode-terraform-provider/) in October 2018. A version history, including the latest provider release number, can be found on [Terraform's Registry](https://registry.terraform.io/providers/linode/linode/latest).
3329

3430
The Linode provider can be used to create Linode instances, Images, domain records, Block Storage Volumes, StackScripts, and other resources. Terraform's [official Linode provider documentation](https://www.terraform.io/docs/providers/linode/index.html) details each resource that can be managed.
3531

32+
The Linode provider relies on Linode's [APIv4](/docs/products/tools/api/), and an API access token is needed to use it. See [Use Terraform to Provision Linode Environments](/docs/guides/how-to-build-your-infrastructure-using-terraform-and-linode/) for instructions on getting an API token and installing Terraform and the Linode provider on your computer.
33+
3634
{{< note >}}
37-
[Terraform’s Linode Provider](https://github.com/linode/terraform-provider-linode) has been updated and now requires Terraform version 0.12+. To learn how to safely upgrade to Terraform version 0.12+, see [Terraform’s official documentation](https://www.terraform.io/upgrade-guides/0-12.html). View [Terraform v0.12’s changelog](https://github.com/hashicorp/terraform/blob/v0.12.0/CHANGELOG.md) for a full list of new features and version incompatibility notes.
35+
As of May 22, 2019, [Terraform’s Linode Provider](https://github.com/linode/terraform-provider-linode) requires Terraform version 0.12+. To learn how to safely upgrade to Terraform version 0.12+, see [Terraform’s official documentation](https://www.terraform.io/upgrade-guides/0-12.html). View [Terraform v0.12’s changelog](https://github.com/hashicorp/terraform/blob/v0.12.0/CHANGELOG.md) for a full list of Terraform versions, features, and incompatibility notes.
3836
{{< /note >}}
3937

4038
## Infrastructure as Code
@@ -57,44 +55,46 @@ The next sections will illustrate core Terraform concepts with examples written
5755

5856
Here's a simple example of a complete Terraform configuration in HCL:
5957

58+
{{< note >}}
59+
The SSH key in this example is truncated for brevity.
60+
{{< /note >}}
61+
6062
{{< file "example.tf" >}}
6163
terraform {
6264
required_providers {
6365
linode = {
6466
source = "linode/linode"
65-
version = "1.16.0"
67+
version = "3.0.0"
6668
}
6769
}
6870
}
6971

7072
provider "linode" {
71-
token = "your-linode-api-token"
73+
token = "your-linode-api-token"
7274
}
7375

7476
resource "linode_instance" "example_instance" {
75-
label = "example_instance_label"
76-
image = "linode/ubuntu18.04"
77-
region = "us-central"
78-
type = "g6-standard-1"
79-
authorized_keys = ["ssh-rsa AAAA...Gw== [email protected]"]
80-
root_pass = "your-root-password"
77+
label = "simple_instance"
78+
image = "linode/ubuntu22.04"
79+
region = "us-central"
80+
type = "g6-standard-1"
81+
authorized_keys = ["ssh-rsa AAAA...Gw== [email protected]"]
82+
root_pass = "this-is-not-a-safe-password"
8183
}
8284
{{< /file >}}
8385

84-
{{< note >}}
85-
The SSH key in this example was truncated for brevity.
86-
{{< /note >}}
86+
This example Terraform file, with the Terraform file extension `.tf`, represents the creation of a single Linode instance labeled `example_instance_label`. This example file is prefixed with a mandatory `provider` block, which sets up the Linode provider must be listed in your configuration.
8787

88-
This example Terraform file, with the Terraform file extension `.tf`, represents the creation of a single Linode instance labeled `example_instance_label`. This example file is prefixed with a mandatory `provider` block, which sets up the Linode provider and which you must list somewhere in your configuration.
88+
The `provider` block is followed by a *resource* declaration. The `example_instance` string that follows the `linode_instance` resource type declaration is Terraform's name for the resource. You cannot declare more than one Terraform resource with the same name and resource type. Resource declarations correspond with the components of your Linode infrastructure: Linode instances, Block Storage Volumes, etc.
8989

90-
The `provider` block is followed by a *resource* declaration. Resource declarations correspond with the components of your Linode infrastructure: Linode instances, Block Storage Volumes, etc.
90+
Resources can accept arguments. The `label` argument specifies the label for the Linode instance in the Linode Manager. This name is independent of Terraform's name for the resource (though you can assign the same value to both). The Terraform name is only recorded in Terraform's [state](#state) and is not communicated to the Linode API. Labels for Linode instances in the same Linode account must be unique.
9191

92-
Resources can accept arguments. `region` and `type` are required arguments for the `linode_instance` resource. A root password must be assigned to every Linode, but the `root_pass` Terraform argument is optional; if it is not specified, a random password will be generated.
92+
`region` and `type` are required arguments for the `linode_instance` resource. The `authorized_keys` argument allows you to optionally provide one or more SSH public keys to deploy for the *root* user. A root password must be assigned to every Linode, but the `root_pass` Terraform argument is optional; if it is not specified, a random password will be generated.
9393

94-
{{< note >}}
95-
The `example_instance` string that follows the `linode_instance` resource type declaration is Terraform's name for the resource. You cannot declare more than one Terraform resource with the same name and resource type.
94+
{{< note title="Root Access & Non-Root Users" >}}
95+
It is considered a best practice to limit root user access on any compute instance. For security best practices and configuration steps after deployment, see our [Set Up and Secure a Linode](https://techdocs.akamai.com/cloud-computing/docs/set-up-and-secure-a-compute-instance) guide.
9696

97-
The `label` argument specifies the label for the Linode instance in the Linode Manager. This name is independent of Terraform's name for the resource (though you can assign the same value to both). The Terraform name is only recorded in Terraform's [state](#state) and is not communicated to the Linode API. Labels for Linode instances in the same Linode account must be unique.
97+
Additionally, non-root users can not be created upon initial deployment using the Linode Terraform Provider. See our [Linux Users and Groups](/docs/guides/linux-users-and-groups/#creating-and-deleting-user-accounts) guide for steps on creating and configuring user accounts on a Linode instance.
9898
{{< /note >}}
9999

100100
### Data Sources
@@ -162,7 +162,7 @@ terraform {
162162
required_providers {
163163
linode = {
164164
source = "linode/linode"
165-
version = "1.16.0"
165+
version = "3.0.0"
166166
}
167167
}
168168
}
@@ -173,7 +173,7 @@ provider "linode" {
173173

174174
resource "linode_instance" "example_instance" {
175175
label = "example_instance_label"
176-
image = "linode/ubuntu18.04"
176+
image = "linode/ubuntu22.04"
177177
region = var.region
178178
type = "g6-standard-1"
179179
authorized_keys = [var.ssh_key]

0 commit comments

Comments
 (0)