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

fix(terraform): apply job fails if lock file has not been commited #617

Merged

Conversation

hknutsen
Copy link
Member

@hknutsen hknutsen commented Dec 16, 2024

Cache functionality currently breaks the workflow if the dependency lock file (.terraform.lock.hcl) has not been commited.

While it's recommended to commit the lock file, it's not required. It should be okay to skip caching plugins if lock file has not been commited.

Implementation

Check if lock file exists:

  • If yes, enable plugin cache.
  • If no, don't enable plugin cache and skip all cache related steps.

Testing

  • Tested and verified to work when lock file has been commited.
  • Tested and verified to work when lock file has not been commited.

(see results in comments)

@hknutsen
Copy link
Member Author

Lock file commited

Both Plan and Apply jobs run successfully:

bilde

During the Plan job, cache was both restored and saved:

bilde

During the Apply job, cache was restored:

bilde

@hknutsen
Copy link
Member Author

Lock file NOT commited

Both Plan and Apply jobs run successfully:

bilde

During the Plan job, cache was NOT restored and/or saved:

bilde

During the Apply job, cache was NOT restored:

bilde

@hknutsen hknutsen marked this pull request as ready for review December 16, 2024 07:53
@hknutsen hknutsen requested a review from a team as a code owner December 16, 2024 07:53
@hknutsen hknutsen merged commit c6292ea into main Dec 16, 2024
23 checks passed
@hknutsen hknutsen deleted the fix/terraform/apply-job-fails-if-lockfile-has-not-been-commited branch December 16, 2024 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants