### High Availability Mirror Configuration Example Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/examples/image_mirrors/multiple_mirrors/README.md Example demonstrating a high availability setup for Redis mirrors, specifying primary, secondary, and tertiary fallback options. ```hcl "docker.io/library/redis" = [ "quay.io/my-org/redis", # Primary "registry.example.com/redis", # Secondary "docker.io/backup/redis" # Tertiary ] ``` -------------------------------- ### Complete Example: Create HCP Cluster and Configure Image Mirrors Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/guides/image-mirrors.md This example demonstrates the complete setup, including creating a ROSA HCP cluster using `rhcs_cluster_rosa_hcp` and subsequently configuring image mirrors for Nginx and Redis using `rhcs_image_mirror` resources. It includes provider configuration and local variables for STS roles. ```terraform terraform { required_providers { rhcs = { version = ">= 1.1.0" source = "terraform-redhat/rhcs" } } } locals { sts_roles = { role_arn = "arn:aws:iam::123456789012:role/my-HCP-ROSA-Installer-Role" support_role_arn = "arn:aws:iam::123456789012:role/my-HCP-ROSA-Support-Role" instance_iam_roles = { worker_role_arn = "arn:aws:iam::123456789012:role/my-HCP-ROSA-Worker-Role" } operator_role_prefix = "my-operator" oidc_config_id = "my-oidc-config-id" } } # Create HCP cluster resource "rhcs_cluster_rosa_hcp" "example_cluster" { name = "example-hcp-cluster" cloud_region = "us-east-1" aws_account_id = "123456789012" aws_billing_account_id = "123456789012" aws_subnet_ids = ["subnet-123", "subnet-456"] availability_zones = ["us-east-1a", "us-east-1b"] replicas = 2 version = "4.15.9" sts = local.sts_roles wait_for_create_complete = true wait_for_std_compute_nodes_complete = true } # Configure image mirrors after cluster creation resource "rhcs_image_mirror" "nginx_mirror" { cluster_id = rhcs_cluster_rosa_hcp.example_cluster.id source = "docker.io/library/nginx" mirrors = ["quay.io/my-org/nginx"] depends_on = [rhcs_cluster_rosa_hcp.example_cluster] } resource "rhcs_image_mirror" "redis_mirror" { cluster_id = rhcs_cluster_rosa_hcp.example_cluster.id source = "docker.io/library/redis" mirrors = [ "registry.example.com/redis", "quay.io/backup/redis" ] depends_on = [rhcs_cluster_rosa_hcp.example_cluster] } ``` -------------------------------- ### Example Output of Image Mirror Configuration Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/examples/image_mirrors/basic/README.md This is an example of the output you can expect after applying the image mirror configuration. ```hcl image_mirror_id = "mirror-123456" image_mirror_source = "docker.io/library/nginx" image_mirror_mirrors = ["quay.io/my-org/nginx"] image_mirror_type = "digest" creation_timestamp = "2024-01-15T10:30:00Z" last_update_timestamp = "2024-01-15T10:30:00Z" ``` -------------------------------- ### Corporate Registry Mirror Configuration Example Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/examples/image_mirrors/multiple_mirrors/README.md Example showing how to configure mirrors for a corporate registry environment, mapping various source images to corporate mirror locations. ```hcl registry_mirrors = { "docker.io/library/nginx" = ["registry.corp.example.com/docker/nginx"] "docker.io/library/postgres" = ["registry.corp.example.com/docker/postgres"] "quay.io/prometheus/prometheus" = ["registry.corp.example.com/quay/prometheus"] "registry.redhat.io/ubi8/ubi" = ["registry.corp.example.com/redhat/ubi8"] } ``` -------------------------------- ### Example: Create Account Roles Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/README.md This example demonstrates how to create account roles using Terraform. It is located in the `examples/create_account_roles/` directory. ```terraform # Example Terraform configuration for creating account roles # See examples/create_account_roles/README.md for more details. ``` -------------------------------- ### Basic DNS Domain Resource Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/resources/dns_domain.md This is a basic example of how to declare a DNS domain resource. No specific configuration is required for a minimal setup. ```terraform resource "rhcs_dns_domain" "dns_domain" {} ``` -------------------------------- ### Example KubeletConfig Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/resources/kubeletconfig.md This example demonstrates how to create a KubeletConfig resource with a specified cluster ID and pod PID limit. Ensure the cluster ID is valid for your RHCS environment. ```terraform resource "rhcs_kubeletconfig" "example_kubeletconfig" { cluster = "cluster-id-123" pod_pids_limit = 10000 } ``` -------------------------------- ### Example Usage of rhcs_hcp_policies Data Source Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/data-sources/hcp_policies.md This example demonstrates how to use the `rhcs_hcp_policies` data source to fetch all available operator and account role policies. No additional setup is required beyond having the provider configured. ```terraform data "rhcs_hcp_policies" "all_policies" {} ``` -------------------------------- ### Example Account Roles Output Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/examples/create_account_roles/README.md This is an example of the output you will see when verifying account roles using the 'rosa list account-roles' command. ```text I: Fetching account roles ROLE NAME ROLE TYPE ROLE ARN OPENSHIFT VERSION AWS Managed ManagedOpenShift-ControlPlane-Role Control plane arn:aws:iam::XXXXX:role/ManagedOpenShift-ControlPlane-Role 4.13 No ManagedOpenShift-Installer-Role Installer arn:aws:iam::XXXXX:role/ManagedOpenShift-Installer-Role 4.13 No ManagedOpenShift-Support-Role Support arn:aws:iam::XXXXX:role/ManagedOpenShift-Support-Role 4.13 No ManagedOpenShift-Worker-Role Worker arn:aws:iam::XXXXX:role/ManagedOpenShift-Worker-Role 4.13 No ``` -------------------------------- ### Example Terraform .tfvars File Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/guides/terraform-vars.md This example demonstrates a basic .tfvars file structure for defining account-wide roles and cluster creation variables. It can be extended to include variables for identity providers and machine pools. Remember to replace placeholder values with your specific configuration details. ```terraform account_role_prefix = "" availability_zones = [""] cloud_region = "" cluster_name = "" operator_role_prefix = " token = "" url = " ### Nested Schema for `autoscaling` Read-Only: - `enabled` (Boolean) Enables autoscaling. If `true`, this variable requires you to set a maximum and minimum replicas range using the `max_replicas` and `min_replicas` variables. - `max_replicas` (Number) The maximum number of replicas for autoscaling functionality. - `min_replicas` (Number) The minimum number of replicas for autoscaling functionality. ``` -------------------------------- ### Provide Installer Role ARN for Unmanaged Provider Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/examples/create_rosa_sts_cluster/oidc_configuration/oidc_provider/README.md For unmanaged provider configurations, set the TF_VAR_installer_role_arn environment variable with the ARN of the installer role. ```bash export TF_VAR_installer_role_arn=... ``` -------------------------------- ### Example Terraform Output for Created Mirrors Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/examples/image_mirrors/multiple_mirrors/README.md Illustrates the expected output after applying the Terraform configuration, showing details of created image mirrors and their configurations. ```json created_mirrors = { "docker.io/library/nginx" = { id = "mirror-nginx-123" mirrors = ["quay.io/my-org/nginx", "registry.example.com/nginx"] source = "docker.io/library/nginx" type = "digest" } "docker.io/library/redis" = { id = "mirror-redis-456" mirrors = ["quay.io/my-org/redis", "registry.example.com/redis"] source = "docker.io/library/redis" type = "digest" } } mirror_count = 4 sources_configured = [ "docker.io/library/nginx", "docker.io/library/redis", "docker.io/library/postgres", "quay.io/prometheus/prometheus" ] ``` -------------------------------- ### Google Identity Provider Configuration Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/resources/identity_provider.md Example of configuring a Google identity provider for a cluster. This method uses Google OAuth for authentication. ```APIDOC ## Create Google Identity Provider ### Description Configures a Google identity provider for a cluster, enabling authentication via Google OAuth. ### Method Resource Creation (Terraform) ### Endpoint N/A (Terraform Resource) ### Parameters #### Required - `cluster` (String) - Identifier of the cluster. - `name` (String) - Name of the identity provider (e.g., "google"). - `google` (Attributes) - Details of the Google identity provider. - `client_id` (String) - Client identifier of a registered Google OAuth application. - `client_secret` (String, Sensitive) - Client secret issued by Google. #### Optional - `google.hosted_domain` (String) - Restrict users to a Google Apps domain. ### Request Example ```terraform resource "ocm_identity_provider" "google_idp" { cluster = "cluster-id-123" name = "google" google = { client_id = "" client_secret = "" hosted_domain = "" } } ``` ### Response #### Success Response (200) - `id` (String) - Unique identifier of the identity provider. #### Response Example N/A (Terraform Resource Output) ``` -------------------------------- ### OpenID Identity Provider Configuration Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/resources/identity_provider.md Example of configuring an OpenID Connect identity provider for a cluster. This method uses OpenID Connect for authentication. ```APIDOC ## Create OpenID Identity Provider ### Description Configures an OpenID Connect identity provider for a cluster, enabling authentication via OpenID Connect. ### Method Resource Creation (Terraform) ### Endpoint N/A (Terraform Resource) ### Parameters #### Required - `cluster` (String) - Identifier of the cluster. - `name` (String) - Name of the identity provider (e.g., "OpenID"). - `openid` (Attributes) - Details of the OpenID identity provider. - `client_id` (String) - Client ID for the OpenID Connect provider. - `client_secret` (String, Sensitive) - Client Secret for the OpenID Connect provider. - `issuer` (String) - The issuer URL of the OpenID Connect provider. #### Optional - `openid.ca` (String) - Path to PEM-encoded certificate file to use for secure OpenID Connect connections. - `openid.claims` (String) - Custom claims to be included in the OpenID Connect token. ### Request Example ```terraform resource "rhcs_identity_provider" "openid_idp" { cluster = "cluster-id-123" name = "OpenID" openid = { client_id = "" client_secret = "" issuer = "" ca = "" claims = "" } } ``` ### Response #### Success Response (200) - `id` (String) - Unique identifier of the identity provider. #### Response Example N/A (Terraform Resource Output) ``` -------------------------------- ### Example Usage of rhcs_policies Data Source Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/data-sources/policies.md Use this data source to fetch all available operator and account role policies for ROSA. No specific configuration is required to list the policies. ```terraform data "rhcs_policies" "all_policies" {} ``` -------------------------------- ### Terraform Initialization and Application Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/examples/image_mirrors/basic/README.md Initialize Terraform, plan the changes, and apply the configuration to create the image mirror. ```bash terraform init ``` ```bash terraform plan ``` ```bash terraform apply ``` -------------------------------- ### Build the Provider Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/CONTRIBUTING.md Compile the provider plugin. Ensure you have the correct Go version and GOPATH set up. ```shell make build ``` -------------------------------- ### Get RHCS Account Information Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/data-sources/info.md Use this data source to fetch details such as account email, ID, name, username, OCM API URL, AWS account ID, and organization details. No additional setup is required beyond having the provider configured. ```terraform data "rhcs_info" "info" {} ``` -------------------------------- ### Initialize Terraform Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/examples/create_identity_provider/gitlab/README.md Run this command in your local 'gitlab' Terraform directory to download all necessary provider plugins and modules required for your plan. ```bash terraform init ``` -------------------------------- ### rhcs_cluster_rosa_hcp Data Source Example Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/data-sources/cluster_rosa_hcp.md Example usage of the rhcs_cluster_rosa_hcp data source to retrieve cluster information. ```APIDOC ## Data Source: rhcs_cluster_rosa_hcp ### Description OpenShift managed cluster using rosa sts. ### Schema #### Required - `id` (String) Unique identifier of the cluster. #### Optional - `domain_prefix` (String) The domain prefix is optionally assigned by the user. It will appear in the Cluster's domain when the cluster is provisioned. If not supplied, it will be auto generated. After the creation of the resource, it is not possible to update the attribute value. - `kms_key_arn` (String) Used to encrypt root volume of compute node pools. The key ARN is the Amazon Resource Name (ARN) of a AWS Key Management Service (KMS) Key. It is a unique, fully qualified identifier for the AWS KMS Key. A key ARN includes the AWS account, Region, and the key ID (optional). After the creation of the resource, it is not possible to update the attribute value. - `registry_config` (Attributes) Registry configuration for this cluster. (see [below for nested schema](#nestedatt--registry_config)) ### Example Usage ```terraform data "rhcs_cluster_rosa_hcp" "cluster" { id = "cluster-id-123" } ``` ### FIPS status verification Use the `fips` attribute from this data source to confirm whether FIPS was enabled when the HCP cluster was created. `fips` is read-only here and reflects the cluster state returned by OCM. ``` -------------------------------- ### Apply Terraform Configuration Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/examples/create_identity_provider/google/README.md Run 'terraform apply' to create the Google identity provider. If a plan file was generated, specify it; otherwise, Terraform will create resources directly. Confirm with 'yes' when prompted. ```bash terraform apply <"google.tfplan"> ``` -------------------------------- ### Test Local Provider Binary with Podman Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/README.md Pull the latest `rhcs-tf-bin` container image and extract the provider binary to your local system. This allows testing without a full build from sources. ```bash podman run --pull=always --rm registry.ci.openshift.org/ci/rhcs-tf-bin:latest cat /root/terraform-provider-rhcs > ~/terraform-provider-rhcs && chmod +x ~/terraform-provider-rhcs ``` -------------------------------- ### Run Linter and Documentation Linter Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/CONTRIBUTING.md Execute the pinned golangci-lint configuration for code quality checks and Vale for documentation linting. ```shell make lint ``` ```shell make docs-lint ``` -------------------------------- ### Perform Basic and Pre-Push Checks Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/README.md Run `make basic-checks` for a convenience flow that includes formatting and may stop for review. Use `make pre-push-checks` for non-mutating verification used by the pre-push hook. ```shell make basic-checks ``` ```shell make pre-push-checks ``` -------------------------------- ### Apply Terraform Plan Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/examples/create_identity_provider/ldap/README.md Run this command to create your identity provider. If you did not run the plan command, you can apply without specifying a file. ```bash terraform apply <"github.tfplan"> ``` -------------------------------- ### Run Linter and Documentation Linter Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/README.md Execute `make lint` to run the pinned golangci-lint configuration used by CI. Use `make docs-lint` to run Vale for inclusive-language rules. ```shell make lint ``` ```shell make docs-lint ``` -------------------------------- ### rhcs_cluster_wait Resource Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/resources/cluster_wait.md Example usage of the rhcs_cluster_wait resource to wait for a cluster to be ready. ```APIDOC ## rhcs_cluster_wait (Resource) ### Description Wait Cluster Resource To be Ready ### Schema #### Required - `cluster` (String) Identifier of the cluster. #### Optional - `timeout` (Number) An optional timeout until the cluster is ready. The timeout value is set in minutes. The default value is 60 minutes. #### Read-Only - `ready` (Boolean) Whether the cluster is ready. Note: this does not account for cluster operators still progressing to completion. ### Example Usage ```terraform resource "rhcs_cluster_wait" "waiter" { cluster = "cluster-id-123" # timeout in minutes timeout = 60 } ``` ``` -------------------------------- ### rhcs_rosa_oidc_config Resource Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/resources/rosa_oidc_config.md Manages OIDC config. This resource can be configured for both managed and unmanaged OIDC setups. ```APIDOC ## rhcs_rosa_oidc_config Resource ### Description Manages OIDC config. This resource can be configured for both managed and unmanaged OIDC setups. ### Schema #### Required - `managed` (Boolean) Indicates whether it is a Red Hat managed or unmanaged (Customer hosted) OIDC configuration, for the cluster's OIDC provider. #### Optional - `installer_role_arn` (String) AWS STS Role ARN for cluster install (with get-secrets permission in the attached policy) - `issuer_url` (String) The bucket/issuer URL - `secret_arn` (String) Indicates for unmanaged OIDC config, the secret ARN #### Read-Only - `id` (String) The OIDC config ID - `oidc_endpoint_url` (String) OIDC Endpoint URL - `thumbprint` (String) SHA1-hash value of the root CA of the issuer URL ### Example Usage ```terraform # example for unmanaged oidc resource "rhcs_rosa_oidc_config" "oidc_config" { managed = false secret_arn = "" issuer_url = "" installer_role_arn = "" } # example for managed oidc resource "rhcs_rosa_oidc_config" "oidc_config" { managed = true } ``` ``` -------------------------------- ### Planning Terraform Apply Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/examples/create_machine_pool/README.md Optionally, run the `plan` command to preview the resources Terraform will create without making any changes to your infrastructure. This helps verify your configuration. ```bash terraform plan -out machine-pool.tfplan ``` -------------------------------- ### rhcs_machine_pool Data Source Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/data-sources/machine_pool.md Example usage of the `rhcs_machine_pool` data source to fetch machine pool details. ```APIDOC ## Data Source: rhcs_machine_pool ### Description Machine pool. ### Usage ```terraform data "rhcs_machine_pool" "machine_pool" { cluster = "cluster-id-123" id = "my-pool" } ``` ### Schema #### Required - `cluster` (String) Identifier of the cluster of the machine pool. - `id` (String) Unique identifier of the machine pool. #### Read-Only - `autoscaling_enabled` (Boolean) Specifies whether auto-scaling is activated for this machine pool. - `availability_zone` (String) A single availability zone in which the machines of this machine pool are created. Relevant only for a single availability zone machine pool. For multiple availability zones check "availability_zones" attribute - `availability_zones` (List of String) A list of Availability Zones. Relevant only for multiple availability zones machine pool. For single availability zone check "availability_zone" attribute. - `aws_additional_security_group_ids` (List of String) AWS additional security group ids. - `disk_size` (Number) The root disk size, in GiB. - `ignore_deletion_error` (Boolean) Indicates to the provider to disregard API errors when deleting the machine pool. This will remove the resource from the management file, but not necessirely delete the underlying pool in case it errors. Setting this to true can bypass issues when destroying the cluster resource alongside the pool resource in the same management file. This is not recommended to be set in other use cases - `labels` (Map of String) The list of the Labels of this machine pool. - `machine_type` (String) Identifier of the machine type used by the nodes, for example `m5.xlarge`. - `max_replicas` (Number) The maximum number of replicas for auto-scaling functionality. relevant only in case of 'autoscaling_enabled = true' - `max_spot_price` (Number) Max Spot price. - `min_replicas` (Number) The minimum number of replicas for autos-caling functionality. relevant only in case of 'autoscaling_enabled = true' - `multi_availability_zone` (Boolean) Specifies whether this machine pool is a multi-AZ machine pool. Relevant only in case of multi-AZ cluster - `name` (String) The name of the machine pool - `replicas` (Number) The machines number in the machine pool. relevant only in case of 'autoscaling_enabled = false' - `subnet_id` (String) An ID of single subnet in which the machines of this machine pool are created. Relevant only for a machine pool with single subnet. For machine pool with multiple subnets check "subnet_ids" attribute - `subnet_ids` (List of String) A list of IDs of subnets in which the machines of this machine pool are created. Relevant only for a machine pool with multiple subnets. For machine pool with single subnet check "subnet_id" attribute - `taints` (Attributes List) The list of the Taints of this machine pool. (see [below for nested schema](#nestedatt--taints)) - `use_spot_instances` (Boolean) Indicates if Amazon EC2 Spot Instances used in this machine pool. #### Nested Schema for `taints` Read-Only: - `key` (String) Taints key - `schedule_type` (String) Taints schedule type - `value` (String) Taints value ``` -------------------------------- ### Plan Terraform Apply Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/examples/create_identity_provider/google/README.md Execute 'terraform plan' to preview the changes that will be made to your infrastructure. This step is optional but recommended to ensure the configuration is correct before applying. ```bash terraform plan -out google.tfplan ``` -------------------------------- ### rhcs_cloud_providers Data Source Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/data-sources/cloud_providers.md Example usage of the `rhcs_cloud_providers` data source to fetch a list of cloud providers. ```APIDOC ## rhcs_cloud_providers (Data Source) ### Description List of cloud providers. ### Usage ```terraform data "rhcs_cloud_providers" "cloud_provider" {} ``` ### Schema #### Optional - `order` (String) - Order criteria. - `search` (String) - Search criteria. #### Read-Only - `item` (Attributes) - Content of the list when there is exactly one item. (see [below for nested schema](#nestedatt--item)) - `items` (Attributes List) - Content of the list. (see [below for nested schema](#nestedatt--items)) ### Nested Schema for `item` Read-Only: - `display_name` (String) - Human friendly name of the cloud provider, for example 'AWS' or 'GCP' - `id` (String) - Unique identifier of the cloud provider. This is what should be used when referencing the cloud provider from other places, for example in the 'cloud_provider' attribute of the cluster resource. - `name` (String) - Short name of the cloud provider, for example 'aws' or 'gcp'. ### Nested Schema for `items` Read-Only: - `display_name` (String) - Human friendly name of the cloud provider, for example 'AWS' or 'GCP' - `id` (String) - Unique identifier of the cloud provider. This is what should be used when referencing the cloud provider from other places, for example in the 'cloud_provider' attribute of the cluster resource. - `name` (String) - Short name of the cloud provider, for example 'aws' or 'gcp'. ``` -------------------------------- ### rhcs_info Data Source Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/data-sources/info.md Example usage of the rhcs_info data source to fetch account and organization information. ```APIDOC ## rhcs_info Data Source ### Description This data source retrieves information about the current OCM account and organization, such as account email, ID, name, username, OCM API URL, AWS account ID, organization external ID, organization ID, and organization name. ### Usage ```terraform data "rhcs_info" "info" {} ``` ### Schema #### Read-Only Attributes - `account_email` (String) - OCM account email - `account_id` (String) - OCM user account ID - `account_name` (String) - OCM account User full name - `account_username` (String) - OCM account username - `ocm_api` (String) - OCM API url - `ocm_aws_account_id` (String) - OCM AWS account ID - `organization_external_id` (String) - OCM account organization external id - `organization_id` (String) - OCM account organization id - `organization_name` (String) - OCM account organization name ``` -------------------------------- ### Format Go and Terraform Files Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/README.md Use these commands for formatting Go import order and syntax, as well as Terraform files. `make fmt` formats all files, while `make fmt-staged` formats only staged files. `make fmt-check` validates formatting without changing files. ```shell make fmt ``` ```shell make fmt-staged ``` ```shell make fmt-check ``` -------------------------------- ### rhcs_cluster_rosa_classic Data Source Usage Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/data-sources/cluster_rosa_classic.md Example usage of the rhcs_cluster_rosa_classic data source to retrieve information about an OpenShift cluster. ```APIDOC ## Data Source: rhcs_cluster_rosa_classic ### Description OpenShift managed cluster using rosa sts. ### Schema #### Required - `id` (String) Unique identifier of the cluster. #### Optional - `domain_prefix` (String) The domain prefix is optionally assigned by the user. It will appear in the Cluster's domain when the cluster is provisioned. If not supplied, it will be auto generated. After the creation of the resource, it is not possible to update the attribute value. - `kms_key_arn` (String) Used to encrypt root volume of compute node pools. The key ARN is the Amazon Resource Name (ARN) of a AWS Key Management Service (KMS) Key. It is a unique, fully qualified identifier for the AWS KMS Key. A key ARN includes the AWS account, Region, and the key ID (optional). After the creation of the resource, it is not possible to update the attribute value. ### Example Usage ```terraform data "rhcs_cluster_rosa_classic" "cluster" { id = "cluster-id-123" } ``` ``` -------------------------------- ### Apply Terraform Plan to Create Identity Provider Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/examples/create_identity_provider/gitlab/README.md Execute the 'apply' command to create the GitLab identity provider. If you skipped the 'plan' step, you can apply directly without specifying a file. Confirm the creation when prompted. ```bash terraform apply <"gitlab.tfplan"> ``` -------------------------------- ### rhcs_groups Data Source Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/data-sources/groups.md Example usage of the rhcs_groups data source to retrieve a list of groups for a given cluster. ```APIDOC ## rhcs_groups Data Source ### Description This data source retrieves a list of groups associated with a specific cluster. ### Usage ```terraform data "rhcs_groups" "groups" { cluster = "cluster-id-123" } ``` ### Parameters #### Required - **cluster** (String) - Identifier of the cluster. ### Read-Only Attributes - **items** (Attributes List) - Content of the list. (see [below for nested schema](#nestedatt--items)) ### Nested Schema for `items` Read-Only: - **id** (String) - Unique identifier of the group. This is what should be used when referencing the group from other places, for example in the 'group' attribute of the user resource. - **name** (String) - Short name of the group for example 'dedicated-admins'. ``` -------------------------------- ### Create rhcs_hcp_default_ingress Resource Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/resources/hcp_default_ingress.md Example of how to create a default ingress for an HCP cluster. The cluster ID and listening method are required. ```terraform resource "rhcs_hcp_default_ingress" "default_ingress" { cluster = "cluster-id-123" listening_method = "external" } ``` -------------------------------- ### RH Managed OIDC Configuration Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/guides/hosted-control-planes.md Sets up a Red Hat managed OIDC configuration for the cluster. This is the simplest OIDC setup. ```terraform resource "rhcs_rosa_oidc_config" "oidc_config" { managed = true } resource "aws_iam_openid_connect_provider" "oidc_provider" { url = "https://${rhcs_rosa_oidc_config.oidc_config.oidc_endpoint_url}" client_id_list = [ "openshift", "sts.amazonaws.com" ] tags = var.tags thumbprint_list = [rhcs_rosa_oidc_config.oidc_config.thumbprint] } data "aws_region" "current" {} resource "time_sleep" "wait_10_seconds" { create_duration = "10s" destroy_duration = "10s" triggers = { oidc_config_id = rhcs_rosa_oidc_config.oidc_config.id oidc_endpoint_url = rhcs_rosa_oidc_config.oidc_config.oidc_endpoint_url oidc_provider_url = aws_iam_openid_connect_provider.oidc_provider.url } } ``` -------------------------------- ### LDAP Identity Provider Configuration Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/resources/identity_provider.md Example of configuring an LDAP identity provider for a cluster. This method uses LDAP for user authentication. ```APIDOC ## Create LDAP Identity Provider ### Description Configures an LDAP identity provider for a cluster, enabling authentication via LDAP. ### Method Resource Creation (Terraform) ### Endpoint N/A (Terraform Resource) ### Parameters #### Required - `cluster` (String) - Identifier of the cluster. - `name` (String) - Name of the identity provider (e.g., "ldap"). - `ldap` (Attributes) - Details of the LDAP identity provider. - `url` (String) - URL of the LDAP server. - `attributes` (Attributes) - LDAP attributes configuration. #### Optional - `ldap.ca` (String) - Path to PEM-encoded certificate file to use for secure LDAP connections. - `ldap.insecure` (Boolean) - Whether to skip TLS verification for the LDAP connection. ### Request Example ```terraform resource "rhcs_identity_provider" "ldap_idp" { cluster = "cluster-id-123" name = "ldap" ldap = { url = "" attributes = {} # Optional Attributes ca = "" insecure = true } } ``` ### Response #### Success Response (200) - `id` (String) - Unique identifier of the identity provider. #### Response Example N/A (Terraform Resource Output) ``` -------------------------------- ### Run Day 1 Post and Day 2 Cases Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/tests/README.md Execute critical and high-priority tests for day 1 post-deployment and day 2 operations, excluding specific tags. ```bash ginkgo run --label-filter '(Critical,High)&&(day1-post,day2)&&!Exclude' tests/e2e ``` -------------------------------- ### Apply Terraform Configuration Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/examples/create_identity_provider/htpasswd/README.md Apply the Terraform plan to create the htpasswd identity provider. You will be prompted to confirm the creation of resources. ```bash terraform apply <"htpasswd.tfplan"> ``` -------------------------------- ### GitLab Identity Provider Configuration Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/resources/identity_provider.md Example of configuring a GitLab identity provider for a cluster. This method uses GitLab OAuth for authentication. ```APIDOC ## Create GitLab Identity Provider ### Description Configures a GitLab identity provider for a cluster, enabling authentication via GitLab OAuth. ### Method Resource Creation (Terraform) ### Endpoint N/A (Terraform Resource) ### Parameters #### Required - `cluster` (String) - Identifier of the cluster. - `name` (String) - Name of the identity provider (e.g., "GitLab"). - `gitlab` (Attributes) - Details of the Gitlab identity provider. - `client_id` (String) - Client identifier of a registered Gitlab OAuth application. - `client_secret` (String, Sensitive) - Client secret issued by Gitlab. - `url` (String) - URL of the Gitlab instance. #### Optional - `gitlab.ca` (String) - Optional trusted certificate authority bundle. ### Request Example ```terraform resource "ocm_identity_provider" "gitlab_idp" { cluster = "cluster-id-123" name = "GitLab" gitlab = { client_id = "" client_secret = "" url = "" } } ``` ### Response #### Success Response (200) - `id` (String) - Unique identifier of the identity provider. #### Response Example N/A (Terraform Resource Output) ``` -------------------------------- ### GitHub Identity Provider Configuration Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/resources/identity_provider.md Example of configuring a GitHub identity provider for a cluster. This method uses GitHub OAuth for authentication. ```APIDOC ## Create GitHub Identity Provider ### Description Configures a GitHub identity provider for a cluster, enabling authentication via GitHub OAuth. ### Method Resource Creation (Terraform) ### Endpoint N/A (Terraform Resource) ### Parameters #### Required - `cluster` (String) - Identifier of the cluster. - `name` (String) - Name of the identity provider (e.g., "Github"). - `github` (Attributes) - Details of the Github identity provider. - `client_id` (String) - Client identifier of a registered Github OAuth application. - `client_secret` (String, Sensitive) - Client secret issued by Github. #### Optional - `github.ca` (String) - Path to PEM-encoded certificate file to use when making requests to the server. - `github.hostname` (String) - Optional domain to use with a hosted instance of GitHub Enterprise. - `github.organizations` (List of String) - Only users that are members of at least one of the listed organizations will be allowed to log in. - `github.teams` (List of String) - Only users that are members of at least one of the listed teams will be allowed to log in. The format is ``/``. ### Request Example ```terraform resource "ocm_identity_provider" "github_idp" { cluster = "cluster-id-123" name = "Github" github = { client_id = "" client_secret = "" organizations = [""] } } ``` ### Response #### Success Response (200) - `id` (String) - Unique identifier of the identity provider. #### Response Example N/A (Terraform Resource Output) ``` -------------------------------- ### Customize Source and Mirrors Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/examples/image_mirrors/basic/README.md Optionally customize the source registry and mirror registries for the image mirror configuration. ```bash export TF_VAR_source_registry="docker.io/library/nginx" ``` ```bash export TF_VAR_mirrors='["quay.io/my-org/nginx"]' ``` -------------------------------- ### Apply Terraform Configuration Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/guides/machine-pool.md Run `terraform apply` to create or update machine pools based on the exported variables and Terraform configuration. ```bash terraform apply ``` -------------------------------- ### Plan Terraform Apply Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/examples/create_identity_provider/gitlab/README.md Optionally, execute the 'plan' command to verify that your Terraform configuration will build correctly without errors before applying it. ```bash terraform plan -out gitlab.tfplan ``` -------------------------------- ### htpasswd Identity Provider Configuration Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/resources/identity_provider.md Example of configuring an htpasswd identity provider for a cluster. This method uses local username and password authentication. ```APIDOC ## Create htpasswd Identity Provider ### Description Configures an htpasswd identity provider for a cluster, allowing local username and password authentication. ### Method Resource Creation (Terraform) ### Endpoint N/A (Terraform Resource) ### Parameters #### Required - `cluster` (String) - Identifier of the cluster. - `name` (String) - Name of the identity provider (e.g., "htpasswd"). - `htpasswd` (Attributes List) - Details of the 'htpasswd' identity provider. - `users` (Attributes List) - A list of htpasswd user credentials. - `username` (String) - User username. - `password` (String, Sensitive) - User password. ### Request Example ```terraform resource "rhcs_identity_provider" "htpasswd_idp" { cluster = "cluster-id-123" name = "htpasswd" htpasswd = { users = [{ username = "" password = "" }, ] } } ``` ### Response #### Success Response (200) - `id` (String) - Unique identifier of the identity provider. #### Response Example N/A (Terraform Resource Output) ``` -------------------------------- ### Plan Terraform Account Role Creation Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/examples/create_account_roles/README.md Optionally, run the plan command to verify that your Terraform files will build correctly without errors before applying them. ```bash terraform plan -out account-roles.tfplan ``` -------------------------------- ### Plan Terraform Apply Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/examples/create_identity_provider/htpasswd/README.md Create an execution plan for your Terraform configuration. This allows you to review the changes that will be made before applying them. ```bash terraform plan -out htpasswd.tfplan ``` -------------------------------- ### Example Usage of rhcs_groups Data Source Source: https://github.com/terraform-redhat/terraform-provider-rhcs/blob/main/docs/data-sources/groups.md Use this data source to retrieve a list of groups for a given cluster ID. The cluster ID is a required parameter. ```terraform data "rhcs_groups" "groups" { cluster = "cluster-id-123" } ```