You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 14, 2022. It is now read-only.
I've been trying to set this up for the last few days at our company, and I've found that this repo may need a major overhaul to accomplish this. We already have a prod environment, and I went down this road because I tried to setup a staging environment for testing. I've got a working PoC internally that I can base a PR on, but essentially here is what is necessary:
Terraform keeps state of the current directory. As such, adding a prefix will not change anything when deploying infrastructure. In fact, it will cause some of the resources to be destroyed and recreated. We don't want this at scale if I want to have both a staging and a prod environment. Nor do I want this if I want to do something like run a CI integration that vets I can always deploy a new version to an environment by creating a test environment and then tearing it down.
To solve for this, all resources need to be moved from circleci.tf to modules/ folder, with each subfolder having one module per resource grouping. So, the way I have organized it in my PoC is
The reason for this is so I can accomplish the next step.
Make variables.tf, circleci.tf, terraform.tfvars, files/, and templates/ all "templates" so to speak. Add a section to the Makefile that would allow make environment staging for example. This would then copy all of the afformentioned files to a folder structure like:
And so on. This allows for me as a consumer to run terraform init/terraform plan on any environment of my choosing in the same AWS infrastructure without colliding or breaking existing infrastructure.
The text was updated successfully, but these errors were encountered:
I've been trying to set this up for the last few days at our company, and I've found that this repo may need a major overhaul to accomplish this. We already have a prod environment, and I went down this road because I tried to setup a staging environment for testing. I've got a working PoC internally that I can base a PR on, but essentially here is what is necessary:
prefix
will not change anything when deploying infrastructure. In fact, it will cause some of the resources to be destroyed and recreated. We don't want this at scale if I want to have both astaging
and aprod
environment. Nor do I want this if I want to do something like run a CI integration that vets I can always deploy a new version to an environment by creating atest
environment and then tearing it down.resources
need to be moved fromcircleci.tf
tomodules/
folder, with each subfolder having one module per resource grouping. So, the way I have organized it in my PoC isThe reason for this is so I can accomplish the next step.
variables.tf
,circleci.tf
,terraform.tfvars
,files/
, andtemplates/
all "templates" so to speak. Add a section to theMakefile
that would allowmake environment staging
for example. This would then copy all of the afformentioned files to a folder structure like:and the sub folder structure would look like
And so on. This allows for me as a consumer to run
terraform init
/terraform plan
on any environment of my choosing in the same AWS infrastructure without colliding or breaking existing infrastructure.The text was updated successfully, but these errors were encountered: