Skip to content

Commit a36fdfc

Browse files
committed
OCM-17691 | fix: Make billing account ID optional to enable GovCloud HCP cluster creation
Before this commit, HCP clusters on ROSA GovCloud couldn't be created because the module required a value for the billing account variable, which is invalid to supply to the OCM API when creating HCP GovCloud clusters[1]. In these cases, the billing ID passed to the OCM `/clusters` API should be empty. This commit makes billing account ID optional so that users can create HCP clusters on ROSA GovCloud. This is consistent with the server side validation OCM Cluster Service applies to the billing ID, which are dynamic based on many criteria[2]. Instead of trying to replicate the server side validation in the provider, this change simply makes the field always optional and the server can perform those complex validations. [1] https://github.com/openshift/rosa/blob/master/cmd/create/cluster/cmd.go#L1268 [2] https://github.com/openshift-online/ocm-cluster-service/blob/main/cmd/clusters-service/service/cluster_service.go
1 parent 8bc5241 commit a36fdfc

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

docs/resources/cluster_rosa_hcp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ resource "rhcs_cluster_rosa_hcp" "rosa_sts_cluster" {
5151

5252
- `availability_zones` (List of String) Availability zones. This attribute specifically applies to the Worker Machine Pool and becomes irrelevant once the resource is created. Any modifications to the initial Machine Pool should be made through the Terraform imported Machine Pool resource. For more details, refer to [Worker Machine Pool in ROSA Cluster](../guides/worker-machine-pool.md)
5353
- `aws_account_id` (String) Identifier of the AWS account. After the creation of the resource, it is not possible to update the attribute value.
54-
- `aws_billing_account_id` (String) Identifier of the AWS account for billing. After the creation of the resource, it is not possible to update the attribute value.
5554
- `aws_subnet_ids` (List of String) AWS subnet IDs. After the creation of the resource, it is not possible to update the attribute value.
5655
- `cloud_region` (String) AWS region identifier, for example 'us-east-1'.
5756
- `name` (String) Name of the cluster. Cannot exceed 54 characters in length. After the creation of the resource, it is not possible to update the attribute value.
@@ -62,6 +61,7 @@ resource "rhcs_cluster_rosa_hcp" "rosa_sts_cluster" {
6261
- `admin_credentials` (Attributes) Admin user credentials. After the creation of the resource, it is not possible to update the attribute value. (see [below for nested schema](#nestedatt--admin_credentials))
6362
- `aws_additional_allowed_principals` (List of String) AWS additional allowed principals.
6463
- `aws_additional_compute_security_group_ids` (List of String) AWS additional compute security group ids.
64+
- `aws_billing_account_id` (String) Identifier of the AWS account for billing. After the creation of the resource, it is not possible to update the attribute value.
6565
- `base_dns_domain` (String) Base DNS domain name previously reserved, e.g. '1vo8.p3.openshiftapps.com'. After the creation of the resource, it is not possible to update the attribute value.
6666
- `channel_group` (String) Name of the channel group where you select the OpenShift cluster version, for example 'stable'. For ROSA, only 'stable' is supported. After the creation of the resource, it is not possible to update the attribute value.
6767
- `compute_machine_type` (String) Identifies the machine type used by the initial worker nodes, for example `m5.xlarge`. Use the `rhcs_machine_types` data source to find the possible values. This attribute specifically applies to the Worker Machine Pool and becomes irrelevant once the resource is created. Any modifications to the initial Machine Pool should be made through the Terraform imported Machine Pool resource. For more details, refer to [Worker Machine Pool in ROSA Cluster](../guides/worker-machine-pool.md)

internal/ocm/resource/cluster.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ func (c *Cluster) CreateAWSBuilder(clusterTopology rosaTypes.ClusterTopology,
181181
if err != nil {
182182
return err
183183
}
184-
awsBuilder.BillingAccountID(*awsBillingAccountId)
184+
if awsBillingAccountId != nil {
185+
awsBuilder.BillingAccountID(*awsBillingAccountId)
186+
}
185187
}
186188

187189
if awsAccountID != nil {

provider/clusterrosa/hcp/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func (r *ClusterRosaHcpResource) Schema(ctx context.Context, req resource.Schema
209209
},
210210
"aws_billing_account_id": schema.StringAttribute{
211211
Description: "Identifier of the AWS account for billing. " + common.ValueCannotBeChangedStringDescription,
212-
Required: true,
212+
Optional: true,
213213
Validators: []validator.String{
214214
stringvalidator.RegexMatches(regexp.MustCompile(`^\d{12}$`), "aws billing account ID must be only digits and exactly 12 in length"),
215215
},

0 commit comments

Comments
 (0)