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

Github diff markdown formatting broken when adding new resources #2497

Closed
mivok opened this issue Sep 6, 2022 · 2 comments
Closed

Github diff markdown formatting broken when adding new resources #2497

mivok opened this issue Sep 6, 2022 · 2 comments
Labels
bug Something isn't working waiting-on-response Waiting for a response from the user

Comments

@mivok
Copy link

mivok commented Sep 6, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Overview of the Issue

In #2337 a change was made to try to identify only terraform specific changes when performing modifications to terraform plan output to make it look nicer in github. However, it doesn't work when adding new resources where the values are not (known after apply). For example, the following aws_route53_record resource is formatted incorrectly:

  # module.foo.aws_route53_record.bar will be created
  + resource "aws_route53_record" "bar" {
      + allow_overwrite = (known after apply)
      + fqdn            = (known after apply)
      + id              = (known after apply)
      + name            = "bar.example.com"
      + type            = "A"
      + zone_id         = "REDACTED"

      + alias {
          + evaluate_target_health = true
          + name                   = (known after apply)
          + zone_id                = (known after apply)
        }
    }

gets formatted as:

  # module.foo.aws_route53_record.bar will be created
+   resource "aws_route53_record" "bar" {
+       allow_overwrite = (known after apply)
+       fqdn            = (known after apply)
+       id              = (known after apply)
      + name            = "bar.example.com"
      + type            = "A"
      + zone_id         = "REDACTED"

+       alias {
          + evaluate_target_health = true
+           name                   = (known after apply)
+           zone_id                = (known after apply)
        }
    }

which is even more confusing than the case where the diff formatting hasn't been applied.

Reproduction Steps

  • Run atlantis with --enable-diff-markdown-format (or the equivalent environment variable) and configured to run against a github repository.
  • Create a new terraform configuration with a simple resource, such as a route53 zone (a route53 record was shown above, but it's easier to reproduce by adding a resource that doesn't depend on something else, such as a route53 zone). Ensure there are some values you specify directly (e.g. the name of the resource). A trivial example would be:
    resource "aws_route53_zone" "foo" {
      name = "foo.example.com"
    }
    (don't worry about the name of the zone, we're only going to run terraform plan and not actually create anything)
  • Optional: run terraform plan locally to verify the plan output. It should look something like this (with the beginning part of the plan stripped off):
    Terraform will perform the following actions:
    
      # aws_route53_zone.foo will be created
      + resource "aws_route53_zone" "foo" {
          + arn           = (known after apply)
          + comment       = "Managed by Terraform"
          + force_destroy = false
          + id            = (known after apply)
          + name          = "foo.example.com"
          + name_servers  = (known after apply)
          + tags_all      = (known after apply)
          + zone_id       = (known after apply)
        }
    
    Plan: 1 to add, 0 to change, 0 to destroy.
    
  • Commit the change to a branch, push it to github, and open a PR
  • View the atlantis plan output, and see that it looks something like this (the beginning part of the output is stripped off):
    Terraform will perform the following actions:
    
      # aws_route53_zone.foo will be created
    +   resource "aws_route53_zone" "foo" {
    +       arn           = (known after apply)
          + comment       = "Managed by Terraform"
          + force_destroy = false
    +       id            = (known after apply)
          + name          = "foo.example.com"
    +       name_servers  = (known after apply)
    +       tags_all      = (known after apply)
    +       zone_id       = (known after apply)
        }
    
    Plan: 1 to add, 0 to change, 0 to destroy.

Environment details

  • Atlantis version: 0.19.8
  • Relevant atlantis flags: --enable-diff-markdown-format (and appropriate configuration to have atlantis work with github)
@mivok mivok added the bug Something isn't working label Sep 6, 2022
@jamengual
Copy link
Contributor

I think this will fix your issue #2418

@jamengual jamengual added the waiting-on-response Waiting for a response from the user label Sep 8, 2022
@mivok
Copy link
Author

mivok commented Sep 14, 2022

I haven't tested it with an actual atlantis install yet (I'll wait on the next release for that), but my quick test script I was using to reproduce the issue works fine with the regex changes. Thank you.

@mivok mivok closed this as completed Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working waiting-on-response Waiting for a response from the user
Projects
None yet
Development

No branches or pull requests

2 participants