navapbc / template-infra

A template to set up foundational infrastructure for your application in AWS
Apache License 2.0
9 stars 2 forks source link

Set non-default workspaces as temporary #649

Closed rocketnova closed 1 week ago

rocketnova commented 2 weeks ago

Ticket

Changes

What was added, updated, or removed in this PR.

  • Updates the database layer to support is_temporary
  • Updates the service layer to set is_temporary to true for any non-default workspace

Context for reviewers

Testing instructions, background context, more in-depth details of the implementation, and anything else you'd like to call out or ask reviewers.

When using terraform, you cannot deploy the same resource with the same name. The terraform apply will fail with an error like "A resource with the ID already exists".

We have 2 current strategies to avoid this:

  1. We use a prefix local to prefix the terraform workspace name to resource names.
  2. We use is_temporary to disable creation of some resources (e.g. https://github.com/navapbc/template-infra/blob/2cda6da18c84aa5a3dfb038ab32be4fac363af21/infra/modules/service/dns.tf#L3)

The combination of these strategies allows us to avoid resource conflicts in our CI pipeline. Our CI jobs use a terraform workspace prefixed with t-. The is_temporary variable currently ensures any service layer resources deployed to a terraform workspace prefixed with t- are marked as temporary.

For platform engineers testing features in the platform-test repository, we try to manually create a new temporary terraform workspace and test out our deployments in that workspace.

This PR

This PR does the following:

Testing

Provide evidence that the code works as expected. Explain what was done for testing and the results of the test plan. Include screenshots, GIF demos, shell commands or output to help show the changes working as expected. ProTip: you can drag and drop or paste images into this textbox.

Before this PR, trying to run make infra-update-app-service APP_NAME=app ENVIRONMENT=dev in workspace rlidp on platform-test:

CleanShot 2024-06-20 at 12 49 42@2x

Successfully tested on https://github.com/navapbc/platform-test/pull/109

rocketnova commented 2 weeks ago

Related to, but not blocked by: https://github.com/navapbc/template-infra/issues/654