coinbase / terraform-landscape

Improve Terraform's plan output to be easier to read and understand
Apache License 2.0
1.58k stars 111 forks source link

Support custom output formatters #94

Open smiller171 opened 5 years ago

smiller171 commented 5 years ago

I'm using Atlantis to put my plans in GH PRs, and it would be great if landscape could better support the diff language format. Just a flag that would put the -/+ operators always at the start of the line.

Current:

Switched to workspace "test".

~ aws_ecs_service.webapp
    task_definition:   "redacted_webapp:64" => "${aws_ecs_task_definition.webapp.family}:${max("${aws_ecs_task_definition.webapp.revision}", "${aws_ecs_task_definition.webapp.revision}")}"

-/+ aws_ecs_task_definition.webapp (new resource required)
    id:                      "redacted_webapp" => "<computed>" (forces new resource)
    arn:                     "arn:aws:ecs:redacted:redacted:task-definition/redacted_webapp:64" => "<computed>"
    container_definitions:   "name": "MAIL_PROTOCOL",
                                      "value": "smtp"
                                    }
                                  ],
                                  "essential": true,
                             -    "image": "redacted.dkr.ecr.redacted.amazonaws.com/redacted:82bd2bb",
                             +    "image": "redacted.dkr.ecr.redacted.amazonaws.com/redacted:124c156",
                                  "logConfiguration": {
                                    "logDriver": "awslogs",
                                    "options": {
                                      "awslogs-create-group": "true",
                                      "awslogs-group": "php-logs-test",
                                  ],
                                  "environment": [

                                  ],
                                  "essential": true,
                             -    "image": "redacted.dkr.ecr.redacted.amazonaws.com/nginx:82bd2bb",
                             +    "image": "redacted.dkr.ecr.redacted.amazonaws.com/nginx:124c156",
                                  "links": [
                                    "redacted"
                                  ],
                                  "logConfiguration": {
                                    "logDriver": "awslogs", (forces new resource)
    network_mode:            "" => "<computed>"
    revision:                "64" => "<computed>"

Plan: 1 to add, 1 to change, 1 to destroy.

Proposed:

Switched to workspace "test".

~ aws_ecs_service.webapp
    task_definition:   "redacted_webapp:64" => "${aws_ecs_task_definition.webapp.family}:${max("${aws_ecs_task_definition.webapp.revision}", "${aws_ecs_task_definition.webapp.revision}")}"

-/+ aws_ecs_task_definition.webapp (new resource required)
    id:                      "redacted_webapp" => "<computed>" (forces new resource)
    arn:                     "arn:aws:ecs:redacted:redacted:task-definition/redacted_webapp:64" => "<computed>"
    container_definitions:   "name": "MAIL_PROTOCOL",
                                      "value": "smtp"
                                    }
                                  ],
                                  "essential": true,
-                                 "image": "redacted.dkr.ecr.redacted.amazonaws.com/redacted:82bd2bb",
+                                 "image": "redacted.dkr.ecr.redacted.amazonaws.com/redacted:124c156",
                                  "logConfiguration": {
                                    "logDriver": "awslogs",
                                    "options": {
                                      "awslogs-create-group": "true",
                                      "awslogs-group": "php-logs-test",
                                  ],
                                  "environment": [

                                  ],
                                  "essential": true,
-                                 "image": "redacted.dkr.ecr.redacted.amazonaws.com/nginx:82bd2bb",
+                                 "image": "redacted.dkr.ecr.redacted.amazonaws.com/nginx:124c156",
                                  "links": [
                                    "redacted"
                                  ],
                                  "logConfiguration": {
                                    "logDriver": "awslogs", (forces new resource)
    network_mode:            "" => "<computed>"
    revision:                "64" => "<computed>"

Plan: 1 to add, 1 to change, 1 to destroy.
sds commented 5 years ago

Open to a pull request adding this functionality.

smiller171 commented 5 years ago

I would but I've never used Ruby. I looked through the code a bit but couldn't quite grok what I'd need to change where.