Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add custom output path for the DB migrate lambda #47

Conversation

tgvashworth
Copy link
Contributor

We had a problem where we were seeing Terraform config drift and unstable plans because the db_migrate_lambda.zip file was being written inside the terraform module folder, which can be outside the repo folder (e.g. if TF_DATA_DIR is set). That means there is no zip file (or index.py) available to a fresh plan and so TF detects a deletion.

A solution to this is to commit or to cache the zip file across builds, but this TF module does not allow that location to be customised.

This PR makes two changes:

  1. The contents of the migrate lambda Python file are now inlined, which makes for one fewer files to manage
  2. There's a variable that specifies the output location so it can be written to the repo/cache location

To test this:

  • I linked the repo that is using this module to our remote branch and verified that the plan became stable and nothing else changes
  • I checked the contents of the zip file to verify it still contained a single index.py file
  • I did not verify the lambda behaviour (not sure how; happy to try)

This removes the need for a .py file to be generated.
This allows the path to be set to a specific location and committed or
cached, so that it is not recreated unnecessarily in an automation
context.
@tgvashworth
Copy link
Contributor Author

@oavdeev Hey! Do you think someone will be able to have a look at this soon?

@tgvashworth
Copy link
Contributor Author

Following up on this: we are using a fork of the TF config with this commit, and the lambda etc is all working fine.

Copy link
Member

@oavdeev oavdeev left a comment

Choose a reason for hiding this comment

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

looks good! sorry it took a while to get to it. And archive_file is a weird beast for sure, creating things as a side effect on a data source read, not the first time that causes some quirks..

@leogargu
Copy link

This would fix the perpetual diff we see in our pipelines! ✨ Can it be merged please?
Happy to help if needed.

@oavdeev
Copy link
Member

oavdeev commented Oct 24, 2023

Merged as #81

@oavdeev oavdeev closed this Oct 24, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants