hashicorp / vscode-terraform Goto Github PK
View Code? Open in Web Editor NEWHashiCorp Terraform VSCode extension
Home Page: https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform
License: Mozilla Public License 2.0
HashiCorp Terraform VSCode extension
Home Page: https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform
License: Mozilla Public License 2.0
Hi,
As mention in #16. I remembered why I had installed HCL extension.
Without it I can't force the syntax highlighting on any file extension.
I have some *.hcl files but with *ctmpl extension (for consul template). With the HCL extension I can choose to force vscode to recognize those files as hcl and without I can't:
Do you think you can make it?
It would be great.
Laurent
Terraform should use #
for comments instead of //
; there was a comment fixing this in a previous version, but it looks like maybe it has returned :(
I'm running vscode 1.15.0 on OSX.
It would be nice to have code completion for the terraform resources, data sources and their supported fields.
Not a big deal, but sometimes you want to poke around and look at the .tfstate
files that Terraform manages. Apparently, they are just plain JSON, so it would be neat if this extension instructed VS Code accordingly.
Hi,
formatting on save stopped working in the last few days.
using vscode Version 1.19.0
plugin 0.0.20
Terraform v0.11.1
I can see tflint running in the output, but it is no longer formatting the code on save
When viewing a resource in a Terraform file, if it contains a HEREDOC block (for example, an IAM policy), the code folding doesn't work - the closing curly brace is correctly matched but when folding the resource the HEREDOC block remains unfolded.
Unfolded:
Folded:
VSCode version: 1.19.2, x64, Linux (Ubuntu 16.04)
plugin version: mauve.terraform 0.0.20
Hello,
Thanks for the extension. I was looking forward to use it to reduce a lot of typing with terraform.
I was trying this plugin on a mac (v10.13.33), VSCode (v1.20) and Terraform (v 0.11.3) and the autocomplete or syntax highlighting doesn't work at all.
Tried to reinstall this and VS Code as well but no luck.
Then I tried to install the other Terraform autocomplete extension (which is in beta) and it works as expected.
Can you please advise if I am missing something?
All of these should be configurable:
Usage: terraform validate [options] [dir]
Validate the terraform files in a directory. Validation includes a
basic check of syntax as well as checking that all variables declared
in the configuration are specified in one of the possible ways:
-var foo=...
-var-file=foo.vars
TF_VAR_foo environment variable
terraform.tfvars
default value
If dir is not specified, then the current directory will be used.
Options:
-check-variables=true If set to true (default), the command will check
whether all required variables have been specified.
-no-color If specified, output won't contain any color.
-var 'foo=bar' Set a variable in the Terraform configuration. This
flag can be set multiple times.
-var-file=foo Set variables in the Terraform configuration from
a file. If "terraform.tfvars" is present, it will be
automatically loaded if this flag is not specified.
Would love to see contextual links to the Terraform documentation.
For example:
resource "aws_s3_bucket" "my_bucket" { ...
Ctrl-clicking on aws_s3_bucket
would take the user to: https://www.terraform.io/docs/providers/aws/r/s3_bucket.html
These are supported in core vscode for some languages (https://stackoverflow.com/a/46597272/4200039 and microsoft/vscode#12146) - I suggest adding #region
support.
Also if the autoformatter did not force a space before the trailing #endregion
comment I'd prefer that.
I tried adding something like https://github.com/Microsoft/vscode/blob/6c421d85528d4ddb37dcb167b7a442e348f51378/extensions/javascript/javascript-language-configuration.json to https://github.com/mauve/vscode-terraform/blob/master/syntaxes/terraform.json and https://github.com/mauve/vscode-terraform/blob/master/terraform.configuration.json but it didn't work.
Receiving this error on the first line of all terraform files since updating to v1.0.0
Unhandled error parsing document: TypeError: Cannot read property 'indexDocument' of undefined (1, 1)
User settings:
{
"[terraform]": {
"editor.formatOnSave": true
},
...
}
In our team, almost everyone was surprised that .tf
files get reformatted on each save. It took us some time to realize that there is the terraform.formatOnSave
config option. A small suggestion would be to ship the extension with auto-formatting disabled by default.
receive the following error when saving a document in VisualStudioCode , 'terraform' unknown internal or external command. removing the extension resolves this behavior.
Hi,
Thanks for the good work on this extension.
Since the last update of vscode, the fmt on save doesn't work anymore. I have update to 0.0.7 and added "terraform.formatOnSave": true
to my use settings.
My coworker has the same problem.
Laurent.
terraform validate $dir
only works when $dir
is a directory containing terraform files, if $dir
contains directories it does not work anymore.
I am running VSCode (x64) v1.18.0 with v0.0.19 of this extension.
VSCode is being run from the extracted contents of a portable ZIP. It is not "installed" on the machine, just unzipped from the portable ZIP into a directory and executed from there.
I'm running the portable ZIP version due to a lack of admin rights, on a client-provided laptop for my current project. Admin rights may or may not be attainable, so I have to work without them for the time being.
When I choose the "Format Document" option from the command palette, I get the following error:
Sorry, but there is no formatter for 'terraform'-files installed.
I have also tried setting the path to the terraform.exe
in VSCode settings like so:
"terraform.path": "C:\\bin\\terraform.exe",
This doesn't make any difference, unfortunately.
Pressing Ctrl (just Ctrl!) opens documentation.
I'd like to only happen when I Ctrl+click, as everywhere else it works.
I'm using Ubuntu 16.04.
Hey there,
I created another vscode plugin for autocomplete since I couldn't get yours working, but now I see with the recent updates that yours is way better than what I had so I'm going to bow out and leave this with you, however one of my challenges was keeping the documentation up to date and I was wondering how you were doing it?
I had started this: https://github.com/erd0s/terraform-scrape which I used to get all the data from the online docs, if you don't already have something in place I'd be happy to modify what I have to fit with your plugin, either way I'd be interested to know how you're doing it because it killed me when I was trying!
Cheers
i've been using this for a while now - its great.
but i've noticed recently on save, all of my tabs get deleted and every line in the document is spaced by 2.
removing the module corrects the issue
This happens as soon as i save my document
eg:
variable "foo" {}
variable "bar" {}
becomes
variable "foo" {}
variable "bar" {}
I am trying to reference a variable in a .tf
file in my project. I have two quotes already typed out and then I type ${
. At this point, I would expect a close-brace character (}
) to automatically be inserted at this point, but it isn't. I know (annoyingly) have to type in that character.
It would be great if this extension supported this auto-closing, like it is suggested in the README. Other IDEs support this, such as Jetbrains.
Using terraform 0.10.4 and vscode-terraform 0.0.18 with vscode user settings:
"terraform.lintPath": "/usr/local/bin/tflint",
"terraform.path": "/usr/local/Cellar/tfenv/0.5.2/versions/0.10.4",
"terraform.formatOnSave": true
Great plugin, thanks!
It would be great to allow for other extensions. For example, we use jinja2 templates to generate our terraform .tf files, so in source control our file extensions are .tf.tpl, which this plugin ignores.
It would be nice to be able to add that extension in a configuration setting, or if the plugin applied this formatting to any file extension containing .tf in it.
๐คทโโ๏ธ
Thanks again!
Hi,
I'm wondering what your thoughts are on extending auto-completion for resources and data sources. I did a quick hack to test this out (screenshot below). Do you have input / would you consider a PR to accomplish this?
A few thoughts of mine, in no particular order:
vim-terraform
project seems to accomplish the same by cloning github repos that match terraform-provider-*
, and searching for resource definitions in the source.CompletionItem.documentation
can present abbreviated documentation and link to terraform.io
Curious to have your thoughts and interested in putting a PR together if this approach seems reasonable.
It looks like #50 broke my configuration (formatting, linting, etc no longer work) since my binaries are in my home dir (e.g. ~/bin/terraform
) and child_process.execFile
doesn't spawn a shell
Changing that to /real/path/to/bin/terraform
gets things going again, but it would be nice to support at least home directory expansion again.
The terraform fmt runner is neat, but on I would prefer to have an option to disable it for tfvars
file. It makes them look really ugly with spaces between all the variables.
Multiple Win10 machines running VSCode and Terraform 0.23.
The linter does not seem happy, as all on-save events and validate fail.
terraform.validate and terraform.lint simply report 'Failed', while the on-save event reports Error: write EPIPE.
Any ideas if there are known incompatibilities that prevent the plugin from doing validation, linting?
Thanks for this plugin, it saved me a lot of time.
I'd like to have it integrated with https://github.com/wata727/tflint
Needs a LICENSE statement
Hello,
I'm looking at the config, and I would expect that terraform fmt be run when I execute a save: command s
on the Mac.
"enable": true,
"ignoreExtensionsOnSave": [
".tfsmurf"
],
"formatOnSave": true
},
I am using VS Code 1.22.2, plugin 0.0.23 of the plugin, and am running OSX 10.13.4, this was previously working, so I'm not sure why it stopped. I don't see any obvious mentions in the Console log or the Dev Tools. Nothing is registered when I execute command s
. Running terraform fmt from bash does what I expect.
Indexing is now enabled by default since vscode-terraform 0.0.21: 7d170c6#diff-b9cfc7f2cdf78a7f4b91a753d10865a2R149
This change seems to freeze Code UI on my system (Ubuntu 17.10 with code 1.21.0-1520420608) where terraform-index
is not installed.
Work-around, start Code with code --disable-extensions
and add "terraform.indexing.enabled": false
to user settings.
As soon as I change terraform.indexing.enabled from false to true, code UI freezes.
Here are some logs when that happens:
==> /home/pdecat/.config/Code/logs/20180309T110358/exthost1.log <==
[2018-03-09 13:07:13.692] [exthost1] [info] ExtensionService#_doActivateExtension mauve.terraform {"startup":false,"activationEvent":"onLanguage:terraform"}
[2018-03-09 13:07:13.692] [exthost1] [info] ExtensionService#loadCommonJSModule /home/pdecat/.vscode/extensions/mauve.terraform-0.0.21/out/src/extension
==> /home/pdecat/.config/Code/logs/20180309T110358/main.log <==
[2018-03-09 13:04:28.563] [main] [info] update#setState checking for updates
[2018-03-09 13:04:29.238] [main] [info] update#setState idle
[2018-03-09 13:07:46.637] [main] [error] [VS Code]: detected unresponsive
Note: only the main view is frozen, menu and developer tools still work.
Since the most recent update (0.8 or 0.10 not to sure), it seems to have introduced a bug in the syntax highlighting of strings.
The attached screenshot explains it better:
After the DEFINITION
string ends, the highlighting is treating the rest of the file as a string, when it is not.
The Terraform template is definitely valid and it's not an escaping issue, the problem first occurred after I updated the plugin.
This is more of a feature request than an actual bug, but with Auto Save enabled in vscode and auto formatting on in Terrafom there are some issues.
When typing in a new line, pausing for a second will cause auto format to run and will move incomplete code around, remove lines that are needed, etc. I've found that if I put in an illegal char, that will prevent auto formatting to run until I'm ready for it to auto format.
Both features are great, but it would be nice if there was a delay on auto formatting that could be configured or invoke formatting on keystroke or button vs on save.
I have this settings on my user settings:
"[terraform]": {
"editor.formatOnSave": true
},
"editor.formatOnSave": true,
And this on my workspace settings:
"files.associations": {
"**/terraform/*/*.tf": "terraform",
"*.tf": "terraform",
"*.tfstate": "json"
,}
I cannot get format on save to work and i i choose the command directly on the palette:
There is no formatter for 'terraform'-files installed.
Terraform: Validate and Terraform:Lint give similar results
"code --version" output: 1.21.0
9a199d77c82fcb82f39c68bb33c614af01c111ba
x64
Extension version: 0.0.23
Thanks!
It ignores settings and reformats on Save event in case of autosave is enabled
If I start with this...
# The SNS topics to use for alarms when missing data, insufficient data, data has returned to OK status (health service)
variable "sns_arn_alarm" {}
variable "sns_arn_alarm_insufficient" {}
variable "sns_arn_alarm_ok" {}
When I save the file it gets turned into this...
# The SNS topics to use for alarms when missing data, insufficient data, data has returned to OK status (health service)
variable "sns_arn_alarm" {}
variable "sns_arn_alarm_insufficient" {}
variable "sns_arn_alarm_ok" {}
Personally, I'd like the lot to stay together, but if there are reasons to require the new line then I'd prefer it to be applied consistently, like this...
# The SNS topics to use for alarms when missing data, insufficient data, data has returned to OK status (health service)
variable "sns_arn_alarm" {}
variable "sns_arn_alarm_insufficient" {}
variable "sns_arn_alarm_ok" {}
Seems like with the version of 0.0.20
the "terraform.formatVarsOnSave"
does no longer exist.
How with the new version I can disable formatting for tfvars
files but leave it for tf
files?
thank you
I'm getting the following error
terraform.validate: Failed:
Error: No Terraform configuration files found in directory: /Users/tony/Code/afedulov/terraform-fargate/terraform/templates
My workspace directory is here - https://github.com/afedulov/terraform-fargate/tree/master/terraform
Running terraform validate
on the command line seems to work just fine. So i'm not sure why this is giving me issues.
It looks like /* */ style comments are not displayed as comments so it's hard to see code that uses that.
This is more of a question than an issue; is there any way to disable the "cmd" shortcut that automatically opens the browser with the terraform documentation for the resource that the cursor is in in the editor?
I found the plugin via https://marketplace.visualstudio.com/items?itemName=mauve.terraform
Yet I'm unable to find/add the extension via marketplace in Visual Studio, does it still exist ?
A terraform
HCL block was introduced recently, which so far is only used to pin the templates to a specific terraform version.
The terraform
word doesn't get highlighted as a keyword, like resource
or variable
would.
Documented here: https://www.terraform.io/docs/configuration/terraform.html#example
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.