Skip to content

Commit

Permalink
Install role manager dependencies on every apply (#452)
Browse files Browse the repository at this point in the history
## Ticket

Resolves #446

## Changes

- Causes pip install to occur on every apply
- Done using `timestamp()` for `trigger_replace` value

## Context for reviewers

Done to prevent case where second engineer in repo can make deployment
without lambda dependencies

## Testing

Tested in [platform-test
PR](navapbc/platform-test#58)

---------

Co-authored-by: Loren Yu <[email protected]>
  • Loading branch information
charles-nava and lorenyu authored Sep 18, 2023
1 parent 2c3faa7 commit ef73a09
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions infra/modules/database/role-manager.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@ resource "aws_lambda_function" "role_manager" {
}

# Installs python packages needed by the role manager lambda function before
# creating the zip archive. Reinstalls whenever requirements.txt changes
# creating the zip archive.
# Runs pip install on every apply so that the role manager archive file that
# is generated locally is guaranteed to have the required dependencies even
# when terraform is run by a developer that did not originally create the
# environment.
# Timestamp is used to always trigger replacement.
resource "terraform_data" "role_manager_python_vendor_packages" {
triggers_replace = file("${path.module}/role_manager/requirements.txt")

triggers_replace = timestamp()
provisioner "local-exec" {
command = "pip3 install -r ${path.module}/role_manager/requirements.txt -t ${path.module}/role_manager/vendor"
}
Expand Down

0 comments on commit ef73a09

Please sign in to comment.