A Workspace of Terraform Configuration.
Type
CRD
Group
tf.upbound.io
Version
v1beta1
apiVersion: tf.upbound.io/v1beta1
kind: Workspace
A WorkspaceSpec defines the desired state of a Workspace.
WorkspaceParameters are the configurable fields of a Workspace.
Arguments to be included in the terraform apply CLI command
Arguments to be included in the terraform destroy CLI command
Environment variables.
Arguments to be included in the terraform init CLI command
Arguments to be included in the terraform plan CLI command
Files of configuration variables. Explicitly declared vars take precedence.
THIS IS A BETA FIELD. It is on by default but can be opted out through a Crossplane feature flag. ManagementPolicies specify the array of actions Crossplane is allowed to take on the managed and external resources. This field is planned to replace the DeletionPolicy field in a future release. Currently, both could be set independently and non-default values would be honored if the feature flag is enabled. If both are custom, the DeletionPolicy field will be ignored. See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md
ProviderConfigReference specifies how the provider that will be used to create, observe, update, and delete this managed resource should be configured.
Policies for referencing.
PublishConnectionDetailsTo specifies the connection secret config which contains a name, metadata and a reference to secret store config to which any connection details for this managed resource should be written. Connection details frequently include the endpoint, username, and password required to connect to the managed resource.
WriteConnectionSecretToReference specifies the namespace and name of a Secret to which any connection details for this managed resource should be written. Connection details frequently include the endpoint, username, and password required to connect to the managed resource. This field is planned to be replaced in a future release in favor of PublishConnectionDetailsTo. Currently, both could be set independently and connection details would be published to both without affecting each other.
A WorkspaceStatus represents the observed state of a Workspace.
Conditions of the resource.
sample-inline-with-env
apiVersion: tf.upbound.io/v1beta1
kind: Workspace
metadata:
name: sample-inline-with-env
spec:
forProvider:
env:
- name: TF_VAR_vpcName
value: sample-tf-inline-with-env
- configMapKeyRef:
key: envfromconfigmap
name: provider-terraform-test
namespace: default
name: TF_VAR_EnvFromConfigMap
- name: TF_VAR_EnvFromSecret
secretKeyRef:
key: envfromsecret
name: provider-terraform-test
namespace: default
module: |
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
tags = {
Name = var.vpcName
EnvFromConfigMap = var.EnvFromConfigMap
EnvFromSecret = var.EnvFromSecret
}
}
resource "aws_subnet" "main" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.1.0/24"
}
output "vpc_id" {
value = aws_vpc.main.id
}
output "subnet_data" {
value = {
"id" = aws_subnet.main.id
"arn" = aws_subnet.main.arn
}
}
variable "vpcName" {
description = "VPC name"
type = string
}
variable "EnvFromConfigMap" {
description = "Environment Value From ConfigMap"
type = string
}
variable "EnvFromSecret" {
description = "Environment Value From Secret"
type = string
}
source: Inline
sample-inline
apiVersion: tf.upbound.io/v1beta1
kind: Workspace
metadata:
name: sample-inline
spec:
forProvider:
module: |
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
tags = {
Name = var.vpcName
}
}
resource "aws_subnet" "main" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.1.0/24"
}
output "vpc_id" {
value = aws_vpc.main.id
}
output "subnet_data" {
value = {
"id" = aws_subnet.main.id
"arn" = aws_subnet.main.arn
}
}
variable "vpcName" {
description = "VPC name"
type = string
}
source: Inline
vars:
- key: vpcName
value: sample-tf-inline
providerConfigRef:
name: aws-eu-west-1
example-random-generator
apiVersion: tf.upbound.io/v1beta1
kind: Workspace
metadata:
annotations:
crossplane.io/external-name: random
meta.upbound.io/example-id: tf/v1beta1/workspace
name: example-random-generator
spec:
forProvider:
enableTerraformCLILogging: true
module: >
resource "random_id" "example_id" {
byte_length = 8
}
resource "random_password" "password" {
length = 16
special = true
}
// Non-sensitive Outputs are written to status.atProvider.outputs and to the connection secret.
output "random_id_hex" {
value = random_id.example_id.hex
}
// Sensitive Outputs are only written to the connection secret
output "random_password" {
value = random_password.password
sensitive = true
}
// Terraform has several other random resources, see the random provider for details
source: Inline
writeConnectionSecretToRef:
name: terraform-workspace-example-random-generator
namespace: default
sample-remote
apiVersion: tf.upbound.io/v1beta1
kind: Workspace
metadata:
name: sample-remote
spec:
forProvider:
module: git::https://github.com/ytsarev/provider-terraform-test-module.git//transition?ref=main
source: Remote
vars:
- key: vpcName
value: sample-tf-remote
example-remote
apiVersion: tf.upbound.io/v1beta1
kind: Workspace
metadata:
annotations:
crossplane.io/external-name: myworkspace
meta.upbound.io/example-id: tf/v1beta1/workspace
name: example-remote
spec:
forProvider:
module: git::https://github.com/crossplane/tf?ref=main
source: Remote
varFiles:
- configMapKeyRef:
key: example.tfvars
name: terraform
namespace: default
source: ConfigMapKey
- format: JSON
secretKeyRef:
key: example.tfvar.json
name: terraform
namespace: default
source: SecretKey
vars:
- key: region
value: us-west-1
writeConnectionSecretToRef:
name: terraform-workspace-example-remote
namespace: default
example-random-generator
apiVersion: tf.upbound.io/v1beta1
kind: Workspace
metadata:
annotations:
crossplane.io/external-name: random
meta.upbound.io/example-id: tf/v1beta1/workspace
name: example-random-generator
spec:
forProvider:
module: >
resource "random_id" "example_id" {
byte_length = 4
}
resource "random_password" "password" {
length = 16
special = true
}
// Non-sensitive Outputs are written to status.atProvider.outputs and to the connection secret.
output "random_id_hex" {
value = random_id.example_id.hex
}
// Sensitive Outputs are only written to the connection secret
output "random_password" {
value = random_password.password
sensitive = true
}
// Terraform has several other random resources, see the random provider for details
source: Inline
writeConnectionSecretToRef:
name: terraform-workspace-example-random-generator
namespace: default
sample-inline
apiVersion: tf.upbound.io/v1beta1
kind: Workspace
metadata:
name: sample-inline
spec:
forProvider:
module: |
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
tags = {
Name = var.vpcName
}
}
resource "aws_subnet" "main" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.1.0/24"
}
output "vpc_id" {
value = aws_vpc.main.id
}
output "subnet_id" {
value = aws_subnet.main.id
}
variable "vpcName" {
description = "VPC name"
type = string
}
source: Inline
vars:
- key: vpcName
value: sample-tf-inline
example-inline
apiVersion: tf.upbound.io/v1beta1
kind: Workspace
metadata:
annotations:
crossplane.io/external-name: coolbucket
meta.upbound.io/example-id: tf/v1beta1/workspace
name: example-inline
spec:
forProvider:
module: >
// Outputs are written to the connection secret.
output "url" {
value = google_storage_bucket.example.self_link
}
resource "random_id" "example" {
byte_length = 4
}
// The google provider and remote state are configured by the provider
// config - see providerconfig.yaml.
resource "google_storage_bucket" "example" {
name = "crossplane-example-${terraform.workspace}-${random_id.example.hex}"
location = "US"
force_destroy = true
public_access_prevention = "enforced"
}
source: Inline
writeConnectionSecretToRef:
name: terraform-workspace-example-inline
namespace: default