func elasticsearchTopologySchema()

in ec/ecresource/deploymentresource/elasticsearch/v2/schema.go [479:610]


func elasticsearchTopologySchema(options topologySchemaOptions) schema.Attribute {
	nodeRolesPlanModifiers := []planmodifier.Set{
		UseNodeRolesDefault(),
	}

	if options.nodeRolesImpactedBySizeChange {
		nodeRolesPlanModifiers = append(nodeRolesPlanModifiers, SetUnknownOnTopologySizeChange())
	}

	var topologyPlanModifiers []planmodifier.Object
	if options.tierName == "master" {
		topologyPlanModifiers = append(topologyPlanModifiers, UseTopologyStateForUnknown("master"))
	}

	return schema.SingleNestedAttribute{
		Optional:      !options.required,
		Computed:      options.tierName == "master",
		Required:      options.required,
		Description:   fmt.Sprintf("'%s' topology element", options.tierName),
		PlanModifiers: topologyPlanModifiers,
		Attributes: map[string]schema.Attribute{
			"instance_configuration_id": schema.StringAttribute{
				Description: `Instance Configuration ID of the topology element`,
				Computed:    true,
				Optional:    true,
				PlanModifiers: []planmodifier.String{
					UseTopologyStateForUnknown(options.tierName),
				},
			},
			"latest_instance_configuration_id": schema.StringAttribute{
				Description: `Latest Instance Configuration ID available on the deployment template for the topology element`,
				Computed:    true,
				PlanModifiers: []planmodifier.String{
					UseTopologyStateForUnknown(options.tierName),
				},
			},
			"instance_configuration_version": schema.Int64Attribute{
				Description: `Instance Configuration version of the topology element`,
				Computed:    true,
				Optional:    true,
				PlanModifiers: []planmodifier.Int64{
					UseTopologyStateForUnknown(options.tierName),
				},
			},
			"latest_instance_configuration_version": schema.Int64Attribute{
				Description: `Latest version available for the Instance Configuration with the latest_instance_configuration_id`,
				Computed:    true,
				PlanModifiers: []planmodifier.Int64{
					UseTopologyStateForUnknown(options.tierName),
				},
			},
			"size": schema.StringAttribute{
				Description: `Amount of "size_resource" per node in the "<size in GB>g" notation`,
				Computed:    true,
				Optional:    true,
				PlanModifiers: []planmodifier.String{
					UseTopologyStateForUnknown(options.tierName),
				},
			},
			"size_resource": schema.StringAttribute{
				Description: `Size type, defaults to "memory".`,
				Optional:    true,
				Computed:    true,
				PlanModifiers: []planmodifier.String{
					planmodifiers.StringDefaultValue("memory"),
				},
			},
			"zone_count": schema.Int64Attribute{
				Description: `Number of zones that the Elasticsearch cluster will span. This is used to set HA`,
				Computed:    true,
				Optional:    true,
				PlanModifiers: []planmodifier.Int64{
					UseTopologyStateForUnknown(options.tierName),
				},
			},
			"node_type_data": schema.StringAttribute{
				Description: `The node type for the Elasticsearch Topology element (data node)`,
				Computed:    true,
				Optional:    true,
				Validators: []validator.String{
					VersionSupportsNodeTypes(),
				},
				PlanModifiers: []planmodifier.String{
					UseNodeTypesDefault(),
				},
			},
			"node_type_master": schema.StringAttribute{
				Description: `The node type for the Elasticsearch Topology element (master node)`,
				Computed:    true,
				Optional:    true,
				Validators: []validator.String{
					versionSupportsNodeTypes{},
				},
				PlanModifiers: []planmodifier.String{
					UseNodeTypesDefault(),
				},
			},
			"node_type_ingest": schema.StringAttribute{
				Description: `The node type for the Elasticsearch Topology element (ingest node)`,
				Computed:    true,
				Optional:    true,
				Validators: []validator.String{
					VersionSupportsNodeTypes(),
				},
				PlanModifiers: []planmodifier.String{
					UseNodeTypesDefault(),
				},
			},
			"node_type_ml": schema.StringAttribute{
				Description: `The node type for the Elasticsearch Topology element (machine learning node)`,
				Computed:    true,
				Optional:    true,
				Validators: []validator.String{
					VersionSupportsNodeTypes(),
				},
				PlanModifiers: []planmodifier.String{
					UseNodeTypesDefault(),
				},
			},
			"node_roles": schema.SetAttribute{
				ElementType:   types.StringType,
				Description:   `The computed list of node roles for the current topology element`,
				Computed:      true,
				PlanModifiers: nodeRolesPlanModifiers,
				Validators: []validator.Set{
					VersionSupportsNodeRoles(),
				},
			},
			"autoscaling": elasticsearchTopologyAutoscalingSchema(options.tierName),
		},
	}
}