Amba.TfVars 1.5.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Amba.TfVars --version 1.5.1                
NuGet\Install-Package Amba.TfVars -Version 1.5.1                
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="Amba.TfVars" Version="1.5.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Amba.TfVars --version 1.5.1                
#r "nuget: Amba.TfVars, 1.5.1"                
#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.
// Install Amba.TfVars as a Cake Addin
#addin nuget:?package=Amba.TfVars&version=1.5.1

// Install Amba.TfVars as a Cake Tool
#tool nuget:?package=Amba.TfVars&version=1.5.1                

Terraform TfVars files parser and serializer for DotNet C#

This is a simple parser and serializer for Terraform .tfvars files into a tree of nodes. The main purpose is to provide a way to refactor and restructure for transform .tfvars files. The library is written in C# and it is based on the ANTLR4 library.

Installation

The Amba.TfVars package is available on NuGet.

dotnet add package Amba.TfVars

Usage

Parsing

var tfvarsNodes = TfVarsContent.Deserialize("key = value");

Serializing

var tfvarsString = TfVarsContent.Serialize(tfvarsNodes);

Tree navigation

const string varfile = """
                           users = [                                
                               {
                                   name = "Jane"
                                   email = "jane@x.com"
                                   meta = {
                                       age = 25
                                   }
                               }
                            ]
                       """;
var parsed = TfVarsContent.Parse(varfile);
Assert.Equal(25, (int)parsed["users"][0]["meta"]["age"]);

Known limitations

  • The parser doesn't do any validation on the content of the tfvars file.
  • The serializer does code format which is not the same as terraform fmt does.
  • The parser doesn't support multiline strings done with <<EOF syntax.

Release notes

Version Description
1.5.1 Add terraform formatting for some cases.
1.5.0 Add NullNode to handle comments after.
1.4.0 Add OneLine boolean property to determine if map or list is declared one -line expression.
1.3.0 Support comments in for maps and variables.
1.2.0 MapNode ordering extension. Can be used to use order for all objects.
1.1.2 Add constructors for constructing tfvars configuration in c# code
1.1.0 Base class has index operator for all nodes of parsed tree. The same as JToken in Newtonsoft.Json.
1.0.0 Initial version

License

Do whatever you want with this code. It is provided as is without any warranty.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.5.2 41 11/20/2024
1.5.1 57 11/20/2024
1.3.0 76 11/16/2024
1.1.3 84 10/26/2024
1.1.1 77 10/26/2024