Skip to content

Commit

Permalink
Update variables (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
brettcurtis authored Nov 2, 2024
1 parent 5878a0b commit aed6a8c
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
- id: check-symlinks

- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.96.1
rev: v1.96.2
hooks:
- id: terraform_fmt

Expand All @@ -29,7 +29,7 @@ repos:
- id: terraform_docs

- repo: https://github.com/bridgecrewio/checkov.git
rev: 3.2.269
rev: 3.2.276
hooks:
- id: checkov
verbose: true
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,21 @@ No resources.
|------|-------------|------|---------|:--------:|
| <a name="input_cost_center"></a> [cost\_center](#input\_cost\_center) | The cost center the resources will be billed to, must start with 'x' followed by three or four digits | `string` | n/a | yes |
| <a name="input_data_classification"></a> [data\_classification](#input\_data\_classification) | The data classification of the resources can be public, internal, or confidential | `string` | n/a | yes |
| <a name="input_email"></a> [email](#input\_email) | The email address of the team responsible for the resources | `string` | n/a | yes |
| <a name="input_repository"></a> [repository](#input\_repository) | The repository name (should be in the format 'owner/repo') containing only lowercase alphanumeric characters or hyphens | `string` | n/a | yes |
| <a name="input_repository"></a> [repository](#input\_repository) | The repository name containing only lowercase alphanumeric characters or hyphens | `string` | n/a | yes |
| <a name="input_team"></a> [team](#input\_team) | The team name (should contain only lowercase alphanumeric characters and hyphens) | `string` | n/a | yes |
| <a name="input_workspace"></a> [workspace](#input\_workspace) | This is used for tests to set the workspace name. Do not set this variable in any other context | `string` | `null` | no |

### Outputs

| Name | Description |
|------|-------------|
| <a name="output_cost_center"></a> [cost\_center](#output\_cost\_center) | The cost center the resources will be billed to |
| <a name="output_data_classification"></a> [data\_classification](#output\_data\_classification) | The data classification of the resources |
| <a name="output_env"></a> [env](#output\_env) | The short name for the environment for example prod, nonprod, sb |
| <a name="output_environment"></a> [environment](#output\_environment) | The environment name for example production, non-production, sandbox |
| <a name="output_labels"></a> [labels](#output\_labels) | A map of labels to apply to resources |
| <a name="output_region"></a> [region](#output\_region) | The region where resources will be deployed |
| <a name="output_repository"></a> [repository](#output\_repository) | The repository name |
| <a name="output_team"></a> [team](#output\_team) | The team name |
| <a name="output_zone"></a> [zone](#output\_zone) | The zone where resources will be deployed |
<!-- END_TF_DOCS -->
1 change: 0 additions & 1 deletion locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ locals {
env = local.environment
cost-center = var.cost_center
data-classification = var.data_classification
email = var.email
region = local.region
repository = var.repository
team = var.team
Expand Down
20 changes: 20 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Terraform Output Values
# https://www.terraform.io/language/values/outputs

output "cost_center" {
description = "The cost center the resources will be billed to"
value = var.cost_center
}

output "data_classification" {
description = "The data classification of the resources"
value = var.data_classification
}

output "env" {
description = "The short name for the environment for example prod, nonprod, sb"
value = local.env
Expand All @@ -21,6 +31,16 @@ output "region" {
value = local.region
}

output "repository" {
description = "The repository name"
value = var.repository
}

output "team" {
description = "The team name"
value = var.team
}

output "zone" {
description = "The zone where resources will be deployed"
value = local.zone
Expand Down
2 changes: 1 addition & 1 deletion tests/default.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,6 @@ variables {
cost_center = "mock-cost-center"
data_classification = "mock-data-classification"
email = "[email protected]"
repository = "mock-owner/mock-repository"
repository = "mock-repository"
team = "mock-team"
}
1 change: 0 additions & 1 deletion tests/fixtures/default/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module "core_workspace" {

cost_center = var.cost_center
data_classification = var.data_classification
email = var.email
repository = var.repository
team = var.team
workspace = var.workspace
Expand Down
16 changes: 3 additions & 13 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,13 @@ variable "data_classification" {
}
}

variable "email" {
description = "The email address of the team responsible for the resources"
type = string

validation {
condition = can(regex("^[a-zA-Z0-9._%+-]+@osinfra\\.io$", var.email))
error_message = "The email address must be a valid osinfra.io email address"
}
}

variable "repository" {
description = "The repository name (should be in the format 'owner/repo') containing only lowercase alphanumeric characters or hyphens"
description = "The repository name containing only lowercase alphanumeric characters or hyphens"
type = string

validation {
condition = can(regex("^[a-z0-9-]+/[a-z0-9-]+$", var.repository))
error_message = "The repository name should be in the format 'owner/repo' and contain only lowercase alphanumeric characters or hyphens"
condition = can(regex("^[a-z0-9-]+$", var.repository))
error_message = "The repository name must consist entirely of lowercase alphanumeric characters or hyphens"
}
}

Expand Down

0 comments on commit aed6a8c

Please sign in to comment.