This module generates the name of cloud resources in different formats as specified below. For the product_family demo_org
,
product_service test_backend
, environment dev
and cloud resource acr
with a default maximum_length 60
# Outputs
camel_case = "Demo_orgTest_backendUseast2Dev000Acr000"
camel_case_with_separator = "Demo_org-Test_backend-Useast2-Dev-000-Acr-000"
camel_case_without_any_separators = "DemoorgTestbackendUseast2Dev000Acr000"
dns_compliant_minimal = "demo-org-test-backend-dev-000-acr"
dns_compliant_minimal_random_suffix = "demo-org-test-backend-9349499394"
lower_case = "demo_orgtest_backenduseast2dev000acr000"
lower_case_with_separator = "demo_org-test_backend-useast2-dev-000-acr-000"
lower_case_without_any_separators = "demoorgtestbackenduseast2dev000acr000"
minimal = "demo_org-test_backend-dev-000-acr"
minimal_random_suffix = "demo_org-test_backend-9349499394"
recommended_per_length_restriction = "demo_org-test_backend-useast2-dev-000-acr-000"
standard = "demo_org-test_backend-useast2-dev-000-acr-000"
upper_case = "DEMO_ORGTEST_BACKENDUSEAST2DEV000ACR000"
upper_case_with_separator = "DEMO_ORG-TEST_BACKEND-USEAST2-DEV-000-ACR-000"
upper_case_without_any_separators = "DEMOORGTESTBACKENDUSEAST2DEV000ACR000"
The same output with a maximum_length of 32
generates below.
Observe the value of recommended_per_length_restriction
camel_case = "DemoBackendEus2Dev001Acr000"
camel_case_with_separator = "Demo-Backend-Eus2-Dev-001-Acr-000"
camel_case_without_any_separators = "DemoBackendEus2Dev001Acr000"
dns_compliant_minimal = "demo-backend-dev-001-acr"
dns_compliant_minimal_random_suffix = "demo-backend-9003923140"
dns_compliant_standard = "demo-backend-eus2-dev-001-acr-000"
lower_case = "demobackendeus2dev001acr000"
lower_case_with_separator = "demo-backend-eus2-dev-001-acr-000"
lower_case_without_any_separators = "demobackendeus2dev001acr000"
minimal = "demo-backend-dev-001-acr"
minimal_random_suffix = "demo-backend-9003923140"
minimal_random_suffix_without_any_separators = "demobackend9003923140"
recommended_per_length_restriction = "demobackendeus2dev001acr000"
standard = "demo-backend-eus2-dev-001-acr-000"
upper_case = "DEMOBACKENDEUS2DEV001ACR000"
upper_case_with_separator = "DEMO-BACKEND-EUS2-DEV-001-ACR-000"
upper_case_without_any_separators = "DEMOBACKENDEUS2DEV001ACR000"
.pre-commit-config.yaml file defines certain pre-commit
hooks that are relevant to terraform, golang and common linting tasks. There are no custom hooks added.
commitlint
hook enforces commit message in certain format. The commit contains the following structural elements, to communicate intent to the consumers of your commit messages:
- fix: a commit of the type
fix
patches a bug in your codebase (this correlates with PATCH in Semantic Versioning). - feat: a commit of the type
feat
introduces a new feature to the codebase (this correlates with MINOR in Semantic Versioning). - BREAKING CHANGE: a commit that has a footer
BREAKING CHANGE:
, or appends a!
after the type/scope, introduces a breaking API change (correlating with MAJOR in Semantic Versioning). A BREAKING CHANGE can be part of commits of any type. footers other than BREAKING CHANGE: may be provided and follow a convention similar to git trailer format. - build: a commit of the type
build
adds changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) - chore: a commit of the type
chore
adds changes that don't modify src or test files - ci: a commit of the type
ci
adds changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) - docs: a commit of the type
docs
adds documentation only changes - perf: a commit of the type
perf
adds code change that improves performance - refactor: a commit of the type
refactor
adds code change that neither fixes a bug nor adds a feature - revert: a commit of the type
revert
reverts a previous commit - style: a commit of the type
style
adds code changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) - test: a commit of the type
test
adds missing tests or correcting existing tests
Base configuration used for this project is commitlint-config-conventional (based on the Angular convention)
If you are a developer using vscode, this plugin may be helpful.
detect-secrets-hook
prevents new secrets from being introduced into the baseline. TODO: INSERT DOC LINK ABOUT HOOKS
In order for pre-commit
hooks to work properly
- You need to have the pre-commit package manager installed. Here are the installation instructions.
pre-commit
would install all the hooks when commit message is added by default except forcommitlint
hook.commitlint
hook would need to be installed manually using the command below
pre-commit install --hook-type commit-msg
- For development/enhancements to this module locally, you'll need to install all of its components. This is controlled by the
configure
target in the project'sMakefile
. Before you can runconfigure
, familiarize yourself with the variables in theMakefile
and ensure they're pointing to the right places.
make configure
This adds in several files and directories that are ignored by git
. They expose many new Make targets.
- The first target you care about is
env
. This is the common interface for setting up environment variables. The values of the environment variables will be used to authenticate with cloud provider from local development workstation.
make configure
command will bring down azure_env.sh
file on local workstation. Devloper would need to modify this file, replace the environment variable values with relevant values.
These environment variables are used by terratest
integration suit.
Service principle used for authentication(value of ARM_CLIENT_ID) should have below privileges on resource group within the subscription.
"Microsoft.Resources/subscriptions/resourceGroups/write"
"Microsoft.Resources/subscriptions/resourceGroups/read"
"Microsoft.Resources/subscriptions/resourceGroups/delete"
Then run this make target to set the environment variables on developer workstation.
make env
- The first target you care about is
check
.
Pre-requisites
Before running this target it is important to ensure that, developer has created files mentioned below on local workstation under root directory of git repository that contains code for primitives/segments. Note that these files are azure
specific. If primitive/segment under development uses any other cloud provider than azure, this section may not be relevant.
- A file named
provider.tf
with contents below
provider "azurerm" {
features {}
}
- A file named
terraform.tfvars
which contains key value pair of variables used.
Note that since these files are added in gitgnore
they would not be checked in into primitive/segment's git repo.
After creating these files, for running tests associated with the primitive/segment, run
make check
If make check
target is successful, developer is good to commit the code to primitive/segment's git repo.
make check
target
- runs
terraform commands
tolint
,validate
andplan
terraform code. - runs
conftests
.conftests
make surepolicy
checks are successful. - runs
terratest
. This is integration test suit. - runs
opa
tests
Name | Version |
---|---|
terraform | ~> 1.0 |
random | >= 3.5 |
Name | Version |
---|---|
random | 3.6.3 |
No modules.
Name | Type |
---|---|
random_integer.random_number | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
logical_product_family | (Required) Name of the product family for which the resource is created. Example: org_name, department_name. |
string |
n/a | yes |
logical_product_service | (Required) Name of the product service for which the resource is created. For example, backend, frontend, middleware etc. |
string |
n/a | yes |
region | (Required) The location where the resource will be created. Must not have spaces For example, us-east-2, useast2, West-US-2 |
string |
n/a | yes |
class_env | (Required) Environment where resource is going to be deployed. For example. dev, qa, uat | string |
n/a | yes |
instance_env | Number that represents the instance of the environment. | number |
0 |
no |
cloud_resource_type | (Required) Abbreviation for the type of resource. For ex. 'rg' for Azure Resource group. | string |
n/a | yes |
instance_resource | Number that represents the instance of the resource. | number |
0 |
no |
maximum_length | Number that represents the maximum length the resource name could have. | number |
60 |
no |
separator | Separator to be used in the name | string |
"-" |
no |
use_azure_region_abbr | Whether to use Azure region abbreviation e.g. eastus -> eus | bool |
false |
no |
Name | Description |
---|---|
lower_case | Name of the resource in lower case. |
lower_case_without_any_separators | Name of the resource in lower case without any separators. Will remove any separators present in any fields as well. |
lower_case_with_separator | Name of the resource with lower case and separator. If separator is not provided by user, then '-' character will be used as a separator. |
upper_case | Name of the resource in upper case. |
upper_case_without_any_separators | Name of the resource in upper case without any separators. Will remove any separators present in any fields as well. |
upper_case_with_separator | Name of the resource in upper case and separator. If separator is not provided by user, then '-' character will be used as a separator. |
standard | Name of the resource as per pre-determined recommended naming convention that is join each field with the provided separator |
recommended_per_length_restriction | Name of the resource that fits the maximum length restriction criteria specified by the user. Returns standard else camel_case_without_any_separators else minimal_without_any_separators until it satisfies the maximum_length requirements |
camel_case | Name of the resource in camel case. |
camel_case_without_any_separators | Name of the resource in camel case. Will remove any separators present in any fields as well. |
camel_case_with_separator | Name of the resource in camel case and separator. If separator is not provided by user, then '-' character will be used as a separator. |
minimal | Name of the resource would exclude region, instance_resource |
minimal_random_suffix | Name of the resource would exclude region, instance_resource and append a random number suffix. This supports max_length restriction |
minimal_random_suffix_without_any_separators | Name of the resource would exclude region, instance_resource and append a random number suffix. This supports max_length restriction and will remove any separators present in any fields as well. |
dns_compliant_minimal | Name is minimal and DNS complaint, that is it can contain only -. |
dns_compliant_standard | Name is standard and DNS complaint, that is it can contain only -. |
dns_compliant_minimal_random_suffix | Name is minimal_random_suffix and DNS complaint, that is it can contain only -. |