Skip to content

Instantly share code, notes, and snippets.

@jarpy
Last active June 30, 2022 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarpy/affd883ee535e16d2d9398352c97240e to your computer and use it in GitHub Desktop.
Save jarpy/affd883ee535e16d2d9398352c97240e to your computer and use it in GitHub Desktop.
from cdktf import App
from os import environ
from typing import Final
from terrazzo.cdktf.stack import TerrazzoStack
if __name__ == "__main__":
# Check if we are running under test.
TERRAZZO_TESTING: Final[bool] = (
environ.get("TERRAZZO_TESTING", "false").lower() == "true"
)
# See if the operator is forcing a single stage ("dev", "prod"), and thus a
# single CDKTF stack ("terrazzo-dev", "terrazzo-prod").
#
# If you don't set this, CDKTF will run all our Python for both "dev", and "prod",
# even though it will only run the resulting Terraform for one of the stacks.
#
# For example, "TERRAZZO_STAGE=dev cdktf plan" can save a lot of time.
TERRAZZO_STAGE: Final[str] = environ.get("TERRAZZO_STAGE", "")
if TERRAZZO_TESTING:
stages = ["test"]
mock_api_calls = True
elif TERRAZZO_STAGE:
stages = [TERRAZZO_STAGE]
mock_api_calls = False
else:
stages = ["dev", "prod"]
mock_api_calls = False
app = App()
for stage in stages:
TerrazzoStack(scope=app, stage=stage, mock_api_calls=mock_api_calls)
app.synth()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment