Skip to content

Pretty Json Formatting from auto backend generation #778

@joshAtRula

Description

@joshAtRula

Describe the Feature

This is a cosmetic request, primarily, but can help avoid linting errors from pre-commit or other CI tools.

Right now, when components.terraform.auto_generate_backend_file is set to true in atmos.yaml, the json that is emitted is of the following format:

{
   "terraform": {
   "backend": {
   "s3": {
   "acl": "bucket-owner-full-control",
   "bucket": "my-tfstate-bucket",
   "dynamodb_table": "some-dynamo-table",
   "encrypt": true,
   "key": "terraform.tfstate",
   "profile": "main",
   "region": "us-west-2",
   "workspace_key_prefix": "something"
}
}
}
}

From a machine perspective, the formatting is irrelevant as long as the json is well-formed, but various linting checks will complain about the output, requiring manual intervention/fixes.

Expected Behavior

The json produced by the auto_generate_backend_file is beautified upon write.

Use Case

No specific challenge. We're adopting usage of atmos (we're loving it!) and this was just feedback from another engineer about the outputs. Nothing earth shattering, just a light refinement request :)

Describe Ideal Solution

Ideally, the json emitted would be beautified/formatted in a way compatible with existing json formatting tools (e.g. https://github.com/pre-commit/pre-commit-hooks/blob/main/tests/pretty_format_json_test.py) with an example below:

{
  "terraform": {
    "backend": {
      "s3": {
        "acl": "bucket-owner-full-control",
        "bucket": "my-tfstate-bucket",
        "dynamodb_table": "some-dynamo-table",
        "encrypt": true,
        "key": "terraform.tfstate",
        "profile": "main",
        "region": "us-west-2",
        "workspace_key_prefix": "something"
      }
    }
  }
}

Alternatives Considered

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions