• HashiCorp Developer

  • HashiCorp Cloud Platform
  • Terraform
  • Packer
  • Consul
  • Vault
  • Boundary
  • Nomad
  • Waypoint
  • Vagrant
Terraform
  • Install
  • Tutorials
    • About the Docs
    • Configuration Language
    • Terraform CLI
    • Terraform Cloud
    • Terraform Enterprise
    • CDK for Terraform
    • Provider Use
    • Plugin Development
    • Registry Publishing
    • Integration Program
  • Registry(opens in new tab)
  • Try Cloud(opens in new tab)
  • Sign up
Plugin Development

Framework

Skip to main content
  • Framework
  • Provider Servers
    • Terraform Concepts
    • Schemas
    • Attributes
    • Blocks
    • Paths
    • Path Expressions
    • Accessing Terraform Data
    • Writing Data
    • Conversion Rules
    • Custom Types
  • Returning Errors and Warnings
  • Validation
  • Acceptance Tests
  • Debugging

  • Resources

  • Tutorial Library
  • Certifications
  • Community Forum
    (opens in new tab)
  • Support
    (opens in new tab)
  • GitHub
    (opens in new tab)
  • Terraform Registry
    (opens in new tab)
  1. Developer
  2. Terraform
  3. Plugin Development
  4. Framework
  5. Handling Data
  6. Terraform Concepts
  • Plugin Framework
  • v1.0.x
  • v0.17.x
  • v0.16.x
  • v0.15.x
  • v0.14.x
  • v0.13.x
  • v0.12.x
  • v0.11.x
  • v0.10.x
  • v0.9.x
  • v0.8.x
  • v0.7.x

ยปTerraform Concepts

Schemas specify the fields that a provider, resource or data source configuration can have.

The fields defined within the schema are either attributes or blocks.

Attributes and blocks within Terraform configuration have different syntax, either using, or omitting an equals sign in their definition, respectively.

Providers, resources and data sources have their own type-specific schema, which use type-specific attributes and blocks.

The following examples use a resource but the same schema attribute and block types are also defined with the schema for providers and data sources. The examples focus on type-related information, the Optional field is included just to provide working examples but refer to Schema for information about the other fields that can be defined within attributes and blocks.

Attributes

Attributes are used to set values.

Attribute TypeDescription
BoolAttributeBoolean values (i.e., true/false)
Float64Attribute64 bit floating point number values
Int64Attribute64 bit integer number values
NumberAttributeGeneric number with up to 512 bits of floating point or integer precision
StringAttributeString values
ListAttributeList with a single element type (e.g., types.StringType)
MapAttributeMap with a single element type (e.g., types.Int64Type)
SetAttributeSet with a single element type (e.g., types.BoolType)
ObjectAttributeObject with only type information for underlying attributes
ListNestedAttributeList containing nested objects where the object attributes can be fully defined
MapNestedAttributeMap containing nested objects where the object attributes can be fully defined
SetNestedAttributeSet containing nested objects where the object attributes can be fully defined
SingleNestedAttributeSingle object where the object attributes can be fully defined

Refer to Attributes - Terraform Configuration and Schema for examples of Terraform configuration and schema that illustrate the usage of the various types of schema attributes.

Blocks

The Terraform language uses a block as a container for other attributes and blocks. Terraform implements many top level blocks, such as provider and resource, while providers can implement nested blocks in their schema to enable practitioners to configure data.

Use nested attributes for new schema implementations. Block support is mainly for migrating prior SDK-based providers.

The available nesting modes are:

  • List: Ordered collection of objects
  • Set: Unordered collection of objects
  • Single: One object

Refer to Blocks - Terraform Configuration for examples of Terraform configuration and schema that illustrate the usage of nested blocks.

Edit this page on GitHub

On this page

  1. Terraform Concepts
  2. Attributes
  3. Blocks
Give Feedback(opens in new tab)
  • Certifications
  • System Status
  • Terms of Use
  • Security
  • Privacy
  • Trademark Policy
  • Trade Controls
  • Give Feedback(opens in new tab)