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

Support atmos terraform apply --from-plan with additional flags #684

Merged

Conversation

duncanaf
Copy link
Contributor

what

  • Change argument generation for atmos terraform apply to make sure the plan-file arg is placed after any flags specified by the user

why

  • Terraform is very picky about the order of flags and args, and requires all args (e.g. plan-file) to come after any flags (e.g. --parallelism=1), or it crashes.
  • atmos terraform apply accepts a plan-file arg, or generates one when --from-plan is used. When this happens, it currently puts the plan-file arg first, before any additional flags specified by the user.
  • This breaks when additional flags are specified, e.g. atmos terraform apply --from-plan -- -parallelism=1. In this example, atmos tries to call terraform apply <planfile> --paralellism=1 and terraform immediately crashes with Error: Too many command line arguments

references

Right now, when atmos generates the plan-file arg for `terraform apply`,
it puts it first, and then appends any additional args or flags that may
be specified by the user. Terraform is very particular about the order
of args and flags, and crashes with an error if flags follow the
plan-file args. Instead, put the plan-file arg at the end of the
command, after any additional flags or args.

For example, with this change `atmos terraform apply -s $STACK
$COMPONENT planfile -- -parallelism=1` will call `terraform apply
-parallelism=1 planfile` instead of `terraform apply planfile
-parallelism=1`.
@duncanaf duncanaf requested review from a team as code owners August 29, 2024 02:53
@aknysh aknysh added the patch A minor, backward compatible change label Sep 1, 2024
Copy link
Member

@aknysh aknysh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @duncanaf

@aknysh aknysh merged commit 61389b2 into cloudposse:main Sep 1, 2024
21 of 22 checks passed
Copy link

github-actions bot commented Sep 1, 2024

These changes were released in v1.87.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch A minor, backward compatible change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants