From a77d79ae92d49fbcab98541e0ad5970ae44597e8 Mon Sep 17 00:00:00 2001 From: Dmitry Borisov Date: Thu, 27 Oct 2022 16:43:38 +0300 Subject: [PATCH] Add multistack monorepo --- examples/multistack-monorepo/ize.toml | 60 +++++++++++++++++++ examples/multistack-monorepo/main.tf | 0 examples/multistack-monorepo/s3/main.tf | 12 ++++ examples/multistack-monorepo/s3/variables.tf | 9 +++ examples/multistack-monorepo/variables.tf | 9 +++ examples/multistack-monorepo/vpc/main.tf | 32 ++++++++++ examples/multistack-monorepo/vpc/variables.tf | 9 +++ 7 files changed, 131 insertions(+) create mode 100644 examples/multistack-monorepo/ize.toml create mode 100644 examples/multistack-monorepo/main.tf create mode 100644 examples/multistack-monorepo/s3/main.tf create mode 100644 examples/multistack-monorepo/s3/variables.tf create mode 100644 examples/multistack-monorepo/variables.tf create mode 100644 examples/multistack-monorepo/vpc/main.tf create mode 100644 examples/multistack-monorepo/vpc/variables.tf diff --git a/examples/multistack-monorepo/ize.toml b/examples/multistack-monorepo/ize.toml new file mode 100644 index 00000000..e3ee020d --- /dev/null +++ b/examples/multistack-monorepo/ize.toml @@ -0,0 +1,60 @@ +aws_region = "us-east-1" # (required) AWS Region of this environment should be specified here. Can be overriden by AWS_PROFILE env var or --aws-region flag. +namespace = "testnut" # (required) Namespace of the project can be specified here. It is used as a base for all naming. It can be overridden by NAMESPACE env var or --namespace flag. +terraform_version = "1.2.6" # (optional) Terraform version can be set here. 1.1.3 by default +# prefer_runtime = "" # (optional) Prefer a specific runtime. (native or docker) (default 'native') +# tag = "" # (optional) Tag can be set statically. Normally it is being constructed automatically based on the git revision. +# plain_text = false # (optional) Plain text output can be enabled here. Default is false. Can be overridden by IZE_PLAIN_TEXT env var or --plain-text-output flag. +# env = "dev" # (optional) Environment name can be specified here. Normally it should be passed via `ENV` variable or --env flag. +# env_dir = "" # (optional) Environment directory can be specified here. Normally it's calculated automatically based on the directory structure convention. +# docker_registry = "" # (optional) Docker registry can be set here. By default it uses ECR repo with the name of the service. +# tf_log_path = "" # (optional) TF_LOG_PATH can be set here. +# custom_prompt = false # (optional) Custom prompt can be enabled here for all console connections. Default: false. +# aws_profile = "" # (optional) AWS Profile can be specified here (but normally it's specified via AWS_PROFILE env var) +# log_level = "" # (optional) Log level can be specified here. Possible levels: info, debug, trace, panic, warn, error, fatal(default). Can be overridden via IZE_LOG_LEVEL env var or via --log-level flag. +# ize_dir = "" # (optional) Ize directory can be specified here. Normally it's assumed to be .infra or .ize in the current repo. +# apps_path = "" # (optional) Path to apps directory can be set. By default apps are searched in 'apps' and 'projects' directories. This is needed in case your repo structure is not purely ize-structured (let's say you have 'src' repo in your dotnet app, as an example) +# root_dir = "" # (optional) Project directory can be set here. By default it's the current directory, but in case you prefer to run ize from the outside of repo it may be useful (uncommon). +# tf_log = "" # (optional) Terraform TF_LOG can be set here. Can be TRACE, DEBUG, INFO, WARN or ERROR. +# config_file = "" # (optional) Path to ize.toml config file can be specified, but normally it's read from the environment's directory automatically. +# home = "" # (optional) User home directory can be specified here. Normally $HOME is used. + +[terraform.infra] +aws_region = "us-east-1" # (optional) Terraform-specific AWS Region of this environment should be specified here. Normally global AWS_REGION is used. +# aws_profile = "" # (optional) Terraform-specific AWS profile (optional) can be specified here (but normally it should be inherited from a global AWS_PROFILE). +# version = "" # (optional) Terraform version can be set here. 1.1.3 by default. +# state_bucket_region = "" # (optional) Terraform state bucket region can be specified here. Normally AWS_REGION is used here. Can be overriden via env vars or flags. +# state_bucket_name = "" # (optional) Terraform state bucket name can be specified here. Normally it's generated and defaults to -tf-state +# root_domain_name = "" # (optional) Root domain name can be set here. This is the main domain that will be passed to the terraform. Generally if your app lives at 'api.dev.nutcorp.net' the root domain is `nutcorp.net` + +[terraform.vpc] +# aws_profile = "" # (optional) Terraform-specific AWS profile (optional) can be specified here (but normally it should be inherited from a global AWS_PROFILE). +# version = "" # (optional) Terraform version can be set here. 1.1.3 by default. +# state_bucket_region = "" # (optional) Terraform state bucket region can be specified here. Normally AWS_REGION is used here. Can be overriden via env vars or flags. +# state_bucket_name = "" # (optional) Terraform state bucket name can be specified here. Normally it's generated and defaults to -tf-state +# root_domain_name = "" # (optional) Root domain name can be set here. This is the main domain that will be passed to the terraform. Generally if your app lives at 'api.dev.nutcorp.net' the root domain is `nutcorp.net` +depends_on = ["infra"] + +[terraform.s3] +# aws_profile = "" # (optional) Terraform-specific AWS profile (optional) can be specified here (but normally it should be inherited from a global AWS_PROFILE). +# version = "" # (optional) Terraform version can be set here. 1.1.3 by default. +# state_bucket_region = "" # (optional) Terraform state bucket region can be specified here. Normally AWS_REGION is used here. Can be overriden via env vars or flags. +# state_bucket_name = "" # (optional) Terraform state bucket name can be specified here. Normally it's generated and defaults to -tf-state +# root_domain_name = "" # (optional) Root domain name can be set here. This is the main domain that will be passed to the terraform. Generally if your app lives at 'api.dev.nutcorp.net' the root domain is `nutcorp.net` +depends_on = ["infra"] + +# [ecs.] +# timeout = "" # (optional) ECS deployment timeout can be specified here. +# docker_registry = "" # (optional) Docker registry can be set here. By default it uses ECR repo with the name of the service. +# skip_deploy = false # skip deploy app +# path = "" # (optional) Path to ecs app folder can be specified here. By default it's derived from apps path and app name. +# unsafe = false # (optional) Enables unsafe mode that increases deploy time on a cost of shorter healtchecks. +# image = "" # (optional) Docker image can be specified here. By default it's derived from the app name. +# cluster = "" # (optional) ECS cluster can be specified here. By default it's derived from env & namespace +# task_definition_revision = "" # (optional) Task definition revision can be specified here. By default latest revision is used to perform a deployment. Normally this parameter can be used via cli during specific deployment needs. + +# [serverless.] +# node_version = "16" # (optional) Node version that will be used by nvm can be specified here that. Default is v14. +# path = "" # (optional) Path to the serverless app directory can be specified here. Normally it's derived from app directory and app name. +# sls_node_modules_cache_mount = "" # (optional) SLS node_modules cache mount path can be specified here. It's used to store cache during CI/CD process. +# file = "" # (optional) Path to serverless file can be specified here. Normally it's serverless.yml in the app directory. +# create_domain = false # (optional) Create domain for the serverless domain manager during the deployment. diff --git a/examples/multistack-monorepo/main.tf b/examples/multistack-monorepo/main.tf new file mode 100644 index 00000000..e69de29b diff --git a/examples/multistack-monorepo/s3/main.tf b/examples/multistack-monorepo/s3/main.tf new file mode 100644 index 00000000..04f83378 --- /dev/null +++ b/examples/multistack-monorepo/s3/main.tf @@ -0,0 +1,12 @@ +module "s3_bucket" { + source = "registry.terraform.io/terraform-aws-modules/s3-bucket/aws" + version = "~>3.0" + + bucket = "${var.env}-${var.namespace}-test-s3-bucket" + acl = "private" + + versioning = { + enabled = false + } + force_destroy = true +} diff --git a/examples/multistack-monorepo/s3/variables.tf b/examples/multistack-monorepo/s3/variables.tf new file mode 100644 index 00000000..267e4a0d --- /dev/null +++ b/examples/multistack-monorepo/s3/variables.tf @@ -0,0 +1,9 @@ +variable "env" {} +variable "namespace" {} +variable "aws_region" {} + +locals { + env = var.env + namespace = var.namespace + aws_region = var.aws_region +} diff --git a/examples/multistack-monorepo/variables.tf b/examples/multistack-monorepo/variables.tf new file mode 100644 index 00000000..267e4a0d --- /dev/null +++ b/examples/multistack-monorepo/variables.tf @@ -0,0 +1,9 @@ +variable "env" {} +variable "namespace" {} +variable "aws_region" {} + +locals { + env = var.env + namespace = var.namespace + aws_region = var.aws_region +} diff --git a/examples/multistack-monorepo/vpc/main.tf b/examples/multistack-monorepo/vpc/main.tf new file mode 100644 index 00000000..02f3d2af --- /dev/null +++ b/examples/multistack-monorepo/vpc/main.tf @@ -0,0 +1,32 @@ +module "vpc" { + source = "registry.terraform.io/terraform-aws-modules/vpc/aws" + version = "~> 3.0" + + name = "${var.env}-vpc" + cidr = "10.0.0.0/16" + + azs = [ + "${var.aws_region}a", + "${var.aws_region}b", + + ] + public_subnets = [ + "10.0.1.0/24", + "10.0.2.0/24" + ] + + private_subnets = [ + "10.0.3.0/24", + "10.0.4.0/24" + ] + + enable_nat_gateway = true + single_nat_gateway = true + enable_dns_hostnames = true + manage_default_network_acl = true + default_network_acl_name = "${var.env}-${var.namespace}" + tags = { + Terraform = "true" + Env = var.env + } +} diff --git a/examples/multistack-monorepo/vpc/variables.tf b/examples/multistack-monorepo/vpc/variables.tf new file mode 100644 index 00000000..267e4a0d --- /dev/null +++ b/examples/multistack-monorepo/vpc/variables.tf @@ -0,0 +1,9 @@ +variable "env" {} +variable "namespace" {} +variable "aws_region" {} + +locals { + env = var.env + namespace = var.namespace + aws_region = var.aws_region +}