The Wayback Machine - https://web.archive.org/web/20220528005849/https://github.com/antonbabenko/pre-commit-terraform/issues/256
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hook for autoformat of terraform code snippets embedded in the docs #256

Open
antonbabenko opened this issue Oct 22, 2021 · 2 comments
Open
Labels
estimate/2days feature good first issue hook/terrafmt

Comments

@antonbabenko
Copy link
Owner

@antonbabenko antonbabenko commented Oct 22, 2021

There is a utility called terrafmt that can be used to check and fix the formating of Terraform snippets embedded into usage sections in README.

How could pre-commit-terraform help solve your problem?

It would be great to have native support as a pre-commit hook.

@antonbabenko antonbabenko added the feature label Oct 22, 2021
@MaxymVlasov MaxymVlasov added the estimate/2days label Oct 25, 2021
@MaxymVlasov MaxymVlasov added the good first issue label Oct 29, 2021
@rahulmlokurte
Copy link

@rahulmlokurte rahulmlokurte commented Dec 30, 2021

@MaxymVlasov @antonbabenko: Can I pick the terrafmt hook? I have tried it in my system. Looks like, terrafmt does not extract terraform files and does not do inline code formatting from the README.md file if, we start the Three backquotes after 4 spaces in the README.md file. It only works, if we start the Three backquotes at column 0.

Ex:

  1. Works:

image

terrafmt blocks README.md

####### B1 @ #587
resource "aws_lambda_function" "pass" {
  function_name = "test-env"
  role          = ""
  runtime       = "python3.8"

  environment {
    variables = {
      AWS_DEFAULT_REGION = "us-west-2"
    }
  }
}
  1. Does not work

image

terrafmt blocks README.md

The README.md in the repository has all the inline code starting at 4 spaces. For ex: Hooks usage notes and examples , apart from checkov, all other sections defines the inline code starting at 4 spaces.

@antonbabenko
Copy link
Owner Author

@antonbabenko antonbabenko commented Jan 3, 2022

Sounds like this is the problem in terrafmt because markdown format allows having an offset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
estimate/2days feature good first issue hook/terrafmt
3 participants