|
| 1 | +# Private Zero Egress ROSA HCP |
| 2 | + |
| 3 | +## Introduction |
| 4 | + |
| 5 | +This is a Terraform manifest example for creating a Red Hat OpenShift Service on AWS (ROSA) Hosted Control Plane (HCP) cluster. This example provides a structured configuration template that demonstrates how to deploy a ROSA cluster within your AWS environment by using Terraform. |
| 6 | + |
| 7 | +This example includes: |
| 8 | +- A Zero Egress ROSA cluster with private access. |
| 9 | +- All AWS resources (IAM and networking) that are created as part of the ROSA cluster module execution. |
| 10 | +- A bastion host EC2 instance that allows to reach the private cluster. |
| 11 | + |
| 12 | +## Example Usage |
| 13 | + |
| 14 | +``` |
| 15 | +############################ |
| 16 | +# Cluster |
| 17 | +############################ |
| 18 | +module "hcp" { |
| 19 | + source = "terraform-redhat/rosa-hcp/rhcs" |
| 20 | +
|
| 21 | + cluster_name = "my-cluster" |
| 22 | + openshift_version = "4.14.24" |
| 23 | + machine_cidr = module.vpc.cidr_block |
| 24 | + aws_subnet_ids = module.vpc.private_subnets |
| 25 | + aws_availability_zones = module.vpc.availability_zones |
| 26 | + replicas = 2 |
| 27 | + private = true |
| 28 | + create_admin_user = true |
| 29 | + admin_credentials_username = "admin" |
| 30 | + admin_credentials_password = random_password.password.result |
| 31 | +
|
| 32 | + // STS configuration |
| 33 | + create_account_roles = true |
| 34 | + account_role_prefix = "my-cluster-account" |
| 35 | + create_oidc = true |
| 36 | + create_operator_roles = true |
| 37 | + operator_role_prefix = "my-cluster-operator" |
| 38 | + is_zero_ingress = true |
| 39 | +} |
| 40 | +
|
| 41 | +resource "random_password" "password" { |
| 42 | + length = 14 |
| 43 | + special = true |
| 44 | + min_lower = 1 |
| 45 | + min_numeric = 1 |
| 46 | + min_special = 1 |
| 47 | + min_upper = 1 |
| 48 | +} |
| 49 | +
|
| 50 | +############################ |
| 51 | +# VPC |
| 52 | +############################ |
| 53 | +module "vpc" { |
| 54 | + source = "terraform-redhat/rosa-hcp/rhcs//modules/vpc" |
| 55 | +
|
| 56 | + name_prefix = "my-vpc" |
| 57 | + availability_zones_count = 1 |
| 58 | + is_zero_ingress = true |
| 59 | +} |
| 60 | +
|
| 61 | +############################ |
| 62 | +# Bastion instance for connection to the cluster |
| 63 | +############################ |
| 64 | +data "aws_ami" "rhel9" { |
| 65 | + most_recent = true |
| 66 | +
|
| 67 | + filter { |
| 68 | + name = "platform-details" |
| 69 | + values = ["Red Hat Enterprise Linux"] |
| 70 | + } |
| 71 | +
|
| 72 | + filter { |
| 73 | + name = "architecture" |
| 74 | + values = ["x86_64"] |
| 75 | + } |
| 76 | +
|
| 77 | + filter { |
| 78 | + name = "root-device-type" |
| 79 | + values = ["ebs"] |
| 80 | + } |
| 81 | +
|
| 82 | + filter { |
| 83 | + name = "manifest-location" |
| 84 | + values = ["amazon/RHEL-9.*_HVM-*-x86_64-*-Hourly2-GP2"] |
| 85 | + } |
| 86 | +
|
| 87 | + owners = ["309956199498"] # Amazon's "Official Red Hat" account |
| 88 | +} |
| 89 | +module "bastion_host" { |
| 90 | + source = "../../modules/bastion-host" |
| 91 | + prefix = "my-host" |
| 92 | + vpc_id = module.vpc.vpc_id |
| 93 | + subnet_ids = [module.vpc.public_subnets[0]] |
| 94 | + ami_id = aws_ami.rhel9.id |
| 95 | + user_data_file = file("bastion-host-user-data.yaml") |
| 96 | +} |
| 97 | +``` |
| 98 | + |
| 99 | + |
| 100 | +<!-- BEGIN_AUTOMATED_TF_DOCS_BLOCK --> |
| 101 | +## Requirements |
| 102 | + |
| 103 | +| Name | Version | |
| 104 | +|------|---------| |
| 105 | +| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 | |
| 106 | +| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.35.0 | |
| 107 | +| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 | |
| 108 | +| <a name="requirement_rhcs"></a> [rhcs](#requirement\_rhcs) | >= 1.6.2 | |
| 109 | + |
| 110 | +## Providers |
| 111 | + |
| 112 | +| Name | Version | |
| 113 | +|------|---------| |
| 114 | +| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.35.0 | |
| 115 | +| <a name="provider_random"></a> [random](#provider\_random) | >= 2.0 | |
| 116 | + |
| 117 | +## Modules |
| 118 | + |
| 119 | +| Name | Source | Version | |
| 120 | +|------|--------|---------| |
| 121 | +| <a name="module_bastion_host"></a> [bastion\_host](#module\_bastion\_host) | ../../modules/bastion-host | n/a | |
| 122 | +| <a name="module_hcp"></a> [hcp](#module\_hcp) | ../../ | n/a | |
| 123 | +| <a name="module_vpc"></a> [vpc](#module\_vpc) | ../../modules/vpc | n/a | |
| 124 | + |
| 125 | +## Resources |
| 126 | + |
| 127 | +| Name | Type | |
| 128 | +|------|------| |
| 129 | +| [random_password.password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource | |
| 130 | +| [aws_ami.rhel9](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source | |
| 131 | + |
| 132 | +## Inputs |
| 133 | + |
| 134 | +| Name | Description | Type | Default | Required | |
| 135 | +|------|-------------|------|---------|:--------:| |
| 136 | +| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | n/a | `string` | n/a | yes | |
| 137 | +| <a name="input_openshift_version"></a> [openshift\_version](#input\_openshift\_version) | n/a | `string` | `"4.16.3"` | no | |
| 138 | + |
| 139 | +## Outputs |
| 140 | + |
| 141 | +| Name | Description | |
| 142 | +|------|-------------| |
| 143 | +| <a name="output_account_role_prefix"></a> [account\_role\_prefix](#output\_account\_role\_prefix) | The prefix used for all generated AWS resources. | |
| 144 | +| <a name="output_account_roles_arn"></a> [account\_roles\_arn](#output\_account\_roles\_arn) | A map of Amazon Resource Names (ARNs) associated with the AWS IAM roles created. The key in the map represents the name of an AWS IAM role, while the corresponding value represents the associated Amazon Resource Name (ARN) of that role. | |
| 145 | +| <a name="output_bastion_host_public_ip"></a> [bastion\_host\_public\_ip](#output\_bastion\_host\_public\_ip) | Bastion Host Public IP | |
| 146 | +| <a name="output_cluster_api_url"></a> [cluster\_api\_url](#output\_cluster\_api\_url) | The URL of the API server. | |
| 147 | +| <a name="output_cluster_console_url"></a> [cluster\_console\_url](#output\_cluster\_console\_url) | The URL of the console. | |
| 148 | +| <a name="output_cluster_id"></a> [cluster\_id](#output\_cluster\_id) | Unique identifier of the cluster. | |
| 149 | +| <a name="output_oidc_config_id"></a> [oidc\_config\_id](#output\_oidc\_config\_id) | The unique identifier associated with users authenticated through OpenID Connect (OIDC) generated by this OIDC config. | |
| 150 | +| <a name="output_oidc_endpoint_url"></a> [oidc\_endpoint\_url](#output\_oidc\_endpoint\_url) | Registered OIDC configuration issuer URL, generated by this OIDC config. | |
| 151 | +| <a name="output_operator_role_prefix"></a> [operator\_role\_prefix](#output\_operator\_role\_prefix) | Prefix used for generated AWS operator policies. | |
| 152 | +| <a name="output_operator_roles_arn"></a> [operator\_roles\_arn](#output\_operator\_roles\_arn) | List of Amazon Resource Names (ARNs) for all operator roles created. | |
| 153 | +| <a name="output_password"></a> [password](#output\_password) | n/a | |
| 154 | +| <a name="output_path"></a> [path](#output\_path) | The arn path for the account/operator roles as well as their policies. | |
| 155 | +<!-- END_AUTOMATED_TF_DOCS_BLOCK --> |
0 commit comments