Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/add examples #9

Merged
merged 5 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ If `make check` target is successful, developer is good to commit the code to pr

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.0, <= 1.5.5 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.0 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3.5 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_random"></a> [random](#provider\_random) | 3.6.1 |
| <a name="provider_random"></a> [random](#provider\_random) | 3.6.3 |

## Modules

Expand Down
57 changes: 57 additions & 0 deletions examples/complete/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# complete

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.0 |

## Providers

No providers.

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_resource_names"></a> [resource\_names](#module\_resource\_names) | terraform.registry.launch.nttdata.com/module_library/resource_name/launch | ~> 1.0 |

## Resources

No resources.

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_logical_product_family"></a> [logical\_product\_family](#input\_logical\_product\_family) | (Required) Name of the product family for which the resource is created.<br> Example: org\_name, department\_name. | `string` | `"launch"` | no |
| <a name="input_logical_product_service"></a> [logical\_product\_service](#input\_logical\_product\_service) | (Required) Name of the product service for which the resource is created.<br> For example, backend, frontend, middleware etc. | `string` | `"backend"` | no |
| <a name="input_instance_resource"></a> [instance\_resource](#input\_instance\_resource) | Number that represents the instance of the resource. | `number` | `0` | no |
| <a name="input_instance_env"></a> [instance\_env](#input\_instance\_env) | Number that represents the instance of the environment. | `number` | `0` | no |
| <a name="input_class_env"></a> [class\_env](#input\_class\_env) | (Required) Environment where resource is going to be deployed. For example. dev, qa, uat | `string` | `"dev"` | no |
| <a name="input_resource_names_map"></a> [resource\_names\_map](#input\_resource\_names\_map) | A map of key to resource\_name that will be used by tf-launch-module\_library-resource\_name to generate resource names | <pre>map(object(<br> {<br> name = string<br> max_length = optional(number, 60)<br> }<br> ))</pre> | `{}` | no |
| <a name="input_region"></a> [region](#input\_region) | (Required) The location where the resource will be created. Must not have spaces<br> For example, us-east-1, us-west-2, eu-west-1, etc. | `string` | `"us-east-2"` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_resource_one_standard"></a> [resource\_one\_standard](#output\_resource\_one\_standard) | Resource one in standard format. |
| <a name="output_resource_two_standard"></a> [resource\_two\_standard](#output\_resource\_two\_standard) | Resource two in standard format. |
| <a name="output_resource_one_lowercase"></a> [resource\_one\_lowercase](#output\_resource\_one\_lowercase) | Resource one in lowercase format. |
| <a name="output_resource_one_uppercase"></a> [resource\_one\_uppercase](#output\_resource\_one\_uppercase) | Resource one in uppercase format. |
| <a name="output_resource_one_lowercase_without_any_separators"></a> [resource\_one\_lowercase\_without\_any\_separators](#output\_resource\_one\_lowercase\_without\_any\_separators) | Resource one in lowercase format without separator. |
| <a name="output_resource_one_uppercase_without_any_separators"></a> [resource\_one\_uppercase\_without\_any\_separators](#output\_resource\_one\_uppercase\_without\_any\_separators) | Resource one in uppercase format without separator. |
| <a name="output_resource_one_minimal"></a> [resource\_one\_minimal](#output\_resource\_one\_minimal) | Resource one in minimal format. |
| <a name="output_resource_one_minimal_random_suffix"></a> [resource\_one\_minimal\_random\_suffix](#output\_resource\_one\_minimal\_random\_suffix) | Resource one in minimal format with random number. |
| <a name="output_resource_one_minimal_random_suffix_without_any_separators"></a> [resource\_one\_minimal\_random\_suffix\_without\_any\_separators](#output\_resource\_one\_minimal\_random\_suffix\_without\_any\_separators) | Resource one in minimal format with random number without separator. |
| <a name="output_resource_one_dns_compliant_standard"></a> [resource\_one\_dns\_compliant\_standard](#output\_resource\_one\_dns\_compliant\_standard) | Resource one in DNS compliant format. |
| <a name="output_resource_one_dns_compliant_minimal"></a> [resource\_one\_dns\_compliant\_minimal](#output\_resource\_one\_dns\_compliant\_minimal) | Resource one in DNS compliant minimal format. |
| <a name="output_resource_one_dns_compliant_minimal_random_suffix"></a> [resource\_one\_dns\_compliant\_minimal\_random\_suffix](#output\_resource\_one\_dns\_compliant\_minimal\_random\_suffix) | Resource one in DNS compliant minimal format with random number. |
| <a name="output_resource_one_camel_case"></a> [resource\_one\_camel\_case](#output\_resource\_one\_camel\_case) | Resource one in camel case format. |
| <a name="output_resource_one_camel_case_without_any_separators"></a> [resource\_one\_camel\_case\_without\_any\_separators](#output\_resource\_one\_camel\_case\_without\_any\_separators) | Resource one in camel case format without separator. |
| <a name="output_resource_one_camel_case_with_separator"></a> [resource\_one\_camel\_case\_with\_separator](#output\_resource\_one\_camel\_case\_with\_separator) | Resource one in camel case format with separator. |
| <a name="output_resource_one_recommended_per_length_restriction"></a> [resource\_one\_recommended\_per\_length\_restriction](#output\_resource\_one\_recommended\_per\_length\_restriction) | Resource one in recommended format as per length restriction. |
| <a name="output_resource_two_recommended_per_length_restriction"></a> [resource\_two\_recommended\_per\_length\_restriction](#output\_resource\_two\_recommended\_per\_length\_restriction) | Resource two in recommended format as per length restriction. |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
39 changes: 39 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

module "resource_names" {
source = "../.."

for_each = var.resource_names_map

logical_product_family = var.logical_product_family
logical_product_service = var.logical_product_service
region = join("", split("-", var.region))
class_env = var.class_env
cloud_resource_type = each.value.name
instance_env = var.instance_env
instance_resource = var.instance_resource
maximum_length = each.value.max_length
}
96 changes: 96 additions & 0 deletions examples/complete/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

output "resource_one_standard" {
value = module.resource_names["resource_one"].standard
description = "Resource one in standard format."
}

output "resource_two_standard" {
value = module.resource_names["resource_two"].standard
description = "Resource two in standard format."
}

output "resource_one_lowercase" {
value = module.resource_names["resource_one"].lower_case_with_separator
description = "Resource one in lowercase format."
}

output "resource_one_uppercase" {
value = module.resource_names["resource_one"].upper_case_with_separator
description = "Resource one in uppercase format."
}

output "resource_one_lowercase_without_any_separators" {
value = module.resource_names["resource_one"].lower_case_without_any_separators
description = "Resource one in lowercase format without separator."
}

output "resource_one_uppercase_without_any_separators" {
value = module.resource_names["resource_one"].upper_case_without_any_separators
description = "Resource one in uppercase format without separator."
}

output "resource_one_minimal" {
value = module.resource_names["resource_one"].minimal
description = "Resource one in minimal format."
}

output "resource_one_minimal_random_suffix" {
value = module.resource_names["resource_one"].minimal_random_suffix
description = "Resource one in minimal format with random number."
}

output "resource_one_minimal_random_suffix_without_any_separators" {
value = module.resource_names["resource_one"].minimal_random_suffix_without_any_separators
description = "Resource one in minimal format with random number without separator."
}

output "resource_one_dns_compliant_standard" {
value = module.resource_names["resource_one"].dns_compliant_standard
description = "Resource one in DNS compliant format."
}

output "resource_one_dns_compliant_minimal" {
value = module.resource_names["resource_one"].dns_compliant_minimal
description = "Resource one in DNS compliant minimal format."
}

output "resource_one_dns_compliant_minimal_random_suffix" {
value = module.resource_names["resource_one"].dns_compliant_minimal_random_suffix
description = "Resource one in DNS compliant minimal format with random number."
}

output "resource_one_camel_case" {
value = module.resource_names["resource_one"].camel_case
description = "Resource one in camel case format."
}

output "resource_one_camel_case_without_any_separators" {
value = module.resource_names["resource_one"].camel_case_without_any_separators
description = "Resource one in camel case format without separator."
}

output "resource_one_camel_case_with_separator" {
value = module.resource_names["resource_one"].camel_case_with_separator
description = "Resource one in camel case format with separator."
}

output "resource_one_recommended_per_length_restriction" {
value = module.resource_names["resource_one"].recommended_per_length_restriction
description = "Resource one in recommended format as per length restriction."
}

output "resource_two_recommended_per_length_restriction" {
value = module.resource_names["resource_two"].recommended_per_length_restriction
description = "Resource two in recommended format as per length restriction."
}
13 changes: 13 additions & 0 deletions examples/complete/test.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
logical_product_family = "terratest"
logical_product_service = "resource_NAME_test"

resource_names_map = {
resource_one = {
name = "r1"
max_length = 80
}
resource_two = {
name = "r2"
max_length = 50
}
}
101 changes: 101 additions & 0 deletions examples/complete/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

variable "logical_product_family" {
type = string
description = <<EOF
(Required) Name of the product family for which the resource is created.
Example: org_name, department_name.
EOF
nullable = false
default = "launch"

validation {
condition = can(regex("^[_\\-A-Za-z0-9]+$", var.logical_product_family))
error_message = "The variable must contain letters, numbers, -, _, and .."
}
}

variable "logical_product_service" {
type = string
description = <<EOF
(Required) Name of the product service for which the resource is created.
For example, backend, frontend, middleware etc.
EOF
nullable = false
default = "backend"

validation {
condition = can(regex("^[_\\-A-Za-z0-9]+$", var.logical_product_service))
error_message = "The variable must contain letters, numbers, -, _, and .."
}
}

variable "instance_resource" {
type = number
description = "Number that represents the instance of the resource."
default = 0

validation {
condition = var.instance_resource >= 0 && var.instance_resource <= 100
error_message = "Instance number should be between 1 to 100."
}
}

variable "instance_env" {
type = number
description = "Number that represents the instance of the environment."
default = 0

validation {
condition = var.instance_env >= 0 && var.instance_env <= 999
error_message = "Instance number should be between 1 to 999."
}
}

variable "class_env" {
type = string
default = "dev"
description = "(Required) Environment where resource is going to be deployed. For example. dev, qa, uat"
nullable = false

validation {
condition = length(regexall("\\b \\b", var.class_env)) == 0
error_message = "Spaces between the words are not allowed."
}
}

variable "resource_names_map" {
description = "A map of key to resource_name that will be used by tf-launch-module_library-resource_name to generate resource names"
type = map(object(
{
name = string
max_length = optional(number, 60)
}
))
default = {}
}

variable "region" {
type = string
description = <<EOF
(Required) The location where the resource will be created. Must not have spaces
For example, us-east-1, us-west-2, eu-west-1, etc.
EOF
nullable = false
default = "us-east-2"

validation {
condition = length(regexall("\\b \\b", var.region)) == 0
error_message = "Spaces between the words are not allowed."
}
}
18 changes: 18 additions & 0 deletions examples/complete/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

terraform {
required_version = "~> 1.0"

required_providers {
}
}
Loading
Loading