Garrard.TerraformLib
0.0.2
dotnet add package Garrard.TerraformLib --version 0.0.2
NuGet\Install-Package Garrard.TerraformLib -Version 0.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Garrard.TerraformLib" Version="0.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Garrard.TerraformLib" Version="0.0.2" />
<PackageReference Include="Garrard.TerraformLib" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Garrard.TerraformLib --version 0.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Garrard.TerraformLib, 0.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Garrard.TerraformLib&version=0.0.2
#tool nuget:?package=Garrard.TerraformLib&version=0.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Garrard.TerraformLib
.NET library for updating and formatting Terraform .tfvars
files.
Installation
You can install the package via NuGet:
.NET CLI
dotnet add package Garrard.TerraformLib --version 0.0.2
Package Manager
Install-Package Garrard.TerraformLib -Version 0.0.2
PackageReference
Add the following XML node into your project file to reference the package:
<PackageReference Include="Garrard.TerraformLib" Version="0.0.2" />
Paket CLI
paket add Garrard.TerraformLib --version 0.0.2
Usage
Here is an example of how to use the library:
using Garrard.TerraformLib;
namespace Garrard.TerraformLab.Sample
{
class Program
{
static void Main()
{
string filePath = "env/lz-sub-base.tfvars";
string modifiedFilePath = "env/lz-sub.tfvars";
// load tfvars file
string fileContent = FileOperations.LoadFile(filePath);
// Parse the content into a dictionary
var parsedContent = TfvarsOperations.ConvertTo(fileContent);
// Example 1: Update the vnet1.name for dev_sub
TfvarsOperations.UpdateNestedProperty(parsedContent,new List<string> { "subscriptions", "dev_sub", "virtual_network", "vnet1", "name" }, "new_vnet_name", Console.WriteLine);
// Example 2: Update the tag in resource_group_tags
TfvarsOperations.UpdateNestedProperty(parsedContent,
new List<string>
{
"subscriptions", "dev_sub", "virtual_network", "vnet1", "resource_group_tags",
"FJ-UPE-LZ-ENVIRONMENT"
}, "dev-env"), Console.WriteLine;
// Convert the dictionary back to tfvars, then format
string changed = TfvarsOperations.ConvertFrom(parsedContent);
string formatted = TfvarsOperations.Fmt(changed);
// Write the updated content back to the file
FileOperations.SaveFile(modifiedFilePath, formatted);
Console.WriteLine(formatted);
Console.WriteLine("File updated successfully.");
}
}
}
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Please refer to the README