diff --git a/docs/resources/datahub_azure_cluster.md b/docs/resources/datahub_azure_cluster.md index d75922ab..4b3005e3 100644 --- a/docs/resources/datahub_azure_cluster.md +++ b/docs/resources/datahub_azure_cluster.md @@ -231,6 +231,7 @@ Required: Optional: +- `availability_zones` (Set of String) List of availability zones that this instance group is associated with. - `recipes` (Set of String) The set of recipe names that are going to be applied on the given instance group. diff --git a/resources/datahub/common_scheme.go b/resources/datahub/common_scheme.go index 120e9760..322132ac 100644 --- a/resources/datahub/common_scheme.go +++ b/resources/datahub/common_scheme.go @@ -146,3 +146,76 @@ var instanceGroupSchemaAttributes = map[string]schema.Attribute{ }, }, } + +var azureInstanceGroupSchemaAttributes = map[string]schema.Attribute{ + "instance_group": schema.ListNestedAttribute{ + Optional: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "node_count": schema.Int64Attribute{ + MarkdownDescription: "The cluster node count. Has to be greater or equal than 0 and less than 100,000.", + Required: true, + }, + "availability_zones": schema.SetAttribute{ + MarkdownDescription: "List of availability zones that this instance group is associated with.", + ElementType: types.StringType, + Optional: true, + }, + "instance_group_name": schema.StringAttribute{ + MarkdownDescription: "The name of the instance group.", + Required: true, + }, + "instance_group_type": schema.StringAttribute{ + MarkdownDescription: "The type of the instance group.", + Required: true, + }, + "instance_type": schema.StringAttribute{ + MarkdownDescription: "The cloud provider-side instance type.", + Required: true, + }, + "root_volume_size": schema.Int64Attribute{ + MarkdownDescription: "The size of the root volume in GB", + Required: true, + }, + "recipes": schema.SetAttribute{ + MarkdownDescription: "The set of recipe names that are going to be applied on the given instance group.", + ElementType: types.StringType, + Optional: true, + }, + "attached_volume_configuration": schema.ListNestedAttribute{ + Required: true, + MarkdownDescription: "Configuration regarding the attached volume to the specific instance group.", + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "volume_size": schema.Int64Attribute{ + MarkdownDescription: "The size of the volume in GB.", + Required: true, + }, + "volume_count": schema.Int64Attribute{ + MarkdownDescription: "The number of volumes to be attached.", + Required: true, + }, + "volume_type": schema.StringAttribute{ + MarkdownDescription: "The - cloud provider - type of the volume.", + Required: true, + }, + }, + }, + }, + "recovery_mode": schema.StringAttribute{ + MarkdownDescription: "The type of the recovery mode.", + Required: true, + }, + "volume_encryption": schema.SingleNestedAttribute{ + MarkdownDescription: "The volume encryption related configuration.", + Required: true, + Attributes: map[string]schema.Attribute{ + "encryption": schema.BoolAttribute{ + Required: true, + }, + }, + }, + }, + }, + }, +} diff --git a/resources/datahub/converter.go b/resources/datahub/converter.go index 4ca5a3d7..31c9e358 100644 --- a/resources/datahub/converter.go +++ b/resources/datahub/converter.go @@ -127,6 +127,12 @@ func fromModelToAzureRequest(model azureDatahubResourceModel, ctx context.Contex igRecipes = append(igRecipes, recipe.ValueString()) } } + var azs []string + if group.AvailabilityZones != nil && len(group.AvailabilityZones) > 0 { + for _, az := range group.AvailabilityZones { + azs = append(azs, az.ValueString()) + } + } rootVolumeSize := int32(group.RootVolumeSize.ValueInt64()) ig := &datahubmodels.AzureInstanceGroupRequest{ AttachedVolumeConfiguration: volReqs, @@ -137,6 +143,7 @@ func fromModelToAzureRequest(model azureDatahubResourceModel, ctx context.Contex RecipeNames: igRecipes, RecoveryMode: group.RecoveryMode.ValueString(), RootVolumeSize: &rootVolumeSize, + AvailabilityZones: azs, } igs = append(igs, ig) } diff --git a/resources/datahub/model_datahub.go b/resources/datahub/model_datahub.go index 0d860174..68325148 100644 --- a/resources/datahub/model_datahub.go +++ b/resources/datahub/model_datahub.go @@ -24,6 +24,7 @@ type InstanceGroup struct { RecoveryMode types.String `tfsdk:"recovery_mode"` VolumeEncryption VolumeEncryption `tfsdk:"volume_encryption"` Recipes []types.String `tfsdk:"recipes"` + AvailabilityZones []types.String `tfsdk:"availability_zones"` } type AttachedVolumeConfiguration struct { diff --git a/resources/datahub/schema_azure_datahub.go b/resources/datahub/schema_azure_datahub.go index 6aaf11c0..b8db7703 100644 --- a/resources/datahub/schema_azure_datahub.go +++ b/resources/datahub/schema_azure_datahub.go @@ -27,7 +27,7 @@ import ( func (r *azureDatahubResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { attr := map[string]schema.Attribute{} utils.Append(attr, generalAttributes) - utils.Append(attr, instanceGroupSchemaAttributes) + utils.Append(attr, azureInstanceGroupSchemaAttributes) utils.Append(attr, map[string]schema.Attribute{ "cluster_template": schema.StringAttribute{ MarkdownDescription: "The name of the cluster template.",