Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions _topic_maps/_topic_map_rosa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ Topics:
File: rosa-mobb-verify-permissions-sts-deployment
- Name: Deploying ROSA with a Custom DNS Resolver
File: cloud-experts-custom-dns-resolver
- Name: Terraform
Dir: terraform
Distros: openshift-rosa
Topics:
- Name: Customizing your cluster with Terraform
File: cloud-experts-terraform-customization
- Name: Using AWS WAF and Amazon CloudFront to protect ROSA workloads
File: cloud-experts-using-cloudfront-and-waf
- Name: Using AWS WAF and AWS ALBs to protect ROSA workloads
Expand Down
1 change: 1 addition & 0 deletions cloud_experts_tutorials/terraform/_attributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
:_mod-docs-content-type: ASSEMBLY
[id="cloud-experts-cloud-experts-terraform-customization"]
= Tutorial: Customizing your cluster with Terraform
include::_attributes/attributes-openshift-dedicated.adoc[]
:context: cloud-experts-terraform-customization

toc::[]

You can customize your cluster with Terraform by using the following guides. This tutorial assumes that you have created your cluster using either xref:../../rosa_hcp/terraform/rosa-hcp-creating-a-cluster-quickly-terraform.adoc#rosa-hcp-creating-a-cluster-quickly-terraform[Creating a default ROSA cluster using Terraform] or xref:../../rosa_install_access_delete_clusters/terraform/rosa-classic-creating-a-cluster-quickly-terraform.adoc#rosa-classic-creating-a-cluster-quickly-terraform[Creating a default {rosa-classic} cluster using Terraform] or link:https://registry.terraform.io/providers/terraform-redhat/rhcs/latest/docs[Terraform registry documentation].

include::modules/terraform-guide-env-variables.adoc[leveloffset=+1]

include::modules/terraform-guide-autoscaling.adoc[leveloffset=+1]

include::modules/terraform-guide-private-clusters.adoc[leveloffset=+1]

[role="_additional-resources"]
[id="additional-resources_cloud-experts-terraform-customization"]
.Additional resources

* See link:https://registry.terraform.io/providers/terraform-redhat/rhcs/latest/docs[Terraform registry documentation].
1 change: 1 addition & 0 deletions cloud_experts_tutorials/terraform/images
1 change: 1 addition & 0 deletions cloud_experts_tutorials/terraform/modules
1 change: 1 addition & 0 deletions cloud_experts_tutorials/terraform/snippets
14 changes: 3 additions & 11 deletions modules/rosa-classic-cluster-terraform-file-creation.adoc
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Module included in the following assemblies:
//
// * rosa_install_access_delete_clusters/rosa-classic-creating-a-cluster-quickly-terraform.adoc

:_content-type: PROCEDURE

[id="rosa-classic-cluster-terraform-file-creation_{context}"]
= Creating your Terraform files locally

Expand Down Expand Up @@ -82,17 +80,11 @@ locals {
resource "time_sleep" "wait_60_seconds" {
count = var.create_vpc ? 1 : 0
depends_on = [module.vpc]
create_duration = "60s"
}

module "rosa-classic" {
source = "terraform-redhat/rosa-classic/rhcs"
version = "1.5.0"
cluster_name = local.cluster_name
openshift_version = var.openshift_version
Comment on lines -91 to -92

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two options are required for the module to work. Seems a bit weird to get rid of the other options as well

account_role_prefix = local.cluster_name
operator_role_prefix = local.cluster_name
replicas = local.worker_node_replicas
aws_availability_zones = local.region_azs
create_oidc = true
private = var.private_cluster
Expand Down Expand Up @@ -130,7 +122,6 @@ Copy and edit this file _before_ running the command to build your cluster.
+
[source,terminal]
----
$ cat<<-EOF>variables.tf

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part of the command is required for it to work

#
# Copyright (c) 2023 Red Hat, Inc.
#
Expand Down Expand Up @@ -200,6 +191,7 @@ variable "aws_subnet_ids" {
variable "private_cluster" {
type = bool
description = "If you want to create a private cluster, set this value to 'true'. If you want a publicly available cluster, set this value to 'false'."
default = "false"
}

#VPC Info
Expand Down Expand Up @@ -247,7 +239,7 @@ variable "default_aws_tags" {
EOF
----

. Create the `vpc.tf` file by running the following command:
. Create the vpc.tf file by running the following command:
+
[source,terminal]
----
Expand Down Expand Up @@ -289,4 +281,4 @@ module "vpc" {
EOF
----
+
You are ready to initiate Terraform.
You are ready to initiate Terraform.
6 changes: 1 addition & 5 deletions modules/rosa-hcp-cluster-terraform-file-creation.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,10 @@ locals {
# The network validator requires an additional 60 seconds to validate Terraform clusters.
resource "time_sleep" "wait_60_seconds" {
count = var.create_vpc ? 1 : 0
depends_on = [module.vpc]
create_duration = "60s"
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This curly brace is required for this to be a valid terraform file


module "rosa-hcp" {
source = "terraform-redhat/rosa-hcp/rhcs"
version = "1.6.3"
cluster_name = local.cluster_name
openshift_version = var.openshift_version

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option is required for the module to work

account_role_prefix = local.cluster_name
operator_role_prefix = local.cluster_name
replicas = local.worker_node_replicas
Expand Down Expand Up @@ -190,6 +185,7 @@ variable "aws_subnet_ids" {
variable "private_cluster" {
type = bool
description = "If you want to create a private cluster, set this value to 'true'. If you want a publicly available cluster, set this value to 'false'."
default = false
}

#VPC Info
Expand Down
11 changes: 5 additions & 6 deletions modules/rosa-sts-cluster-terraform-destroy.adoc
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// Module included in the following assemblies:
//
// * rosa_install_access_delete_clusters/rosa-classic-creating-a-cluster-quickly-terraform.adoc
//
// * rosa_hcp/terraform/rosa-hcp-creating-a-cluster-quickly-terraform.adoc
// * rosa_install_access_delete_clusters/terraform/rosa-classic-creating-a-cluster-quickly-terraform.adoc
ifeval::["{context}" == "rosa-classic-creating-a-cluster-quickly-terraform"]
:tf-defaults:
:tf-rosa-classic:
endif::[]
ifeval::["{context}" == "rosa-hcp-creating-a-cluster-quickly-terraform"]
:tf-rosa-hcp:
endif::[]
:_content-type: PROCEDURE

[id="sd-terraform-cluster-destroy_{context}"]
= Deleting your ROSA cluster with Terraform

Expand Down Expand Up @@ -115,8 +114,8 @@ I: Fetching operator roles
I: No operator roles available
----
ifeval::["{context}" == "rosa-classic-creating-a-cluster-quickly-terraform"]
:tf-defaults:
:!tf-rosa-classic:
endif::[]
ifeval::["{context}" == "rosa-hcp-creating-a-cluster-quickly-terraform"]
:tf-rosa-hcp:
:!tf-rosa-hcp:
endif::[]
15 changes: 5 additions & 10 deletions modules/rosa-sts-cluster-terraform-execute.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Module included in the following assemblies:
//
// * rosa_install_access_delete_clusters/rosa-classic-creating-a-cluster-quickly-terraform.adoc
//
// * rosa_hcp/terraform/rosa-hcp-creating-a-cluster-quickly-terraform.adoc
// * rosa_install_access_delete_clusters/terraform/rosa-classic-creating-a-cluster-quickly-terraform.adoc
ifeval::["{context}" == "rosa-classic-creating-a-cluster-quickly-terraform"]
:tf-rosa-classic:
endif::[]
Expand Down Expand Up @@ -47,19 +47,14 @@ Success! The configuration is valid.
$ terraform apply
----
+
The Terraform interface asks two questions to create your cluster, similiar to the following:
The Terraform interface asks a question to create your cluster, similiar to the following:
+
.Example output
[source,terminal]
----
var.create_vpc
If you would like to create a new VPC, set this value to 'true'. If you do not want to create a new VPC, set this value to 'false'.

Enter a value:

var.private_cluster
If you want to create a private cluster, set this value to 'true'. If you want a publicly available cluster, set this value to 'false'.

Enter a value:
----

Expand All @@ -69,7 +64,7 @@ ifdef::tf-rosa-hcp[]
.Example output
[source,terminal]
----
Plan: 63 to add, 0 to change, 0 to destroy.
Plan: 64 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
Terraform will perform the actions described above.
Expand All @@ -80,7 +75,7 @@ ifdef::tf-rosa-classic[]
.Example output
[source,terminal]
----
Plan: 74 to add, 0 to change, 0 to destroy.
Plan: 75 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
Terraform will perform the actions described above.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,8 @@ endif::tf-classic,tf-hcp[]

|Networking configuration
|
ifndef::tf-classic,tf-hcp[]
* Cluster privacy: Public
endif::tf-classic,tf-hcp[]
ifdef::tf-classic,tf-hcp[]
* Cluster privacy: public or private
* You can choose to create a new VPC during the Terraform cluster creation process.
endif::tf-classic,tf-hcp[]
ifdef::openshift-rosa[]
Expand Down
2 changes: 0 additions & 2 deletions modules/rosa-terraform-overview.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
//
// * rosa_install_access_delete_clusters/rosa-classic-creating-a-cluster-quickly-terraform.adoc
//

:_content-type: CONCEPT

[id="rosa-terraform-overview_{context}"]
= Overview of Terraform

Expand Down
13 changes: 13 additions & 0 deletions modules/terraform-guide-autoscaling.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Module included in the following assemblies:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 [error] OpenShiftAsciiDoc.ModuleContainsContentType: Module is missing the '_mod-docs-content-type' variable.

//
// * cloud_experts_tutorials/terraform/cloud-experts-terraform-customization.adoc

:_mod-docs-content-type: PROCESS
[id="terraform-guide-autoscaling_{context}"]
= Enabling autoscaling on your cluster

In your `variables.tf` file, set the default value to `true`:

[source,terminal]
----

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be empty?

----
67 changes: 67 additions & 0 deletions modules/terraform-guide-env-variables.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Module included in the following assemblies:
//
// * cloud_experts_tutorials/terraform/cloud-experts-terraform-customization.adoc

:_mod-docs-content-type: CONCEPT
[id="terraform-guide-env-variable_{context}"]
= Using environmental variables

You can use locally set variables to specify a value once and reuse that value later.

.Procedure

. Set an environment variable by running the following command:
+
[source,terminal]
----
$ export <1> = <2>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$ export <1> = <2>
$ export <1>=<2>

Spaces between the variable name and value are not supported in bash, so probably better to not include the spaces here

VARIABLE_NAME="VARIABLE_VALUE"
----
+
Your variable name and value can be any string. For example, if you want to consistently refer to your cluster's name, you run the following commad:
+
.Example input
[source,terminal]
----
$ export CLUSTER_NAME="rosa-cluster"
----

. Confirm the environment variable by running the following:
+
[source,terminal]
----
$ echo $<variable_name>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, maybe add a call out (1) here for "variable name"

----
+
.Example output
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, maybe show both example input and example output.

[source,terminal]
----
$ echo $CLUSTER_NAME
$ rosa-cluster
----

[id="terraform-guide-env-variable-table_{context}"]
== Examples of variables used for OpenShift resources
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
== Examples of variables used for OpenShift resources
== Common OpenShift resources variables


Use this table as a guideline for your own environment. The table is not a comprehensive model of all possible environment variables.

[cols="1,1"]
|===
|Example variable name| Description

|CLUSTER_NAME
|This is the text-based string that you use as the name of your cluster.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
|This is the text-based string that you use as the name of your cluster.
|Text-based string to name your cluster.


|AWS_REGION
|This is text-based string is the AWS region that you want to use for your resource.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
|This is text-based string is the AWS region that you want to use for your resource.
|Text-based string for the AWS region for your resource.


|ACCOUNT_ROLES_PREFIX
|

|
|

|===

[id="terraform-guide-env-variable-example_{context}"]
== Example workflow using environmental variables to create a ROSA cluster
19 changes: 19 additions & 0 deletions modules/terraform-guide-private-clusters.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Module included in the following assemblies:
//
// * cloud_experts_tutorials/terraform/cloud-experts-terraform-customization.adoc

ifeval::["{context}" == "cloud-experts-terraform-customization"]
:enable-vpc:
endif::[]
:_mod-docs-content-type: CONCEPT
[id="terraform-guide-private-cluster_{context}"]
= Creating a private {hcp-title} cluster

. Run the following command in your terminal to create a private {hcp-title} cluster:
+
[source,terminal]
----
$ export TF_VAR_private_cluster="true"
----

include::snippets/terraform-apply.adoc[]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:_content-type: ASSEMBLY
[id="rosa-classic-creating-a-cluster-quickly-terraform"]
= Creating a default ROSA (classic architecture) cluster using Terraform
= Creating a default {rosa-classic} cluster using Terraform
include::_attributes/attributes-openshift-dedicated.adoc[]
:context: rosa-classic-creating-a-cluster-quickly-terraform

Expand All @@ -16,9 +16,12 @@ The cluster creation process described below uses a Terraform configuration that
* All other AWS resources required to create a ROSA with STS cluster

include::modules/rosa-terraform-overview.adoc[leveloffset=+1]

include::modules/rosa-sts-terraform-prerequisites.adoc[leveloffset=+1]

[discrete]
include::modules/rosa-sts-terraform-considerations.adoc[leveloffset=+1]

include::modules/rosa-sts-overview-of-the-default-cluster-specifications.adoc[leveloffset=+1]

[id="rosa-classic-creating-a-cluster-quickly-terraform-procedure"]
Expand All @@ -27,8 +30,11 @@ include::modules/rosa-sts-overview-of-the-default-cluster-specifications.adoc[le
The cluster creation process outlined below shows how to use Terraform to create your account-wide IAM roles and a {rosa-classic} cluster with a managed OIDC configuration.

include::modules/rosa-sts-cluster-terraform-setup.adoc[leveloffset=+2]

include::modules/rosa-classic-cluster-terraform-file-creation.adoc[leveloffset=+2]

include::modules/rosa-sts-cluster-terraform-execute.adoc[leveloffset=+2]

include::modules/rosa-sts-cluster-terraform-destroy.adoc[leveloffset=+2]

[role="_additional-resources"]
Expand Down
Loading