![]() |
VOOZH | about |
dotnet add package Terraform.Aspire.Hosting.Templates --version 0.1.0-preview.8
NuGet\Install-Package Terraform.Aspire.Hosting.Templates -Version 0.1.0-preview.8
<PackageReference Include="Terraform.Aspire.Hosting.Templates" Version="0.1.0-preview.8" />
<PackageVersion Include="Terraform.Aspire.Hosting.Templates" Version="0.1.0-preview.8" />Directory.Packages.props
<PackageReference Include="Terraform.Aspire.Hosting.Templates" />Project file
paket add Terraform.Aspire.Hosting.Templates --version 0.1.0-preview.8
#r "nuget: Terraform.Aspire.Hosting.Templates, 0.1.0-preview.8"
#:package Terraform.Aspire.Hosting.Templates@0.1.0-preview.8
#addin nuget:?package=Terraform.Aspire.Hosting.Templates&version=0.1.0-preview.8&prereleaseInstall as a Cake Addin
#tool nuget:?package=Terraform.Aspire.Hosting.Templates&version=0.1.0-preview.8&prereleaseInstall as a Cake Tool
👁 Quality Build
👁 Release to NuGet
👁 License
👁 GitHub Tag
Libraries for .NET Aspire to create terraform code based on templates or Cloud Development Kit (CDK) for Terraform (CDKTF).
Alpha Version is still in development - APIs may change
Aspire.Terraform supports template based generation as well as CDK for Terraform (CDKTF).
Aspire.Terraform provides a set of templates that can be used to generate Terraform code for various resource types. These templates are stored in the .\templates folder and use Handlebars syntax for dynamic content generation.
dotnet add package Terraform.Aspire.Hosting
// or
dotnet add package Terraform.Aspire.Hosting.Azure
Add .Azure package for support of Azure resources.
Add the following lines to you Aspire Host:
builder.AddTerraformTemplatePublishing()
// or
builder.AddTerraformAzureTemplatePublishing()
Define the location of template files either by defining it in the appsettings.json
"Terraform": {
"Templates": {
"TemplatesPath": "https://raw.githubusercontent.com/lolochristen/Aspire.Terraform/refs/heads/main/templates/container-apps/"
}
}
or in code
builder.AddTerraformAzureTemplatePublishing(configureOptions: options =>
{
options.TemplatesPath = "../my-templates";
});
The ./templates/container-apps in this repository contains a base template to deploy to Azure Container Apps. Other templates or targets will eventually be added.
To execute the publisher for terraform use the following command line from your Aspire Host project folder:
dotnet run --publisher terraform --output-path terraform
An integration into terragrunt is also possible by using run_cmd, see ./playground/AzureContainerApps/terragrunt for an example.
In addition to template-based generation, Aspire.Terraform also supports the use of CDK for Terraform (CDKTF). This allows developers to define their infrastructure using familiar programming languages and leverage the power of the CDK ecosystem.
Install CDK TF from here
dotnet add package Terraform.Aspire.Hosting.Cdk
Create a cdktf.json file in your Aspire Host project folder with the following content:
{
"language": "csharp",
"app": "dotnet run -project [Project].csproj --publisher terraform --output-path infra",
"projectId": "d8c23291-21cf-4f76-b40d-90cc2e384901",
"output": "infra",
"terraformProviders": [
"azure/azapi@~> 2.4"
],
"context": {}
}
Add the CDK publisher to your Aspire Host:
builder.AddTerraformCdkPublishing();
Define your environment and stacks
var terraform = builder.AddTerraformCdkEnvironment("terraform");
var mystack = terraform.AddStack<MyStack>("mystack");
public class MyStack : TerraformStack
{
public MyStack(Construct scope, string id) : base(scope, id)
{
new TerraformOutput(this, "output1", new TerraformOutputConfig()
{
Value = "Hello from MyStack"
});
}
}
Use cdktf CLI or just generate stack with '''dotnet run --publisher terraform --output-path infra''' command
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on Terraform.Aspire.Hosting.Templates:
| Package | Downloads |
|---|---|
|
Terraform.Aspire.Hosting.Azure.Templates
Package Description |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-preview.8 | 1,252 | 12/1/2025 |
| 0.1.0-preview.7 | 195 | 11/24/2025 |
| 0.1.0-preview.6 | 297 | 11/13/2025 |
| 0.1.0-preview.5 | 154 | 11/7/2025 |
| 0.1.0-preview.4 | 191 | 11/4/2025 |
| 0.1.0-preview.3 | 189 | 10/27/2025 |
| 0.1.0-preview.2 | 126 | 10/24/2025 |
| 0.1.0-preview.1 | 177 | 10/21/2025 |
| 0.1.0-preview.0 | 180 | 10/21/2025 |