Skip to navigation

Use the Sigma Terraform provider

View as Markdown

After you install and configure the Sigma Terraform provider, you can define Sigma resources in Terraform, preview changes, and apply them.

This document explains how to write your first configuration, import existing Sigma objects, understand resource behavior, protect sensitive values in state, and troubleshoot errors.

Each resource and data source maps to Sigma REST API endpoints. For the full list of arguments and attributes, see the provider documentation in the Terraform Registry. The examples directory on GitHub has one configuration for each resource and data source.

Create resources with Terraform

You use a Terraform configuration to declare the resources, and the Sigma Terraform provider uses the Sigma REST API to update your Sigma organization.

The following example creates an Analytics team and a user named Jane Doe, then adds the user to the team.

# Create a team.
resource "sigma_team" "analytics" {
name = "Analytics"
}
# Create a user. Sigma stores the account type as "build".
resource "sigma_member" "jane" {
email = "jane@example.com"
first_name = "Jane"
last_name = "Doe"
member_type = "build"
}
# Add the user to the team.
resource "sigma_team_membership" "jane_analytics" {
team_id = sigma_team.analytics.id
member_id = sigma_member.jane.id
}
# Read existing workspaces without managing them.
data "sigma_workspaces" "all" {}

The provider calls the following Sigma REST API endpoints for the objects in this example:

Terraform objectSigma REST API endpoint
sigma_teamCreate a team
sigma_memberCreate a member
sigma_team_membershipUpdate team members
sigma_workspaces data sourceList workspaces

By default, creating a sigma_member sends an email invitation to the user. To create members without sending an invitation, for example if your identity provider manages user onboarding, set send_invite = false on the resource.

To preview and apply the changes, use the terraform plan and terraform apply commands:

# Preview the changes Terraform will make.
terraform plan
# Create the resources in Sigma.
terraform apply

To remove the resources that a configuration manages, run terraform destroy. Before you destroy a resource, review Understand resource behavior.

Import existing resources

To manage an object that already exists in Sigma, import it into Terraform state.

Each resource page in the provider documentation has an Import section with the ID format.

For example, to import an existing team:

  1. In your configuration, add a resource block for the object, for example:

    resource "sigma_team" "analytics" {
    name = "Analytics"
    }
  2. To import the object, run the following terraform import command with the ID of the object in Sigma:

    terraform import sigma_team.analytics <team_id>

    Some resources use a composite ID. For example, a team membership uses <team_id>:<member_id>.

  3. To confirm that your configuration matches the imported object, run terraform plan.

For more information about how importing works, see Import resources in the Terraform documentation.

Understand resource behavior

Some resources behave in ways that aren’t obvious from their configuration, such as deleting content when you destroy a resource or requiring extra arguments after an import. The following table lists these behaviors. Review them before you apply changes to a production organization or when you troubleshoot unexpected plan output:

ResourceBehavior
sigma_memberDestroying a user deactivates the user in Sigma. The email address stays reserved and can’t be used for a new user without an admin restoring the user in Sigma.
sigma_workspaceDestroying a workspace permanently deletes the workspace and the documents in it. Sigma can’t recover a deleted workspace.
sigma_workspace_grantThe permission argument uses the API value. view is Can view, explore is Can explore, organize is Can contribute, and edit is Can manage.
sigma_folderDestroying a folder archives it. You can restore the content from Sigma.
sigma_connectionWhen you create the connection, Sigma validates the credentials in details_json. Sigma doesn’t return the details_json attribute. After an import, the next plan proposes an update unless you add lifecycle { ignore_changes = [details_json] }. Destroying a connection breaks content that uses it.
sigma_account_typeChanging permissions updates the account type. Changing name creates a new account type with a new ID, moves the users to it, and deletes the old one, unless you set migrate_on_rename = false. Settings that reference the old account type, such as SSO or SCIM role mappings, aren’t updated. Changing only description replaces the account type, and Sigma reassigns the users of the old account type to the account type in reassign_to_account_type_id.
sigma_api_credentialSigma returns client_secret only when it creates the credential. Destroying the resource immediately revokes the credential and any tool that uses it starts receiving authentication errors.
sigma_tenantChanging cloud_provider replaces the tenant organization. For more information, see Create and manage tenant organizations.

Protect sensitive values in state

Terraform stores resource attributes in a state file. The following resources store sensitive values there, because Sigma doesn’t return them after creation:

  • sigma_api_credential.client_secret
  • sigma_connection.details_json, which contains the data platform credentials that you provide for a connection
  • sigma_api_connector_credential.credential_json
  • sigma_smtp_settings.password
  • User attribute values, which might hold tenant IDs or other values used for row-level security

To protect these values, do the following:

  • Store state in an encrypted remote backend with restricted access, such as Amazon S3 with encryption, HCP Terraform, Azure Blob Storage, or Google Cloud Storage with customer-managed keys. Don’t use local state files for configurations that handle real credentials.
  • Create a dedicated API credential for Terraform and rotate it regularly.
  • Treat TF_LOG output as sensitive, even though the provider masks known secret fields. For more guidance, see Manage sensitive data in your configuration.

The provider reads configuration and metadata for the objects you manage or look up, such as user names and emails, teams, connection settings, and grants. It doesn’t read data in your workbooks, data models, or connected warehouses.

Troubleshoot the provider

The following sections describe how to log provider requests and resolve common errors.

Enable debug logging

To see the HTTP requests that the provider sends, set the TF_LOG environment variable. For more information about log levels and options such as TF_LOG_PATH, see Enable Terraform logs. Request and response bodies appear at the TRACE level in the sigma_http subsystem. The provider masks values such as client secrets, access tokens, warehouse credentials, and user attribute values.

# Log provider requests.
TF_LOG=DEBUG terraform plan
# Include request and response bodies.
TF_LOG=TRACE terraform plan

Resolve common errors

SymptomLikely cause and resolution
Authentication errors, such as 401The client ID or secret is incorrect or revoked, or the credentials belong to a different Sigma organization. Verify the values, and check the credential with the sigma_whoami data source.
Requests fail to connect, or return 404The base_url doesn’t match your organization’s cloud and region. In Sigma, go to Administration > Developer Access to confirm the API base URL.
403 or permission errors when you create or change a resourceThe credentials are assigned to a user without the Admin account type. Generate new credentials assigned to a user with the Admin account type.
429 rate limit errorsThe provider retries automatically and honors the Retry-After header for up to one minute. To reduce load, run terraform apply with a lower -parallelism value, for example -parallelism=2.
A connection plan shows changes after an importSigma doesn’t return details_json. Add lifecycle { ignore_changes = [details_json] } to the resource.

For more information about using Terraform itself, see the following in the HashiCorp documentation: