ModPosh.TerraformRegistry 2.1.0

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

// Install ModPosh.TerraformRegistry as a Cake Tool
#tool nuget:?package=ModPosh.TerraformRegistry&version=2.1.0                
Latest Version Nuget.org Issues License Discord
Latest Version Nuget.org GitHub issues GitHub license Discord Server

TerraformRegistryClient

The TerraformRegistryClient is a C# library designed to interact with the Terraform Registry API. It allows you to list modules, search for modules, retrieve module versions, and fetch detailed module information. This client can be used in both C# and PowerShell projects.

Features

  • List Terraform modules available in the registry.
  • Search for specific modules using a search query.
  • Retrieve detailed information about specific modules.

Using the Client in C-Sharp

Below is an example of how to use the TerraformRegistryClient in your C# projects.

using ModPosh.TerraformRegistryClient;
using ModPosh.TerraformRegistryClient.Models;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        // Create a ConnectionInfo object
        var connectionInfo = new TerraformRegistryConnectionInfo("https://registry.terraform.io/v1/");

        // Create an instance of the client with the connection info
        var client = new Client(connectionInfo);

        // Example: List all modules in a specific namespace
        var modulesResponse = await client.ListModulesAsync(moduleNamespace: "hashicorp");
        foreach (var module in modulesResponse.Modules)
        {
            Console.WriteLine($"Module: {module.Name}, Provider: {module.Provider}, Version: {module.Version}");
        }

        // Example: Search for modules with a specific query
        var searchResponse = await client.SearchModulesAsync("consul");
        foreach (var module in searchResponse.Modules)
        {
            Console.WriteLine($"Found module: {module.Name}, Provider: {module.Provider}");
        }

        // Example: Get detailed information about a specific module version
        var moduleDetails = await client.GetModuleAsync("hashicorp", "consul", "aws", "0.0.1");
        Console.WriteLine($"Module Description: {moduleDetails.Description}");
    }
}

Using the Client in PowerShell

Below is an example of how to use the TerraformRegistryClient in your PowerShell scripts.

  1. Load the assembly:

    # Adjust the path to where your DLL is located
    Add-Type -Path "C:\path\to\ModPosh.TerraformRegistry.dll"
    
  2. Create an instance of the client and use its methods:

    # Create a ConnectionInfo object
    $connectionInfo = New-Object ModPosh.TerraformRegistryClient.TerraformRegistryConnectionInfo("https://registry.terraform.io/v1/")
    
    # Create an instance of the Client class with the connection info
    $client = New-Object ModPosh.TerraformRegistryClient.Client($connectionInfo)
    
    # Example: List all modules in a specific namespace
    $modulesResponse = $client.ListModulesAsync("hashicorp").Result
    foreach ($module in $modulesResponse.Modules) {
        Write-Host "Module: $($module.Name), Provider: $($module.Provider), Version: $($module.Version)"
    }
    
    # Example: Search for modules with a specific query
    $searchResponse = $client.SearchModulesAsync("consul").Result
    foreach ($module in $searchResponse.Modules) {
        Write-Host "Found module: $($module.Name), Provider: $($module.Provider)"
    }
    
    # Example: Get detailed information about a specific module version
    $moduleDetails = $client.GetModuleAsync("hashicorp", "consul", "aws", "0.0.1").Result
    Write-Host "Module Description: $($moduleDetails.Description)"
    

API Documentation

ListModulesAsync

public Task<ListModulesResponse> ListModulesAsync(string? moduleNamespace = null, int? offset = null, string? provider = null, bool? verified = null)

Lists Terraform modules available in the registry, optionally filtering by namespace, provider, and verification status.

SearchModulesAsync

public Task<ListModulesResponse> SearchModulesAsync(string searchString, int? offset = null, string? provider = null, bool? verified = null)

Searches for Terraform modules using a search query, with optional filters for provider and verification status.

ListModuleVersionAsync

public Task<ListModuleVersionResponse> ListModuleVersionAsync(string moduleNamespace, string moduleName, string moduleProvider)

Lists the versions of a specific module available in the Terraform Registry.

GetModuleAsync

public Task<GetModuleResponse> GetModuleAsync(string moduleNamespace, string moduleName, string moduleProvider, string moduleVersion)

Retrieves detailed information about a specific version of a Terraform module.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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. 
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
2.3.0 148 8/18/2024
2.2.0 120 8/18/2024
2.1.0 116 8/18/2024
2.0.0 122 8/17/2024
1.0.0 111 8/5/2024

Version 2.0.0 of TerraformRegistryClient