Spacelift
PrivacyT&Cs
  • 👋Hello, Spacelift!
  • 🚀Getting Started
  • 🌠Main concepts
    • Stack
      • Creating a stack
      • Stack settings
      • Organizing stacks
      • Stack locking
      • Drift detection
    • Configuration
      • Environment
      • Context
      • Runtime configuration
        • YAML reference
    • Run
      • Task
      • Proposed run (preview)
      • Tracked run (deployment)
      • Module test case
      • User-Provided Metadata
      • Run Promotion
      • Pull Request Comments
    • Policy
      • Login policy
      • Access policy
      • Approval policy
      • Initialization policy
      • Plan policy
      • Push policy
      • Task policy
      • Trigger policy
    • Resources
    • Worker pools
    • VCS Agent Pools
  • 🛰️Platforms
    • Terraform
      • Module registry
      • External modules
      • Provider
      • State management
      • Terragrunt
      • Version management
      • Handling .tfvars
      • CLI Configuration
      • Cost Estimation
      • Resource Sanitization
      • Storing Complex Variables
      • Debugging Guide
    • Pulumi
      • Getting started
        • C#
        • Go
        • JavaScript
        • Python
      • State management
      • Version management
    • CloudFormation
      • Getting Started
      • Reference
      • Integrating with SAM
      • Integrating with the serverless framework
    • Kubernetes
      • Getting Started
      • Authenticating
      • Custom Resources
      • Helm
      • Kustomize
  • ⚙️Integrations
    • Audit trail
    • Cloud Integrations
      • Amazon Web Services (AWS)
      • Microsoft Azure
      • Google Cloud Platform (GCP)
    • Source Control
      • GitHub
      • GitLab
      • Azure DevOps
      • Bitbucket Cloud
      • Bitbucket Datacenter/Server
    • Docker
    • GraphQL API
    • Single sign-on
      • GitLab OIDC Setup Guide
      • Okta OIDC Setup Guide
      • OneLogin OIDC Setup Guide
      • Azure AD OIDC Setup Guide
      • AWS IAM Identity SAML 2.0 Setup Guide
    • Slack
    • Webhooks
  • 📖Product
    • Privacy
    • Security
    • Support
      • Statement of Support
    • Disaster Continuity
    • Billing
      • Stripe
      • AWS Marketplace
    • Terms and conditions
    • Refund Policy
  • Cookie Policy
Powered by GitBook
On this page
  • Sanitization and Plan Policies
  • Disabling Sanitization

Was this helpful?

  1. Platforms
  2. Terraform

Resource Sanitization

Terraform state can contain very sensitive data. Sometimes this is unavoidable because of the design of certain Terraform providers, or because the definition of what is sensitive isn't always simple and may vary between individuals and organizations. To avoid leaking sensitive data, Spacelift takes the approach of automatically sanitizing any resources stored or passed to plan policies by default.

For example, if we take the following definition for an EC2 instance:

resource "aws_instance" "this" {
  ami           = "ami-abc123"
  instance_type = "t3.small"

  root_block_device {
    volume_size = 50
  }

  tags = {
    Name = "My Instance"
  }
}

Spacelift will supply something similar to the following to any plan policies:

{
  ...,
  "terraform": {
    "resource_changes": [
      {
        "address": "module.instance.aws_instance.this",
        "change": {
          "actions": ["create"],
          "after": {
            "ami": "c4cb6118",
            ...,
            "tags": {
              "Name": "d3dac282"
            },
            "tags_all": {
              "Name": "d3dac282"
            },
          }
        }
      }
    ]
  }
}

Sanitization and Plan Policies

Disabling Sanitization

If you have a situation where the sanitized() helper function doesn't provide you with enough flexibility to create a particular policy, you can disable sanitization completely for a stack. To do this, add the feature:disable_resource_sanitization label to your stack. This will disable sanitization for any future runs.

PreviousCost EstimationNextStoring Complex Variables

Last updated 3 years ago

Was this helpful?

As you can see, the ami and tags fields have had their values sanitized, and replaced with hashes. The same sanitization is also applied to resources shown in the views.

Sometimes you need to perform a comparison against a sanitized value in a plan policy. To help with this we provide a sanitized() that you can use in your policies.

🛰️
resources
helper function