hcledit

command
v0.0.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2024 License: MIT Imports: 3 Imported by: 0

README

hcledit command

release docker

hcledit command is a CLI tool to edit HCL configuration, which exposes hcledit API as command line interface. You can think this as a sample application built by the package.

Install

Install binaries via GitHub Releases or below:

Homebrew:

$ brew tap mercari/hcledit https://github.com/mercari/hcledit
$ brew install hcledit

go get:

$ go get -u go.mercari.io/hcledit/cmd/hcledit

Docker:

$ docker run --rm -it mercari/hcledit hcledit

Examples

The following is an HCL configuration which we want to manipulate.

resource "google_container_node_pool" "nodes1" {
   name = "nodes1"

   node_config {
     preemptible  = false
     machine_type = "e2-medium"
   }
}

To read an attribute,

$ hcledit read 'resource.google_container_node_pool.*.node_config.machine_type' /path/to/file.tf
resource.google_container_node_pool.nodes1.node_config.machine_type e2-medium

To create a new attribute,

$ hcledit create 'resource.google_container_node_pool.*.node_config.image_type' 'COS' /path/to/file.tf
resource "google_container_node_pool" "nodes1" {
   name = "nodes1"

   node_config {
     preemptible  = false
     machine_type = "e2-medium"
+    image_type   = "COS"
   }
}

To update the existing attribute,

$ hcledit update 'resource.google_container_node_pool.*.node_config.machine_type' 'e2-highmem-2' /path/to/file.tf
resource "google_container_node_pool" "nodes1" {
   name = "nodes1"

   node_config {
     preemptible  = false
-    machine_type = "e2-medium"
+    machine_type = "e2-highmem-2"
   }
}

To delete the existing attribute,

$ hcledit delete 'resource.google_container_node_pool.*.node_config.machine_type' /path/to/file.tf
resource "google_container_node_pool" "nodes1" {
   name = "nodes1"

   node_config {
     preemptible  = false
-    machine_type = "e2-medium"
   }
}

Documentation

Overview

The hcledit tool provides a CRUD interface to attributes within a Terraform file.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL