Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Major mode of Terraform configuration file

License

NotificationsYou must be signed in to change notification settings

hcl-emacs/terraform-mode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Major mode ofTerraform configuration file

Screenshot

terraform-mode

imenu(helm-imenu)

terraform-mode

Installation

You can installterraform-mode.el fromMELPA bypackage.el.

Features

  • Syntax highlighting
  • Indentation
  • imenu
  • Formatting usingterraform fmt
  • Block folding
  • easier access to Terraform resource documentation

Block folding

terraform-mode sets upoutline-mode variables for block folding.To useoutline-mode for block folding, enableoutline-minor-modeinterraform-mode-hook:

(add-hook'terraform-mode-hook#'outline-minor-mode)

You can useoutline-toggle-children bound toC-c C-f to togglevisibility of a block at point.

We also provide functionterraform-toggle-or-indent whichfolds-or-indents. It is not bound by default, but you can bind it toTAB or any other key.

Access to Terraform resource documentation

Within aresource or adata block, typeC-c C-d C-w to open a newbrowser tab with the resource or data documentation page.

TypeC-c C-d C-c to kill the URL (i.e. copy it to the clipboard) for the documentation page rather than directly open it in the browser.

You can also typeC-c C-d C-r to insert a comment containing a link tothis documentation right above the resource or data block.

This feature requires either:

  • arequired_provider declaration in any.tf file in current directory(seeTerraform doc)
  • a workingterraform providers command. This command may require avalid token (at least for AWS).

Customize Variables

terraform-indent-level(Default:2)

Indentation size. You need to callrevert-buffer if you change this value outer of hook such aseval-expression.

terraform-format-on-save(Defaultnil)

Set tot to automatically format the buffer on save.

Sample Configuration

(custom-set-variables '(terraform-indent-level4))

Withuse-package

(use-package terraform-mode;; if using straight;; :straight t;; if using package.el;; :ensure t:custom (terraform-indent-level4):config  (defunmy-terraform-mode-init ();; if you want to use outline-minor-mode;; (outline-minor-mode 1)    )  (add-hook'terraform-mode-hook'my-terraform-mode-init))

See Also

This major-mode inherits from hcl-mode. Most of syntax features, like highlighting, indentation are implemented in hcl-mode.


[8]ページ先頭

©2009-2025 Movatter.jp