Skip to content

Blocks

Block Modules are normal Terraform modules that are treated as Blocks in Nullstone.

These modules have no special functionality beyond normal Terraform; they are typically used for areas of infrastructure that are not tightly managed by Nullstone. For this reason, a block module is a great starting point when import existing infrastructure and creating new modules into Nullstone.

Terraform Data Sources

ns_workspace

A Nullstone workspace is a block launched into an environment. Nullstone injects the organization, stack, block, and environment information into a Terraform plan through the ns_workspace data source.

The following content demonstrates usage of this data source.

hcl
data "ns_workspace" "this" {}

locals {
  tags       = data.ns_workspace.this.tags
  block_name = data.ns_workspace.this.block_name
}
data "ns_workspace" "this" {}

locals {
  tags       = data.ns_workspace.this.tags
  block_name = data.ns_workspace.this.block_name
}

ns_connection

In Nullstone, it is common for a block to rely on another block. For example, a cluster operates inside a network and needs information about the network.

Connection

The ns_connection data source provides access to other workspace outputs. The ns_connection defines a connection that is a user configures when launching workspaces in Nullstone. The following example demonstrates defining a network of type network/aws.

hcl
data "ns_connection" "network" {
  name = "network"
  type = "network/aws"
}
data "ns_connection" "network" {
  name = "network"
  type = "network/aws"
}

The above type refers to the Module Type that is specified when creating new modules in the Nullstone registry. See Contracts to learn more about type.

Outputs

The ns_connection data source provides outputs exactly like terraform_remote_state. The following example demonstrates retrieving outputs from the connection.

hcl
data "ns_connection" "network" {
  name = "network"
  type = "network/aws"
}

locals {
  vpc_id = data.ns_connection.network.outputs.vpc_id
}
data "ns_connection" "network" {
  name = "network"
  type = "network/aws"
}

locals {
  vpc_id = data.ns_connection.network.outputs.vpc_id
}