Fix "invalid count argument" error #476
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ticket
Resolves #475
Changes
Additional changes
Context for reviewers
In #475, @rocketnova discovered a bug that prevents terraform from creating a plan for the database layer. The module sets the count for the db password secret to be
length(aws_rds_cluster.db.master_user_secret)
, but this is unnecessary sinceaws_rds_cluster.db.master_user_secret
will always be available as long as the rds_cluster'smanage_master_user_password
is set totrue
which will always be the case since it is hardcoded totrue
(seetemplate-infra/infra/modules/database/main.tf
Line 31 in 6b3588c
This changeset removes the unnecessary count which fixes the terraform plan.
This changeset also includes a number of minor cleanup changes:
Testing and Migration notes
Developed and tested on platform-test in this PR: navapbc/platform-test#66
Copied here for convenience:
lyfxcnt
("lorenyu fix count")make infra-update-app-database-roles APP_NAME=app ENVIRONMENT=dev
make infra-check-app-database-roles APP_NAME=app ENVIRONMENT=dev
Migration notes
If the rds database cluster already exists and has manage_master_user_password set to false, the terraform plan will fail with the following error:
thus, in order to migrate, we'll need to follow the following steps:
first do a targeted apply of the aws_rds_cluster by running the following command (replace ENVIRONMENT_NAME with the correct environment)
Then you can apply the rest of the changes normally with
make infra-update-app-database APP_NAME=app ENVIRONMENT=<ENVIRONMENT_NAME>