terraform
It uses a custom container built on the Wolfi base image with Terraform, SOPS, Git, and supporting tools pre-installed.The module supports securely decrypting a SOPS-encrypted `terraform.tfvars.json` using an optional AGE key,
and mounts it into the working directory for use during plan or apply operations.
Supported Terraform operations include `init`, `apply`, and `destroy`. The module always runs `terraform init` first,
and then executes the specified operation. After execution, any sensitive files such as the decrypted tfvars file are deleted.
The module also exposes helper methods:
- `Version`: returns the installed Terraform version.
- `Output`: retrieves Terraform outputs in JSON format.
- `DecryptSops`: decrypts a file using SOPS and returns its content as a string.
It is designed to run Terraform commands reproducibly in CI pipelines or local development environments with secret handling and plugin caching.
Installation
dagger install github.com/stuttgart-things/dagger/terraform@v0.13.6
Entrypoint
Return Type
Terraform
Example
dagger -m github.com/stuttgart-things/dagger/terraform@4024f62d194980be2877f069bfee9d44932b0cc1 call \
func (m *MyModule) Example() *dagger.Terraform {
return dag.
Terraform()
}
@function
def example() -> dagger.Terraform:
return (
dag.terraform()
)
@func()
example(): Terraform {
return dag
.terraform()
}
Types
Terraform 🔗
baseImage() 🔗
Return Type
String !
Example
dagger -m github.com/stuttgart-things/dagger/terraform@4024f62d194980be2877f069bfee9d44932b0cc1 call \
base-image
func (m *MyModule) Example(ctx context.Context) string {
return dag.
Terraform().
BaseImage(ctx)
}
@function
async def example() -> str:
return await (
dag.terraform()
.base_image()
)
@func()
async example(): Promise<string> {
return dag
.terraform()
.baseImage()
}
version() 🔗
Return Type
String !
Example
dagger -m github.com/stuttgart-things/dagger/terraform@4024f62d194980be2877f069bfee9d44932b0cc1 call \
version
func (m *MyModule) Example(ctx context.Context) string {
return dag.
Terraform().
Version(ctx)
}
@function
async def example() -> str:
return await (
dag.terraform()
.version()
)
@func()
async example(): Promise<string> {
return dag
.terraform()
.version()
}
execute() 🔗
Return Type
Directory !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
terraformDir | Directory ! | - | No description provided |
operation | String | "apply" | No description provided |
Example
dagger -m github.com/stuttgart-things/dagger/terraform@4024f62d194980be2877f069bfee9d44932b0cc1 call \
execute --terraform-dir DIR_PATH
func (m *MyModule) Example(terraformDir *dagger.Directory) *dagger.Directory {
return dag.
Terraform().
Execute(terraformDir)
}
@function
def example(terraform_dir: dagger.Directory) -> dagger.Directory:
return (
dag.terraform()
.execute(terraform_dir)
)
@func()
example(terraformDir: Directory): Directory {
return dag
.terraform()
.execute(terraformDir)
}
output() 🔗
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
terraformDir | Directory ! | - | No description provided |
Example
dagger -m github.com/stuttgart-things/dagger/terraform@4024f62d194980be2877f069bfee9d44932b0cc1 call \
output --terraform-dir DIR_PATH
func (m *MyModule) Example(ctx context.Context, terraformDir *dagger.Directory) string {
return dag.
Terraform().
Output(ctx, terraformDir)
}
@function
async def example(terraform_dir: dagger.Directory) -> str:
return await (
dag.terraform()
.output(terraform_dir)
)
@func()
async example(terraformDir: Directory): Promise<string> {
return dag
.terraform()
.output(terraformDir)
}