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

[Issue #1519] Cherry pick platform's pattern for env vars & ssm secrets #1516

Merged
merged 7 commits into from
Mar 22, 2024

Conversation

coilysiren
Copy link
Collaborator

@coilysiren coilysiren commented Mar 21, 2024

Summary

Relates to #784

Closes #1519

Copies navapbc/template-infra#549

Time to review: 10 mins

Changes proposed

  • cherry picks platform infra template's pattern for passing in env vars and AWS SSM secrets
  • changes ENABLE_V_0_1_ENDPOINTS / enable_v01_endpoints to use the above pattern
  • does not yet change any of our SSM secrets to use platform's pattern, I plan to do that in a follow-up PR

Context for reviewers

I created this PR via tactical copy-pasting from the https://github.com/navapbc/template-infra/ repo.

The goal of this PR is to DRY our methods for setting environment variables. Notice on the red side of the diff, how I've removed the need to set enable_v01_endpoints so many times. Then notice on the green side of the diff, that I only need to set ENABLE_V_0_1_ENDPOINTS twice (for dev and staging). That's the goal of this PR, to pull in platform's very nice pattern for DRY'ing environment variables.

Testing

To test this, I added - then removed - the following block from staging.tf

  service_override_extra_environment_variables = {
    ENABLE_V_0_1_ENDPOINTS = "true"
  }

I then deployed to staging to see the difference. It worked as intended.

@github-actions github-actions bot added documentation Improvements or additions to documentation terraform infra labels Mar 21, 2024
@coilysiren coilysiren changed the title [Issue 784] Cherry pick platform pattern for env vars [Issue 784] Cherry pick platform's pattern for env vars Mar 21, 2024
@coilysiren coilysiren changed the title [Issue 784] Cherry pick platform's pattern for env vars [Issue 784] Cherry pick platform's pattern for env vars & secrets Mar 21, 2024
@coilysiren coilysiren changed the title [Issue 784] Cherry pick platform's pattern for env vars & secrets [Issue #784] Cherry pick platform's pattern for env vars & secrets Mar 21, 2024
@coilysiren coilysiren changed the title [Issue #784] Cherry pick platform's pattern for env vars & secrets [Issue #1519] Cherry pick platform's pattern for env vars & secrets Mar 22, 2024
@coilysiren coilysiren changed the title [Issue #1519] Cherry pick platform's pattern for env vars & secrets [Issue #1519] Cherry pick platform's pattern for env vars & ssm secrets Mar 22, 2024
@@ -0,0 +1,58 @@
# Environment variables and secrets
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@coilysiren
Copy link
Collaborator Author

The CI failures are related to the WAF. They dont seem related to this PR

@coilysiren coilysiren marked this pull request as ready for review March 22, 2024 16:11
Copy link
Collaborator

@chouinar chouinar 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, at least to my rough understanding of terraform

@@ -7,6 +7,5 @@ module "prod_config" {
domain = "api.simpler.grants.gov"
database_instance_count = 2
database_enable_http_endpoint = true
enable_v01_endpoints = false
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we add the ENABLE_V_0_1_ENDPOINTS value in the service overrides as false?

Doesn't technically need to be there (null == false for this), but just to have the mapping defined for prod.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@chouinar I wanted to leave it null since the string "False" is truthy, ya know?

$ python -c 'print(bool("False"))'
> True

Unless you're certain the that thing reading the env vars is casting strings to booleans "properly"!

Copy link
Collaborator

Choose a reason for hiding this comment

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

We use Pydantic for loading env vars / converting to Python types. It considers false as a false value: https://docs.pydantic.dev/2.0/usage/types/booleans/

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added! f32edb6

@coilysiren
Copy link
Collaborator Author

I was able to confirm that the terratest CI failures (eg. Infra Service Checks) aren't related to this PR. This example PR reproduces the same failures: #1522

@coilysiren coilysiren merged commit 54cb709 into main Mar 22, 2024
7 checks passed
@coilysiren coilysiren deleted the platform-env-vars branch March 22, 2024 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation infra terraform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Cherry pick Nava template's pattern for handling env vars and secrets
2 participants