-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add sub resource example and descriptors (#19)
* feat: Add example of the sub resource usage with descriptor * feat: Add CODEOWNERS * chore: Upgrade minimal version of Terraform * Update variables.tf Co-authored-by: Mariusz Wojakowski <[email protected]> * Update variables.tf Co-authored-by: Mariusz Wojakowski <[email protected]> * Update variables.tf Co-authored-by: Mariusz Wojakowski <[email protected]> * docs: update README --------- Co-authored-by: Mariusz Wojakowski <[email protected]>
- Loading branch information
1 parent
ffb3e64
commit 38ca08b
Showing
12 changed files
with
68 additions
and
11 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# FILE PATTERN OWNER(S) | ||
* @getindata/devops-labs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
terraform { | ||
required_version = ">= 0.15.0" | ||
required_version = ">= 1.3.0" | ||
|
||
required_providers { | ||
null = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
terraform { | ||
required_version = ">= 0.15.0" | ||
required_version = ">= 1.3.0" | ||
|
||
required_providers { | ||
null = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
locals { | ||
# Get a name from the descriptor. If not available, use default naming convention. | ||
# Trim and replace function are used to avoid bare delimiters on both ends of the name and situation of adjacent delimiters. | ||
name_from_descriptor = local.enabled ? trim(replace( | ||
lookup(module.this.descriptors, "module-resource-name", module.this.id), "/${module.this.delimiter}${module.this.delimiter}+/", module.this.delimiter | ||
# | ||
# todo: Build a wrapper module around context module with name from descriptor feature | ||
name_from_descriptor = module.this.enabled ? trim(replace( | ||
lookup(module.this.descriptors, var.descriptor_name, module.this.id), "/${module.this.delimiter}${module.this.delimiter}+/", module.this.delimiter | ||
), module.this.delimiter) : null | ||
|
||
subresource_name_from_descriptor = module.subresource_label.enabled ? trim(replace( | ||
lookup(module.subresource_label.descriptors, var.sub_resource.descriptor_name, module.subresource_label.id), "/${module.subresource_label.delimiter}${module.subresource_label.delimiter}+/", module.subresource_label.delimiter | ||
), module.subresource_label.delimiter) : null | ||
|
||
enabled = module.this.enabled | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,18 @@ | ||
# Example, compulsory input variable | ||
|
||
variable "example_var" { | ||
description = "Example varible passed into the module" | ||
description = "Example variable passed into the module" | ||
type = string | ||
} | ||
|
||
variable "descriptor_name" { | ||
description = "Name of the descriptor used to form a resource name" | ||
type = string | ||
default = "resource-type" | ||
} | ||
|
||
variable "sub_resource" { | ||
description = "Some other resource that is part of stack/module" | ||
type = object({ | ||
descriptor_name = optional(string, "sub-resource-type") | ||
example_var = string | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters