### Example Usage Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/resources/user.md Examples of how to configure the spectrocloud_user resource. ```APIDOC ## Example Usage An example of creating a user resource with assigned teams and custom roles in Palette. ```hcl resource "spectrocloud_user" "user-test"{ first_name = "tf" last_name = "test" email = "test-tf@spectrocloud.com" team_ids = [data.spectrocloud_team.team2.id] project_role { project_id = data.spectrocloud_project.default.id role_ids = [for r in data.spectrocloud_role.app_roles : r.id] } project_role { project_id = data.spectrocloud_project.ranjith.id role_ids = [for r in data.spectrocloud_role.app_roles : r.id] } tenant_role = [for t in data.spectrocloud_role.tenant_roles : t.id] workspace_role { project_id = data.spectrocloud_project.default.id workspace { id = data.spectrocloud_workspace.workspace.id role_ids = [for w in data.spectrocloud_role.workspace_roles : w.id] } workspace { id = data.spectrocloud_workspace.workspace2.id role_ids = ["66fbea622947f81fc26983e6"] } } resource_role { project_ids = [data.spectrocloud_project.default.id, data.spectrocloud_project.ranjith.id] filter_ids = [data.spectrocloud_filter.filter.id] role_ids = [for r in data.spectrocloud_role.resource_roles : r.id] } resource_role { project_ids = [data.spectrocloud_project.ranjith.id] filter_ids = [data.spectrocloud_filter.filter.id] role_ids = [for re in data.spectrocloud_role.resource_roles_editor : re.id] } } ``` The example below demonstrates how to create an user with only assigned teams. ```hcl resource "spectrocloud_user" "user-test"{ first_name = "tf" last_name = "test" email = "test-tf@spectrocloud.com" team_ids = [data.spectrocloud_team.team2.id] } ``` ``` -------------------------------- ### Example Usage Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/resources/role.md Example of how to use the spectrocloud_role resource to create a custom role. ```APIDOC ```terraform variable "roles" { type = list(string) default = ["Cluster Admin", "Cluster Profile Editor"] } # Data source loop to retrieve multiple roles data "spectrocloud_role" "roles" { for_each = toset(var.roles) name = each.key } resource "spectrocloud_role" "custom_role" { name = "Test Cluster Role" type = "project" permissions = flatten([for role in data.spectrocloud_role.roles : role.permissions]) } ``` ``` -------------------------------- ### Install Dependencies Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/spectrocloud/scripts/README.md Installs required Python packages and makes the formatter script executable. ```bash pip install -r spectrocloud/scripts/requirements.txt chmod +x spectrocloud/scripts/spectro-tf-format ``` -------------------------------- ### spectrocloud_appliances Data Source - Example Usage Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/data-sources/appliances.md This example demonstrates how to use the spectrocloud_appliances data source to filter appliances by status, health, architecture, and tags, and then outputs the names of the matching appliances. ```APIDOC ## spectrocloud_appliances Data Source ### Description Provides details about a set of appliances used for Edge Native cluster provisioning. Various attributes could be used to search for appliances like `tags`, `status`, `health`, and `architecture`. ### Method GET ### Endpoint /api/v1/appliances ### Parameters #### Query Parameters - **context** (String) - Optional - The context of the appliances. Allowed values are `project` or `tenant`. Defaults to `project`. - **status** (String) - Optional - The status of the appliance. Supported values are: 'ready', 'in-use', and 'unpaired'. If not specified, all appliances are returned. - **health** (String) - Optional - The health of the appliance. Supported values are: 'healthy', and 'unhealthy'. If not specified, all appliances are returned. - **architecture** (String) - Optional - The architecture of the appliance. Supported values are: 'amd64', and 'arm64'. If not specified, all appliances are returned. - **tags** (Map of String) - Optional - A list of tags to filter the appliances. ### Response #### Success Response (200) - **id** (String) - The ID of this resource. - **ids** (List of String) - The unique ids of the appliances. #### Response Example { "example": "{\"id\": \"some-id\", \"ids\": [\"appliance-id-1\", \"appliance-id-2\"]}" } ## Example Usage ```terraform # Data source to retrieve details of appliances based on filters data "spectrocloud_appliances" "filtered_appliances" { context = "project" # Context can be "project" or "tenant" status = "ready" # Filter by status ready, in-use, unpaired health = "healthy" # Filter by health status architecture = "amd_64" # Filter by architecture type amd64, arm64 tags = { environment = "production" # Filter by tag key-value pairs } } # Output the list of appliance IDs that match the filters output "appliance_ids" { value = [for a in data.spectrocloud_appliance.filtered_appliances : a.name] } ``` ``` -------------------------------- ### Configuration Options Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/spectrocloud/scripts/README.md Examples of CLI flags to customize output directory, disable backups, or skip formatting. ```bash # Custom output directory spectro-tf-format --output-dir=configs generated.tf # Skip backup creation spectro-tf-format --no-backup generated.tf # Skip terraform formatting spectro-tf-format --no-format generated.tf ``` -------------------------------- ### Example Usage of spectrocloud_role Resource Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/resources/role.md This example demonstrates how to manage roles in Palette. It uses a data source to retrieve existing role permissions and then creates a custom role with those permissions. ```terraform variable "roles" { type = list(string) default = ["Cluster Admin", "Cluster Profile Editor"] } # Data source loop to retrieve multiple roles data "spectrocloud_role" "roles" { for_each = toset(var.roles) name = each.key } resource "spectrocloud_role" "custom_role" { name = "Test Cluster Role" type = "project" permissions = flatten([for role in data.spectrocloud_role.roles : role.permissions]) } ``` -------------------------------- ### Example Output Structure Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/spectrocloud/scripts/README.md Visual representation of the directory structure created after processing. ```text ├── generated.tf # Updated with file() references ├── cluster_configs_yaml/ │ ├── cluster_cloud_config.yaml # Clean YAML format │ ├── cluster_control-plane-pool_config.yaml │ └── cluster_worker-pool_config.yaml ``` -------------------------------- ### Inline YAML Example for Cluster Profile Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/resources/cluster_profile.md This example shows how to define a cluster profile using inline YAML for manifests. It's useful for simple, self-contained manifest definitions directly within the Terraform configuration. ```terraform # If looking up a cluster profile instead of creating a new one # data "spectrocloud_cluster_profile" "profile" { # # id = # name = var.cluster_cluster_profile_name # } # # Example of a Basic add-on profile # resource "spectrocloud_cluster_profile" "cp-addon-vsphere" { # name = "cp-basic" # description = "basic cp" # cloud = "vsphere" # type = "add-on" # pack { # name = "spectro-byo-manifest" # tag = "1.0.x" # uid = "5faad584f244cfe0b98cf489" # # layer = "" # values = <<-EOT # manifests: # byo-manifest: # contents: | # # Add manifests here # apiVersion: v1 # kind: Namespace # metadata: # labels: # app: wordpress # app3: wordpress3 # name: wordpress # EOT # } ``` -------------------------------- ### Application Deployment Example Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/resources/application.md Use this snippet to deploy an application into a specified cluster group with defined resource limits. Ensure the application profile and cluster group UID are correctly provided. ```hcl resource "spectrocloud_application" "application" { name = "app-beru-whitesun-lars" application_profile_uid = data.spectrocloud_application_profile.id config { cluster_name = "sandbox-scorpius" cluster_group_uid = "6358d799fad5aa39fa26a8c2" # or data.spectrocloud_cluster_group.id limits { cpu = 2 memory = 4096 storage = 10 } } } ``` -------------------------------- ### spectrocloud_resource_limit Resource Configuration Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/resources/resource_limit.md Example of how to configure the spectrocloud_resource_limit resource with various settings. ```APIDOC ## spectrocloud_resource_limit Resource ### Description Manages resource limits in SpectroCloud Palette. When this resource is destroyed, resource limits will revert to the Palette default settings. ### Method `CREATE`, `UPDATE`, `DESTROY` (Implicitly managed by Terraform) ### Endpoint Not applicable for Terraform resources; managed via Terraform provider. ### Parameters #### Optional - **alert** (Number) - The maximum number of alerts that can be created. Must be between 1 and 10,000. - **api_keys** (Number) - The maximum number of API keys that can be generated. Must be between 1 and 10,000. - **appliance** (Number) - The maximum number of appliances that can be managed. Must be between 1 and 50,000. - **appliance_token** (Number) - The maximum number of appliance tokens that can be issued. Must be between 1 and 10,000. - **application_deployment** (Number) - The maximum number of application deployments allowed. Must be between 1 and 10,000. - **application_profile** (Number) - The maximum number of application profiles that can be configured. Must be between 1 and 10,000. - **certificate** (Number) - The maximum number of certificates that can be managed. Must be between 1 and 10,000. - **cloud_account** (Number) - The maximum number of cloud accounts that can be added. Must be between 1 and 10,000. - **cluster** (Number) - The maximum number of clusters that can be created. Must be between 1 and 50,000. - **cluster_group** (Number) - The maximum number of cluster groups that can be created. Must be between 1 and 10,000. - **cluster_profile** (Number) - The maximum number of cluster profiles that can be configured. Must be between 1 and 10,000. - **filter** (Number) - The maximum number of filters that can be defined. Must be between 1 and 10,000. - **location** (Number) - The maximum number of locations that can be configured. Must be between 1 and 10,000. - **macro** (Number) - The maximum number of macros that can be created. Must be between 1 and 10,000. - **private_gateway** (Number) - The maximum number of private gateways that can be managed. Must be between 1 and 10,000. - **project** (Number) - The maximum number of projects that can be created. Must be between 1 and 10,000. - **registry** (Number) - The maximum number of registries that can be configured. Must be between 1 and 10,000. - **role** (Number) - The maximum number of roles that can be assigned. Must be between 1 and 10,000. - **ssh_key** (Number) - The maximum number of SSH keys that can be managed. Must be between 1 and 10,000. - **team** (Number) - The maximum number of teams that can be created. Must be between 1 and 10,000. - **user** (Number) - The maximum number of users that can be added. Must be between 1 and 10,000. - **workspace** (Number) - The maximum number of workspaces that can be created. Must be between 1 and 10,000. #### Nested Schema for `timeouts` Optional: - **create** (String) - **delete** (String) - **update** (String) ### Request Example ```hcl resource "spectrocloud_resource_limit" "resource_limit" { alert = 101 api_keys = 201 appliance = 6001 appliance_token = 201 application_deployment = 200 application_profile = 200 certificate = 20 cloud_account = 355 cluster = 300 cluster_group = 50 cluster_profile = 2500 filter = 200 location = 100 macro = 6000 private_gateway = 100 project = 200 registry = 200 role = 100 ssh_key = 300 team = 100 user = 300 workspace = 60 } ``` ### Response #### Success Response (200) - **id** (String) - The ID of this resource. #### Response Example ```json { "id": "" } ``` ``` -------------------------------- ### Manage Developer Setting Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/resources/developer_setting.md Example of managing a developer setting in Palette, configuring limits for virtual clusters, CPU, memory, and storage. ```hcl resource "spectrocloud_developer_setting" "dev_setting" { virtual_clusters_limit = 10 cpu = 20 memory = 100 storage = 100 hide_system_cluster_group = false } ``` -------------------------------- ### Define Application Profile Packs Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/resources/application_profile.md Example configuration for defining multiple operator-instance packs within an application profile. ```hcl # Sample Operator-Instance Tier's pack { name = "minio-operator-stage" type = data.spectrocloud_pack_simple.minio_pack.type source_app_tier = data.spectrocloud_pack_simple.minio_pack.id properties = { "minioUsername" = "miniostaging" "minioUserPassword" = base64encode("test123!wewe!") "volumeSize" = "10" } } pack { name = "mysql-3-stage" type = data.spectrocloud_pack_simple.mysql_pack.type source_app_tier = data.spectrocloud_pack_simple.mysql_pack.id properties = { "dbRootPassword" = base64encode("test123!wewe!") "dbVolumeSize" = "20" "version" = "5.7" } } pack { name = "redis-4-stage" type = data.spectrocloud_pack_simple.redis_pack.type source_app_tier = data.spectrocloud_pack_simple.redis_pack.id properties = { "databaseName" = "redsitstaging" "databaseVolumeSize" = "10" } } } ``` -------------------------------- ### Create SSH Key Resource in HCL Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/resources/ssh_key.md Examples of defining an SSH key resource with different context settings. ```hcl resource "spectrocloud_ssh_key" "ssh_tenant" { name = "ssh-dev-1" context = "project" ssh_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDZ....." } ``` ```hcl resource "spectrocloud_ssh_key" "ssh_tenant" { name = "ssh-dev-1" context = "tenant" ssh_key = var.ssh_key_value } ``` -------------------------------- ### spectrocloud_registry_helm Resource Configuration Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/resources/registry_helm.md Example of how to define and configure a Helm registry resource using Terraform. ```APIDOC ## spectrocloud_registry_helm Resource ### Description Manages a Helm registry within Spectro Cloud. ### Method Resource Definition ### Endpoint N/A (Terraform Resource) ### Parameters #### Required - **name** (String) - The name of the Helm registry. Must be unique. - **endpoint** (String) - The URL endpoint of the Helm registry. - **is_private** (Boolean) - Specifies if the registry is private or public. - **credentials** (Block List, Min: 1, Max: 1) - Authentication credentials for the registry. #### Nested Schema for `credentials` - **credential_type** (String) - Required - The type of authentication ('noAuth', 'basic', 'token'). - **username** (String) - Optional - Username for 'basic' authentication. - **password** (String) - Optional - Password for 'basic' authentication. - **token** (String) - Optional - Authentication token for 'token' authentication. #### Optional - **wait_for_sync** (Boolean) - If true, waits for the registry to synchronize. Defaults to false. - **timeouts** (Block) - Configuration for create, update, and delete timeouts. #### Nested Schema for `timeouts` - **create** (String) - Timeout for resource creation. - **update** (String) - Timeout for resource update. - **delete** (String) - Timeout for resource deletion. ### Read-Only - **id** (String) - The unique identifier of the Helm registry resource. ### Request Example ```terraform resource "spectrocloud_registry_helm" "r1" { name = "us-artifactory" endpoint = "https://123456.dkr.ecr.us-west-1.amazonaws.com" is_private = true credentials { credential_type = "noAuth" username = "abc" password = "def" } # Optional: Wait for the registry to complete synchronization # wait_for_sync = true } ``` ### Import Helm registries can be imported using the registry ID. ```bash terraform import spectrocloud_registry_helm.example ``` **Note**: This is a tenant-level resource. Ensure your provider is configured with appropriate tenant-level credentials. ``` -------------------------------- ### spectrocloud_password_policy Resource Configuration Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/resources/password_policy.md Example of how to configure the spectrocloud_password_policy resource to enforce specific password requirements. ```APIDOC ## spectrocloud_password_policy Resource ### Description The `spectrocloud_password_policy` resource enforces a password compliance policy in Palette. By default, a password policy is configured with default values, but this resource allows users to update these settings. When this resource is destroyed, the password policy reverts to the Palette default settings. ### Method Not applicable (Terraform resource) ### Endpoint Not applicable (Terraform resource) ### Parameters #### Optional Parameters - **first_reminder_days** (Number) - Optional - The number of days before the password expiry to send the first reminder to the user. Default is `5` days before expiry. - **min_digits** (Number) - Optional - The minimum number of numeric digits (0-9) required in the password. Minimum length of digit should be `1`. - **min_lowercase_letters** (Number) - Optional - The minimum number of lowercase letters (a-z) required in the password. Minimum length of lower case should be `1`. - **min_password_length** (Number) - Optional - The minimum length required for the password. Default minimum length is `6`. - **min_special_characters** (Number) - Optional - The minimum number of special characters (e.g., !, @, #, $, %) required in the password. Minimum special characters should be `1`. - **min_uppercase_letters** (Number) - Optional - The minimum number of uppercase letters (A-Z) required in the password. Minimum length of upper case should be `1`. - **password_expiry_days** (Number) - Optional - The number of days before the password expires. Must be between 1 and 1000 days. Default is `999` days for expiry. Conflicts with `min_password_length`, `min_uppercase_letters`, `min_digits`, `min_lowercase_letters`, `min_special_characters`. - **password_regex** (String) - Optional - A regular expression (regex) to define custom password patterns. - **timeouts** (Block) - Optional - Configuration for timeouts. - **create** (String) - Optional - **delete** (String) - Optional - **update** (String) - Optional ### Request Example ```hcl resource "spectrocloud_password_policy" "policy_regex" { # password_regex = "*" password_expiry_days = 123 first_reminder_days = 5 min_digits = 1 min_lowercase_letters = 12 min_password_length = 12 min_special_characters = 1 min_uppercase_letters = 1 } ``` ### Response #### Success Response (200) - **id** (String) - The ID of this resource. #### Response Example (Terraform apply output will show resource creation/update status) ``` -------------------------------- ### Generate Dev Provider Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/dev/README.md Run this script to generate a development build of the provider. Ensure you have the necessary build tools installed. ```bash generate_dev_provider.sh ``` -------------------------------- ### Example Usage of spectrocloud_cluster_vsphere Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/resources/cluster_vsphere.md Use this snippet to provision a vSphere cluster in Palette. Ensure the necessary data sources for cluster profiles and cloud accounts are defined. ```terraform data "spectrocloud_cluster_profile" "vmware_profile" { name = "vsphere-picard-2" version = "1.0.0" context = "project" } data "spectrocloud_cloudaccount_vsphere" "vmware_account" { name = var.shared_vmware_cloud_account_name } resource "spectrocloud_cluster_vsphere" "cluster" { name = "vsphere-picard-3" # For Force Delete enforcement # force_delete = true # force_delete_delay = 25 cloud_account_id = data.spectrocloud_cloudaccount_vsphere.vmware_account.id cluster_profile { id = data.spectrocloud_cluster_profile.vmware_profile.id } cloud_config { ssh_key = var.cluster_ssh_public_key datacenter = var.vsphere_datacenter folder = var.vsphere_folder # For Dynamic DNS (network_type & network_search_domain value should set for DDNS) network_type = "DDNS" network_search_domain = var.cluster_network_search # For Static (By Default static_ip is false, for static provisioning, it is set to be true. Not required to specify network_type & network_search_domain) # static_ip = true } machine_pool { control_plane = true control_plane_as_worker = true name = "cp-pool" count = 1 placement { cluster = var.vsphere_cluster resource_pool = var.vsphere_resource_pool datastore = var.vsphere_datastore network = var.vsphere_network } instance_type { disk_size_gb = 40 memory_mb = 4096 cpu = 2 } } machine_pool { name = "worker-basic" count = 1 node_repave_interval = 30 placement { cluster = var.vsphere_cluster resource_pool = var.vsphere_resource_pool datastore = var.vsphere_datastore network = var.vsphere_network } instance_type { disk_size_gb = 40 memory_mb = 8192 cpu = 4 } } } ``` -------------------------------- ### spectrocloud_backup_storage_location Resource Configuration Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/resources/backup_storage_location.md Example configurations for creating a backup storage location using the spectrocloud_backup_storage_location resource. Demonstrates S3 configurations for different environments. ```APIDOC ## spectrocloud_backup_storage_location Resource ### Description This resource is used to configure a backup storage location within Spectro Cloud. It supports various storage providers including AWS S3, GCP, Azure, and Minio. ### Method Not Applicable (Terraform Resource) ### Endpoint Not Applicable (Terraform Resource) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body This resource is configured via Terraform HCL, not a direct API request body. ### Request Example ```terraform resource "spectrocloud_backup_storage_location" "bsl1" { name = "dev-backup-s3" context = "tenant" is_default = false region = "us-east-2" bucket_name = "dev-backup" s3 { credential_type = var.credential_type access_key = var.aws_access_key secret_key = var.aws_secret_key s3_force_path_style = false #s3_url = "http://10.90.78.23" } } resource "spectrocloud_backup_storage_location" "bsl2" { name = "prod-backup-s3" is_default = false region = "us-east-2" bucket_name = "prod-backup" s3 { credential_type = var.credential_type arn = var.arn external_id = var.external_id s3_force_path_style = false #s3_url = "http://10.90.78.23" } } ``` ### Response Not Applicable (Terraform Resource) ### Schema #### Required - **name** (String) The name of the backup storage location. This is a unique identifier for the backup location. #### Optional - **azure_storage_config** (Block List, Max: 1) Azure storage settings for configuring the backup storage location. (see [below for nested schema](#nestedblock--azure_storage_config)) - **bucket_name** (String) The name of the storage bucket where backups are stored. This is relevant for S3 or S3-compatible(minio) or gcp storage services. - **ca_cert** (String) An optional CA certificate used for SSL connections to ensure secure communication with the storage provider. This is relevant for S3 or S3-compatible(minio) storage services. - **context** (String) The context of the backup storage location. Allowed values are `project` or `tenant`. Default value is `project`. If the `project` context is specified, the project name will sourced from the provider configuration parameter [`project_name`](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs#schema). - **gcp_storage_config** (Block List, Max: 1) GCP storage settings for configuring the backup storage location. (see [below for nested schema](#nestedblock--gcp_storage_config)) - **is_default** (Boolean) Specifies if this backup storage location should be used as the default location for storing backups. - **region** (String) The region where the backup storage is located, typically corresponding to the region of the cloud provider. This is relevant for S3 or S3-compatible(minio) storage services. - **s3** (Block List, Max: 1) S3-specific settings for configuring the backup storage location. (see [below for nested schema](#nestedblock--s3)) - **storage_provider** (String) The storage location provider for backup storage. Allowed values are `aws` or `minio` or `gcp` or `azure`. Default value is `aws`. - **timeouts** (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) #### Read-Only - **id** (String) The ID of this resource. ### Nested Schema for `azure_storage_config` Required: - **azure_client_id** (String) Unique client Id from Azure console. - **azure_client_secret** (String, Sensitive) Azure secret for authentication. - **azure_tenant_id** (String) Unique tenant Id from Azure console. - **container_name** (String) The container name. - **resource_group** (String) The resource group name. - **stock_keeping_unit** (String) The stop-keeping unit. eg: `Standard_LRS` - **storage_name** (String) The storage name. - **subscription_id** (String) Unique subscription Id from Azure console. ### Nested Schema for `gcp_storage_config` (Schema not provided in the input text) ``` -------------------------------- ### Cluster Profile with Data Resources and Custom YAML Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/resources/cluster_profile.md This example demonstrates creating a cluster profile using data resources for pack information and referencing a YAML file for manifest content. It's useful for defining complex cluster configurations with external pack dependencies. ```terraform data "spectrocloud_registry" "public_registry" { name = "Public Repo" } data "spectrocloud_cloudaccount_aws" "account" { count = var.deploy-aws ? 1 : 0 name = var.aws-cloud-account-name } data "spectrocloud_pack" "aws_csi" { name = "csi-aws-ebs" version = "1.22.0" registry_uid = data.spectrocloud_registry.public_registry.id } data "spectrocloud_pack" "aws_cni" { name = "cni-calico" version = "3.26.1" registry_uid = data.spectrocloud_registry.public_registry.id } data "spectrocloud_pack" "aws_k8s" { name = "kubernetes" version = "1.27.5" registry_uid = data.spectrocloud_registry.public_registry.id } data "spectrocloud_pack" "aws_ubuntu" { name = "ubuntu-aws" version = "22.04" registry_uid = data.spectrocloud_registry.public_registry.id } data "spectrocloud_cluster" "aws_cluster_api" { count = var.deploy-aws ? 1 : 0 name = "aws-cluster-api" context = "project" depends_on = [spectrocloud_cluster_aws.aws-cluster-api] } resource "spectrocloud_cluster_profile" "aws-profile" { count = var.deploy-aws ? 1 : 0 name = "tf-aws-profile" description = "A basic cluster profile for AWS" tags = concat(var.tags, ["env:aws"]) cloud = "aws" type = "cluster" version = "1.0.0" pack { name = data.spectrocloud_pack.aws_ubuntu.name tag = data.spectrocloud_pack.aws_ubuntu.version uid = data.spectrocloud_pack.aws_ubuntu.id values = data.spectrocloud_pack.aws_ubuntu.values } pack { name = data.spectrocloud_pack.aws_k8s.name tag = data.spectrocloud_pack.aws_k8s.version uid = data.spectrocloud_pack.aws_k8s.id values = data.spectrocloud_pack.aws_k8s.values } pack { name = data.spectrocloud_pack.aws_cni.name tag = data.spectrocloud_pack.aws_cni.version uid = data.spectrocloud_pack.aws_cni.id values = data.spectrocloud_pack.aws_cni.values } pack { name = data.spectrocloud_pack.aws_csi.name tag = data.spectrocloud_pack.aws_csi.version uid = data.spectrocloud_pack.aws_csi.id values = data.spectrocloud_pack.aws_csi.values } pack { name = "hello-universe" type = "manifest" tag = "1.0.0" values = "" manifest { name = "hello-universe" content = file("manifests/hello-universe.yaml") } } } ``` -------------------------------- ### Configure SAML SSO Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/resources/sso.md Example of configuring SAML SSO settings, including service provider details, identity provider metadata, and default team assignments. Ensure to replace placeholder values with your actual configuration. ```hcl data "spectrocloud_team" "team" { name = "Tenant Admin" } resource "spectrocloud_sso" "sso_setting" { sso_auth_type = "saml" # oidc or none domains = ["test.com", "test-login.com"] auth_providers = ["github", "google"] saml { service_provider = "Microsoft ADFS" identity_provider_metadata = "test" default_team_ids = [data.spectrocloud_team.team.id] enable_single_logout = true name_id_format = "name_id_format" first_name = "testfirst" last_name = "testlast" email = "test@test.com" spectro_team = "SpectroTeam" } } ``` -------------------------------- ### Complete Workflow Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/spectrocloud/scripts/README.md Demonstrates the full cycle of importing a cluster, generating configuration, processing it, and reviewing the results. ```bash # Import existing cluster cat > import.tf << EOF import { to = spectrocloud_cluster_custom_cloud.example id = "cluster123:project:nutanix" } EOF # Generate and process terraform plan -generate-config-out=generated.tf spectro-tf-format generated.tf # Review results ls cluster_configs_yaml/ terraform plan # Clean up rm import.tf ``` -------------------------------- ### Import a spectrocloud_appliance Resource Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/resources/appliance.md Appliances can be imported using their UID or name. The `wait` field defaults to `false` for imported resources. Ensure provider is configured with project-level credentials. ```bash terraform import spectrocloud_appliance.example / ``` -------------------------------- ### Generate Dev Provider with Make Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/dev/README.md Alternatively, use the make command to generate a development build of the provider. This is a convenient shortcut for the script. ```bash make dev-provider ``` -------------------------------- ### GET spectrocloud_filter Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/data-sources/filter.md Retrieves the details of a specific filter by its name. ```APIDOC ## GET spectrocloud_filter ### Description Retrieves the metadata and specification details for a filter identified by its name. ### Parameters #### Query Parameters - **name** (String) - Required - The name of the filter to retrieve. ### Response #### Success Response (200) - **id** (String) - The ID of the resource. - **metadata** (List of Object) - Metadata including annotations, labels, and name. - **spec** (List of Object) - Specification details including filter groups, conjunctions, and individual filter criteria (key, negation, operator, values). ``` -------------------------------- ### GET spectrocloud_registry_helm Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/data-sources/registry_helm.md Retrieves information about a specific Helm registry managed by SpectroCloud. ```APIDOC ## GET spectrocloud_registry_helm ### Description Retrieves the details of a specific SpectroCloud Helm registry by its name. ### Parameters #### Required Parameters - **name** (String) - Required - The name of the Helm registry to look up. ### Response #### Read-Only Fields - **id** (String) - The unique identifier of the retrieved Helm registry. ``` -------------------------------- ### Terraform Initialization and Application Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/index.md Initialize your Terraform project and apply the configuration to provision Spectro Cloud resources. Ensure all variables are correctly set. ```console terraform init && terraform apply ``` -------------------------------- ### spectrocloud_project Resource Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/resources/project.md Details for the spectrocloud_project resource, including schema definitions and usage examples. ```APIDOC ## spectrocloud_project (Resource) ### Description Create and manage projects in Palette. ### Parameters #### Required - **name** (String) - The name of the project. #### Optional - **description** (String) - The description of the project. - **tags** (Set of String) - Assign tags to the project. - **timeouts** (Block) - Configuration for resource operation timeouts. #### Read-Only - **id** (String) - The ID of this resource. ### Request Example ```terraform resource "spectrocloud_project" "project" { name = "dev2" tags = ["owner:jdoe@emxaple.com", "cost-center:12345"] description = "This is the primary devoplent environment for team Yellow." } ``` ### Import Use the following command to import an existing project: `terraform import spectrocloud_project.{project_uid}/{project_name}` ``` -------------------------------- ### Create a VM with default configurations Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/resources/virtual_machine.md Use this snippet to create a basic virtual machine with default cloud-init disk, container disk, interface, and network configurations. Ensure the cluster data source is correctly defined. ```terraform data "spectrocloud_cluster" "vm_enabled_base_cluster" { name = "tenant-cluster-002" context = "project" } locals { storage_class_name = "spectro-storage-class" } // Create a VM with default cloud init disk, container disk , interface and network resource "spectrocloud_virtual_machine" "tf-test-vm-basic-type" { cluster_uid = data.spectrocloud_cluster.vm_enabled_base_cluster.id cluster_context = data.spectrocloud_cluster.vm_enabled_base_cluster.context run_on_launch = true name = "tf-test-vm-basic-type" namespace = "default" labels = { "tf" = "test" } volume { name = "containerdisk" volume_source { container_disk { image_url = "gcr.io/spectro-images-public/release/vm-dashboard/os/ubuntu-container-disk:20.04" } } } volume { name = "cloudintdisk" volume_source { cloud_init_config_drive { user_data = "\n#cloud-config\nssh_pwauth: True\nchpasswd: { expire: False }\npassword: spectro\ndisable_root: false\n" } } } disk { name = "containerdisk" disk_device { disk { bus = "virtio" } } } disk { name = "cloudintdisk" disk_device { disk { bus = "virtio" } } } cpu { cores = 2 sockets = 1 threads = 10 } memory { guest = "1Gi" } resources { requests = { memory = "1Gi" cpu = 1 } limits = { cpu = 2 memory = "1Gi" } } interface { name = "default" interface_binding_method = "InterfaceMasquerade" } network { name = "default" network_source { pod {} } } } ``` -------------------------------- ### Help Command Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/spectrocloud/scripts/README.md Displays the built-in help menu for the formatter. ```bash spectro-tf-format --help ``` -------------------------------- ### Define a Virtual Machine with Cloud-Init and Multus Networking Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/resources/virtual_machine.md Configures a virtual machine using a container disk, cloud-init for initialization, and multiple network interfaces with specific models. ```hcl resource "spectrocloud_virtual_machine" "tf-test-vm-multi-networks" { cluster_uid = data.spectrocloud_cluster.vm_enabled_base_cluster.id cluster_context = data.spectrocloud_cluster.vm_enabled_base_cluster.context name = "tf-test-vm-multi-network-interface" namespace = "default" run_on_launch = true labels = { "key1" = "value1" } volume { name = "test-vm-containerdisk1" volume_source { container_disk { image_url = "quay.io/kubevirt/fedora-cloud-container-disk-demo" } } } volume { name = "cloudintdisk" volume_source { cloud_init_config_drive { user_data = "\n#cloud-config\nssh_pwauth: True\nchpasswd: { expire: False }\npassword: spectro\ndisable_root: false\n" } } } resources { requests = { memory = "2G" cpu = 1 } } disk { name = "test-vm-containerdisk1" disk_device { disk { bus = "virtio" } } } disk { name = "cloudintdisk" disk_device { disk { bus = "virtio" } } } interface { name = "main" interface_binding_method = "InterfaceMasquerade" model = "virtio" } interface { name = "additional" interface_binding_method = "InterfaceBridge" model = "e1000e" } network { name = "main" network_source { pod {} } } network { name = "additional" network_source { multus { network_name = "macvlan-conf" default = false } } } } ``` -------------------------------- ### GET spectrocloud_appliance Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/data-sources/appliance.md Retrieves details for a single appliance used for Edge Native cluster provisioning. ```APIDOC ## GET spectrocloud_appliance ### Description Provides details about a single appliance used for Edge Native cluster provisioning. ### Parameters #### Optional - **id** (String) - Optional - ID of the appliance registered in Palette. - **name** (String) - Optional - The name of the appliance. ### Response - **architecture** (String) - The architecture of the appliance (amd64, arm64). - **health** (String) - The health of the appliance (healthy, unhealthy). - **status** (String) - The status of the appliance (ready, in-use, unpaired). - **tags** (Map of String) - The tags of the appliance. ### Request Example ```terraform data "provider_appliance" "example" { id = "appliance-1234" } ``` ``` -------------------------------- ### Basic Usage Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/spectrocloud/scripts/README.md Generates a Terraform configuration file and processes it using default settings. ```bash # Generate Terraform configuration terraform plan -generate-config-out=generated.tf # Process with built-in defaults spectro-tf-format generated.tf ``` -------------------------------- ### spectrocloud_developer_setting Resource Management Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/resources/developer_setting.md Example of how to manage the spectrocloud_developer_setting resource in Terraform, including setting limits and quotas. ```APIDOC ## spectrocloud_developer_setting (Resource) Each developer in this tenant may create up to 1 virtual clusters and will be allocated compute and storage quota across all their virtual clusters based on the configuration in developer setting [Developer Setting](https://docs.spectrocloud.com/devx/manage-dev-engine/resource-quota/#tenant-developer-user-quotas) guide. ~> The developer_setting resource enforces a usage quota for developer. By default, a developer quota is configured in Palette with default values. Users can update the developer settings as per their requirements. Every new virtual cluster will consume about 3 CPU and 3 GiB memory even without any user workloads, we recommend that you allocate quota accordingly. When a spectrocloud_developer_setting resource is destroyed, the developer setting will revert to the Palette default settings. ### Example Usage An example of managing an developer setting in Palette. ```hcl resource "spectrocloud_developer_setting" "dev_setting" { virtual_clusters_limit = 10 cpu = 20 memory = 100 storage = 100 hide_system_cluster_group = false } ``` ### Schema #### Optional - **cpu** (Number) - Defines the number of CPU cores allocated to the cluster. - **hide_system_cluster_group** (Boolean) - If set to `true`, hides the system cluster. - **memory** (Number) - Specifies the amount of memory (in GiB) allocated to the cluster. - **storage** (Number) - Defines the storage capacity (in GiB) allocated to the cluster. - **timeouts** (Block, Optional) - (see [below for nested schema](#nestedblock--timeouts)) - **virtual_clusters_limit** (Number) - Specifies the number of virtual clusters to be created. #### Read-Only - **id** (String) - The ID of this resource. ### Nested Schema for `timeouts` Optional: - **create** (String) - **delete** (String) - **update** (String) ``` -------------------------------- ### Create a project with metadata Source: https://github.com/spectrocloud/terraform-provider-spectrocloud/blob/main/docs/resources/project.md Defines a project resource including optional tags and a description. ```terraform resource "spectrocloud_project" "project" { name = "dev2" tags = ["owner:jdoe@emxaple.com", "cost-center:12345"] description = "This is the primary devoplent environment for team Yellow." } ```