-
Notifications
You must be signed in to change notification settings - Fork 13
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
fix: Add missing change.actions values to planfile.ts #7
Conversation
https://developer.hashicorp.com/terraform/internals/json-format#change-representation has two entries in change.actions that aren't currently in the definition for planfileSchema: ['read'] and ['create', 'delete']. This commit adds those to the Zod definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! I have no objection to adding the read
option (I didn't know this is an option that is actually returned during plan
). Would you prefer displaying read resources in the PR comment or should they be excluded?
Regarding ["create", "delete"]
, I'm wondering (1) why would that ever happen during apply and (2) how to integrate this into the current representation in the PR. What does this do semantically, "re-delete"? 😄
I think it's okay to not display read resources, since the action doesn't display them at the moment. They could perhaps be added in a later PR. Looking at https://developer.hashicorp.com/terraform/internals/json-format#plan-representation and at the plan JSON I was testing with, there's a
I was surprised by this too! I think it's one way that a replacement can be represented - create a new thing, then delete the old thing - but it is very strange compared to the other way around. 😄 |
Apologies, I noticed that CI had failed due to a syntax error where I added one of the action types - I've added the missing comma to planfile.ts. |
Sorry for getting back to you so late here @isobelhooper! Let's not display the read resources for the time being, we can do that in a follow-up PR. Regarding |
As far as CI is concerned:
|
@borchero I've just had this (or something very like it) crop up, where terraform-plan-commit fails with zodErrors about invalid literals that looks identical to @isobelhooper 's error above. I've got both the terraform plan text output and the -out saved, if that's useful. The error, though, is somewhat hard to reproduce - if I write some code to create an S3 bucket with the usual S3 sub-resources, if I add an iam_policy_document that refers to the S3 bucket itself - something like
then this crashes terraform-plan-comment , but if i change the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry this took forever! I think this should do it now, thanks for the PR @isobelhooper :)
Wanted to say thank you again for accepting this PR, as it means it works with our Terraform state - we're now using it for our PRs and it's very useful! |
https://developer.hashicorp.com/terraform/internals/json-format#change-representation has two entries in change.actions that aren't currently in the definition for planfileSchema: ['read'] and ['create', 'delete'].
I've done very little Typescript work, but It looks like these are pretty simple to add, so I've made this PR to include them.
Motivation
I'm looking for a currently-maintained Github action to comment with summaries of
terraform plan
results on my team's PRs, and this one looks really nicely done.I tried out this action with a change to one of my team's Terraform definitions, and while the code coped fine with a plan without changes, it errored on the first change entry, which had an action of
"read"
.The error output from Zod
Changes
Adding the two possible entries for
changes.actions
that are in the current JSON output change representation but not in here yet.