diff --git a/docs/data-sources/cluster_rosa_hcp.md b/docs/data-sources/cluster_rosa_hcp.md index 57964420..336fce54 100644 --- a/docs/data-sources/cluster_rosa_hcp.md +++ b/docs/data-sources/cluster_rosa_hcp.md @@ -60,6 +60,7 @@ data "rhcs_cluster_rosa_hcp" "cluster" { - `max_hcp_cluster_wait_timeout_in_minutes` (Number) This attribute is not supported for cluster data source. Therefore, it will not be displayed as an output of the datasource - `max_machinepool_wait_timeout_in_minutes` (Number) This attribute is not supported for cluster data source. Therefore, it will not be displayed as an output of the datasource - `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. +- `no_cni` (Boolean) Disable CNI creation to let users bring their own CNI. After the creation of the resource, it is not possible to update the attribute value. - `ocm_properties` (Map of String) Merged properties defined by OCM and the user defined 'properties'. - `pod_cidr` (String) Block of IP addresses for pods. After the creation of the resource, it is not possible to update the attribute value. - `private` (Boolean) Provides private connectivity from your cluster's VPC to Red Hat SRE, without exposing traffic to the public internet. After the creation of the resource, it is not possible to update the attribute value. diff --git a/docs/resources/cluster_rosa_hcp.md b/docs/resources/cluster_rosa_hcp.md index a87507a5..af179180 100644 --- a/docs/resources/cluster_rosa_hcp.md +++ b/docs/resources/cluster_rosa_hcp.md @@ -77,6 +77,7 @@ resource "rhcs_cluster_rosa_hcp" "rosa_sts_cluster" { - `machine_cidr` (String) Block of IP addresses for nodes. After the creation of the resource, it is not possible to update the attribute value. - `max_hcp_cluster_wait_timeout_in_minutes` (Number) This value sets the maximum duration in minutes to wait for a HCP cluster to be in a ready state. - `max_machinepool_wait_timeout_in_minutes` (Number) This value sets the maximum duration in minutes to wait for machine pools to be in a ready state. +- `no_cni` (Boolean) Disable CNI creation to let users bring their own CNI. After the creation of the resource, it is not possible to update the attribute value. - `pod_cidr` (String) Block of IP addresses for pods. After the creation of the resource, it is not possible to update the attribute value. - `private` (Boolean) Provides private connectivity from your cluster's VPC to Red Hat SRE, without exposing traffic to the public internet. After the creation of the resource, it is not possible to update the attribute value. - `properties` (Map of String) User defined properties. It is essential to include property 'role_creator_arn' with the value of the user creating the cluster. Example: properties = {rosa_creator_arn = data.aws_caller_identity.current.arn} diff --git a/provider/clusterrosa/hcp/datasource.go b/provider/clusterrosa/hcp/datasource.go index 979b829c..33a427e8 100644 --- a/provider/clusterrosa/hcp/datasource.go +++ b/provider/clusterrosa/hcp/datasource.go @@ -191,6 +191,10 @@ func (r *ClusterRosaHcpDatasource) Schema(ctx context.Context, req datasource.Sc Description: "Length of the prefix of the subnet assigned to each node. " + common.ValueCannotBeChangedStringDescription, Computed: true, }, + "no_cni": schema.BoolAttribute{ + Description: "Disable CNI creation to let users bring their own CNI. " + common.ValueCannotBeChangedStringDescription, + Computed: true, + }, "channel_group": schema.StringAttribute{ Description: deprecatedMessage, Computed: true, diff --git a/provider/clusterrosa/hcp/resource.go b/provider/clusterrosa/hcp/resource.go index 9b721bd2..85235559 100644 --- a/provider/clusterrosa/hcp/resource.go +++ b/provider/clusterrosa/hcp/resource.go @@ -287,6 +287,14 @@ func (r *ClusterRosaHcpResource) Schema(ctx context.Context, req resource.Schema int64planmodifier.UseStateForUnknown(), }, }, + "no_cni": schema.BoolAttribute{ + Description: "Disable CNI creation to let users bring their own CNI. " + common.ValueCannotBeChangedStringDescription, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Bool{ + boolplanmodifier.UseStateForUnknown(), + }, + }, "channel_group": schema.StringAttribute{ Description: "Name of the channel group where you select the OpenShift cluster version, for example 'stable'. " + "For ROSA, only 'stable' is supported. " + common.ValueCannotBeChangedStringDescription, @@ -621,6 +629,9 @@ func createHcpClusterObject(ctx context.Context, if common.HasValue(state.HostPrefix) { network.HostPrefix(int(state.HostPrefix.ValueInt64())) } + if common.BoolWithFalseDefault(state.NoCNI) { + network.Type("Other") + } if !network.Empty() { builder.Network(network) } @@ -949,6 +960,7 @@ func validateNoImmutableAttChange(state, plan *ClusterRosaHcpState) diag.Diagnos common.ValidateStateAndPlanEquals(state.ServiceCIDR, plan.ServiceCIDR, "service_cidr", &diags) common.ValidateStateAndPlanEquals(state.PodCIDR, plan.PodCIDR, "pod_cidr", &diags) common.ValidateStateAndPlanEquals(state.HostPrefix, plan.HostPrefix, "host_prefix", &diags) + common.ValidateStateAndPlanEquals(state.NoCNI, plan.NoCNI, "no_cni", &diags) common.ValidateStateAndPlanEquals(state.ChannelGroup, plan.ChannelGroup, "channel_group", &diags) // STS field validations @@ -1603,6 +1615,12 @@ func populateRosaHcpClusterState(ctx context.Context, object *cmv1.Cluster, stat } else { state.HostPrefix = types.Int64Null() } + networkType, ok := object.Network().GetType() + if ok && networkType == "Other" { + state.NoCNI = types.BoolValue(true) + } else { + state.NoCNI = types.BoolNull() + } channel_group, ok := object.Version().GetChannelGroup() if ok { state.ChannelGroup = types.StringValue(channel_group) diff --git a/provider/clusterrosa/hcp/state.go b/provider/clusterrosa/hcp/state.go index b398a47b..5302e076 100644 --- a/provider/clusterrosa/hcp/state.go +++ b/provider/clusterrosa/hcp/state.go @@ -40,6 +40,7 @@ type ClusterRosaHcpState struct { MachineCIDR types.String `tfsdk:"machine_cidr"` ServiceCIDR types.String `tfsdk:"service_cidr"` HostPrefix types.Int64 `tfsdk:"host_prefix"` + NoCNI types.Bool `tfsdk:"no_cni"` Proxy *proxy.Proxy `tfsdk:"proxy"` // Standard machine pools fields