Skip to content

Commit 0840073

Browse files
committed
OSDOCS-9242: Terraform Guide Updates
1 parent a837529 commit 0840073

13 files changed

+584
-144
lines changed

_topic_maps/_topic_map_rosa.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,16 @@ Distros: openshift-rosa
215215
Topics:
216216
- Name: Creating a ROSA cluster with STS using the default options
217217
File: rosa-sts-creating-a-cluster-quickly
218-
- Name: Creating a ROSA cluster with STS using the default options with Terraform
219-
File: rosa-sts-creating-a-cluster-quickly-terraform
220218
- Name: Creating a ROSA cluster with STS using customizations
221219
File: rosa-sts-creating-a-cluster-with-customizations
220+
- Name: Creating a ROSA cluster with STS using Terraform
221+
Dir: terraform
222+
Distros: openshift-rosa
223+
Topics:
224+
- Name: Creating a default ROSA Classic cluster using Terraform
225+
File: rosa-sts-creating-a-cluster-quickly-terraform
226+
# - Name: Customizing a ROSA cluster with Terraform
227+
# File: rosa-sts-creating-a-cluster-with-customizations-terraform
222228
- Name: Interactive cluster creation mode reference
223229
File: rosa-sts-interactive-mode-reference
224230
- Name: Creating an AWS PrivateLink cluster on ROSA
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * rosa_install_access_delete_clusters/rosa-sts-creating-a-cluster-with-customizations-terraform.adoc
4+
//
5+
ifeval::["{context}" == "rosa-sts-creating-a-cluster-quickly-terraform"]
6+
:tf-defaults:
7+
endif::[]
8+
:_content-type: PROCEDURE
9+
[id="rosa-cluster-cluster-role-name-change_{context}"]
10+
= Changing your cluster and role prefix name
11+
:source-highlighter: coderay
12+
13+
By default, the Terraform files used in this guide create a cluster that uses the naming convention of `rosa-` with six-random letters or numbers. This Terraform plan uses your cluster name to create your account role and Operator role prefixes.
14+
15+
.Sample code
16+
[source,terminal]
17+
----
18+
# If cluster_name is not null, use that, otherwise generate a random cluster name
19+
cluster_name = coalesce(var.cluster_name, "rosa-${random_string.random_name.result}")
20+
----
21+
22+
This code snippet from the `main.tf` file shows that if you set a name for the `cluster_name` variable, that value will be used instead of a randomly-generated string.
23+
24+
.Procedure
25+
26+
You can set the cluster name three different ways:
27+
28+
. You export the name of your cluster in the command line by running the following command:
29+
+
30+
[source,terminal]
31+
----
32+
$ export TF_VAR_cluster_name=<your_cluster_name>
33+
----
34+
+
35+
After exporting this variable, you can build your Terraform cluster by running the following command:
36+
+
37+
[source,terminal]
38+
----
39+
$ terraform init && terraform apply
40+
----
41+
42+
. You set a `cluster_name` value in the `terraform.tfvars` file:
43+
+
44+
[source,console]
45+
----
46+
###############################
47+
# General Cluster Information #
48+
###############################
49+
50+
# You can choose any OpenShift version that is currently supported. Make sure to use X.Y.Z when setting your version.
51+
rosa_openshift_version = "4.14.8"
52+
cluster_name = "test-tf"
53+
----
54+
+
55+
After setting this variable in the `terraform.tfvars` file, you can build your Terraform cluster by running the following command:
56+
+
57+
[source,terminal]
58+
----
59+
$ terraform init && terraform apply
60+
----
61+
62+
. You enter the cluster name when prompted in the terminal:
63+
+
64+
[source,terraform]
65+
----
66+
FORTHCOMING
67+
----
68+
69+
ifeval::["{context}" == "rosa-sts-creating-a-cluster-quickly-terraform"]
70+
:tf-defaults:
71+
endif::[]

modules/rosa-sts-cluster-terraform-destroy.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,5 @@ I: Fetching operator roles
105105
I: No operator roles available
106106
----
107107
ifeval::["{context}" == "rosa-sts-creating-a-cluster-quickly-terraform"]
108-
:!tf-defaults:
108+
:tf-defaults:
109109
endif::[]
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * rosa_install_access_delete_clusters/rosa-sts-creating-a-cluster-quickly-terraform.adoc
4+
//
5+
ifeval::["{context}" == "rosa-sts-creating-a-cluster-quickly-terraform"]
6+
:tf-defaults:
7+
endif::[]
8+
:_content-type: PROCEDURE
9+
10+
[id="rosa-sts-cluster-terraform-execute_{context}"]
11+
= Using Terraform to create your ROSA cluster
12+
13+
After you create the Terraform files, you must initiate Terraform to provide all of the required dependencies. Then apply the Terraform plan.
14+
15+
.Procedure
16+
17+
. Set up Terraform to create your resources based on your Terraform files, run the following command:
18+
+
19+
[source,terminal]
20+
----
21+
$ terraform init
22+
----
23+
24+
. *Optional*: Verify that the Terraform you copied is correct by running the following command:
25+
+
26+
[source,terminal]
27+
----
28+
$ terraform validate
29+
----
30+
+
31+
.Example output
32+
+
33+
[source,terminal]
34+
----
35+
Success! The configuration is valid.
36+
----
37+
38+
. Create your cluster with Terraform by running the following command:
39+
+
40+
[source,terminal]
41+
----
42+
$ terraform apply
43+
----
44+
45+
. The Terraform interface lists the resources to be created or changed and prompts for confirmation. Enter `yes` to proceed or `no` to cancel:
46+
+
47+
.Example output
48+
[source,terminal]
49+
----
50+
Plan: 39 to add, 0 to change, 0 to destroy.
51+
52+
Do you want to perform these actions?
53+
Terraform will perform the actions described above.
54+
Only 'yes' will be accepted to approve.
55+
56+
Enter a value: yes
57+
----
58+
+
59+
If you enter `yes`, your Terraform plan starts, creating your AWS account roles, Operator roles, and your ROSA Classic cluster.
60+
61+
.Verification
62+
. Verify that your cluster was created by running the following command:
63+
+
64+
[source,terminal]
65+
----
66+
$ rosa list clusters
67+
----
68+
+
69+
.Example output showing a cluster's ID, name, and status:
70+
+
71+
[source,terminal]
72+
----
73+
ID NAME STATE TOPOLOGY
74+
27c3snjsupa9obua74ba8se5kcj11269 rosa-tf-demo ready Classic (STS)
75+
----
76+
77+
. Verify that your account roles were created by running the following command:
78+
+
79+
[source,terminal]
80+
----
81+
$ rosa list account-roles
82+
----
83+
+
84+
.Example output
85+
[source,terminal]
86+
----
87+
I: Fetching account roles
88+
ROLE NAME ROLE TYPE ROLE ARN OPENSHIFT VERSION AWS Managed
89+
ROSA-demo-ControlPlane-Role Control plane arn:aws:iam::<ID>:role/ROSA-demo-ControlPlane-Role 4.14 No
90+
ROSA-demo-Installer-Role Installer arn:aws:iam::<ID>:role/ROSA-demo-Installer-Role 4.14 No
91+
ROSA-demo-Support-Role Support arn:aws:iam::<ID>:role/ROSA-demo-Support-Role 4.14 No
92+
ROSA-demo-Worker-Role Worker arn:aws:iam::<ID>:role/ROSA-demo-Worker-Role 4.14 No
93+
----
94+
95+
. Verify that your Operator roles were created by running the following command:
96+
+
97+
[source,terminal]
98+
----
99+
$ rosa list operator-roles
100+
----
101+
+
102+
.Example output showing Terraform-created Operator roles:
103+
[source,terminal]
104+
----
105+
I: Fetching operator roles
106+
ROLE PREFIX AMOUNT IN BUNDLE
107+
rosa-demo 6
108+
----
109+
110+
ifeval::["{context}" == "rosa-sts-creating-a-cluster-quickly-terraform"]
111+
:tf-defaults:
112+
endif::[]

0 commit comments

Comments
 (0)