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

Add ability to force unlock TF state and fix digest value of lock file in DynamoDB #235

Merged
merged 13 commits into from
Sep 7, 2023

Commits on Aug 30, 2023

  1. Add ability to force unlock TF state

    Sometimes, if a failure occurs or you've Ctrl+C'ed out of the middle of
    an apply, the Terraform state may be left in a locked state. When this
    happens, you must run 'terraform force-unlock' with the lock ID to
    unlock it.
    
    This change detects when an apply results in a lock error, and prompts
    the user to rerun the command with the --force-unlock flag. It does this
    by capturing the stderr stream of the 'terraform apply' command to
    inspect the message if an error occurs. An added bonus is that since we
    are using Popen to execute the command, we can handle things more
    gracefully if a user Ctrl+Cs out of the apply and allow Terraform to
    release the lock, reducing the amount of ways we can get into this
    failure state.
    
    In order to support the --force-unlock flag, there will be a change to
    the civiform-deploy repo as well.
    nb1701 committed Aug 30, 2023
    Configuration menu
    Copy the full SHA
    bac0f13 View commit details
    Browse the repository at this point in the history
  2. Add ability to fix digest value of lock file in DynamoDB

    If something goes wrong during deployment, especially when a user has force-unlocked due to a previous issue and then multiple apply actions are happening at once, the digest value for the Terraform lock file in S3 can be incorrect. This lets us set the digest value to the correct value, as given by the error message of a previous Terraform command, without having to go into the AWS console to set it manually.
    nb1701 committed Aug 30, 2023
    Configuration menu
    Copy the full SHA
    3eefba4 View commit details
    Browse the repository at this point in the history
  3. Add bin/fmt script

    This currently relies on the binaries being installed locally. We may want to move to using the civiform formatter container instead, or something like it, in the future.
    nb1701 committed Aug 30, 2023
    Configuration menu
    Copy the full SHA
    b444d9e View commit details
    Browse the repository at this point in the history
  4. Formatting fixes

    nb1701 committed Aug 30, 2023
    Configuration menu
    Copy the full SHA
    8defbc2 View commit details
    Browse the repository at this point in the history
  5. Remove debug stuff

    nb1701 committed Aug 30, 2023
    Configuration menu
    Copy the full SHA
    d48cbb9 View commit details
    Browse the repository at this point in the history
  6. Perform fixes during the run if running interactively

    If we hit a TF lock state issue, or the S3 digest issue, this allows the
    user to fix the problem during this particular invocation of the
    command, so they do not need to rerun the command. If we are not running
    in a TTY, we'll fall back to prompting the user to rerun the command
    with the appropriate flag.
    nb1701 committed Aug 30, 2023
    Configuration menu
    Copy the full SHA
    cf00e08 View commit details
    Browse the repository at this point in the history
  7. bin/fmt fixes

    nb1701 committed Aug 30, 2023
    Configuration menu
    Copy the full SHA
    acffcdc View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    42235a7 View commit details
    Browse the repository at this point in the history
  9. Inline comments

    nb1701 committed Aug 30, 2023
    Configuration menu
    Copy the full SHA
    cadc160 View commit details
    Browse the repository at this point in the history
  10. Change to using env vars instead of flags when rerunning a command to…

    … fix a problem
    
    This allows us not to have to change a CE's fork of civiform-deploy.
    nb1701 committed Aug 30, 2023
    Configuration menu
    Copy the full SHA
    ce693fb View commit details
    Browse the repository at this point in the history
  11. Formatting fixes

    nb1701 committed Aug 30, 2023
    Configuration menu
    Copy the full SHA
    1d0f21c View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    468c984 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    a129878 View commit details
    Browse the repository at this point in the history