Skip to content

Commit 5ce428c

Browse files
committed
vpc and volumens docs refactor and new volumen env
1 parent 035310b commit 5ce428c

File tree

7 files changed

+50
-10
lines changed

7 files changed

+50
-10
lines changed

terraform-environments/digitalocean/terragrunt-dev/SFO3/terragrunt-dev/0100-vpc/terragrunt.hcl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ terraform {
77
source = "github.com/ManagedKube/kubernetes-ops//terraform-modules/digitalocean/vpc?ref=digitalocean-kube-ops"
88
}
99

10-
dependency "project" {
11-
config_path = "${get_terragrunt_dir()}/../050-project"
12-
}
13-
1410
# ---------------------------------------------------------------------------------------------------------------------
1511
# Locals are named constants that are reusable within the configuration.
1612
# ---------------------------------------------------------------------------------------------------------------------
@@ -34,5 +30,4 @@ inputs = {
3430
vpc_region = local.region_vars.locals.digitalocean_region
3531
vpc_description = "Vpc for testing ManageKube in Digital Ocean"
3632
vpc_ip_range = "10.10.10.0/24"
37-
project_id = dependency.project.outputs.project_id
3833
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Include all settings from the root terragrunt.hcl file
2+
include {
3+
path = find_in_parent_folders()
4+
}
5+
6+
terraform {
7+
source = "github.com/ManagedKube/kubernetes-ops//terraform-modules/digitalocean/volume?ref=digitalocean-kube-ops"
8+
}
9+
10+
dependency "project" {
11+
config_path = "${get_terragrunt_dir()}/../050-project"
12+
}
13+
14+
# ---------------------------------------------------------------------------------------------------------------------
15+
# Locals are named constants that are reusable within the configuration.
16+
# ---------------------------------------------------------------------------------------------------------------------
17+
locals {
18+
# Load common variables shared across all accounts
19+
common_vars = read_terragrunt_config(find_in_parent_folders("common.hcl"))
20+
21+
# Load region-level variables
22+
region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
23+
24+
# Load environment-level variables
25+
environment_vars = read_terragrunt_config(find_in_parent_folders("environment.hcl"))
26+
}
27+
28+
# ---------------------------------------------------------------------------------------------------------------------
29+
# MODULE PARAMETERS
30+
# These are the variables we have to pass in to use the module specified in the terragrunt configuration above
31+
# ---------------------------------------------------------------------------------------------------------------------
32+
inputs = {
33+
volume_name = "vol-${local.environment_vars.locals.project_name}"
34+
volume_region = local.region_vars.locals.digitalocean_region
35+
volume_description = "Volumen of ${local.environment_vars.locals.project_name} in region: ${local.region_vars.locals.digitalocean_region}"
36+
volume_project_id = dependency.project.outputs.project_id
37+
}

terraform-modules/digitalocean/volume/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ No modules.
1919

2020
| Name | Type |
2121
|------|------|
22+
| [digitalocean_project_resources.project](https://registry.terraform.io/providers/digitalocean/digitalocean/2.19.0/docs/resources/project_resources) | resource |
2223
| [digitalocean_volume.this](https://registry.terraform.io/providers/digitalocean/digitalocean/2.19.0/docs/resources/volume) | resource |
2324

2425
## Inputs
@@ -28,6 +29,7 @@ No modules.
2829
| <a name="input_volume_description"></a> [volume\_description](#input\_volume\_description) | (Optional) A free-form text field up to a limit of 1024 bytes to describe a block storage volume.. | `string` | n/a | yes |
2930
| <a name="input_volume_initial_filesystem_type"></a> [volume\_initial\_filesystem\_type](#input\_volume\_initial\_filesystem\_type) | (Optional) Initial filesystem type (xfs or ext4) for the block storage volume. | `string` | n/a | yes |
3031
| <a name="input_volume_name"></a> [volume\_name](#input\_volume\_name) | (Required) A name for the block storage volume. Must be lowercase and be composed only of numbers, letters and -, up to a limit of 64 characters. | `string` | n/a | yes |
32+
| <a name="input_volume_project_id"></a> [volume\_project\_id](#input\_volume\_project\_id) | (Optional) The id of the project where the vpc will be associated | `string` | n/a | yes |
3133
| <a name="input_volume_region"></a> [volume\_region](#input\_volume\_region) | (Required) The region that the block storage volume will be created in. | `string` | n/a | yes |
3234
| <a name="input_volume_size"></a> [volume\_size](#input\_volume\_size) | (Required) The size of the block storage volume in GiB. If updated, can only be expanded. | `number` | `20` | no |
3335

terraform-modules/digitalocean/volume/main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,11 @@ resource "digitalocean_volume" "this" {
1313
size = var.volume_size
1414
initial_filesystem_type = var.volume_initial_filesystem_type
1515
description = var.volume_description
16+
}
17+
18+
resource "digitalocean_project_resources" "project" {
19+
project = var.volume_project_id
20+
resources = [
21+
digitalocean_volume.this.urn
22+
]
1623
}

terraform-modules/digitalocean/volume/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ variable "volume_description" {
2525
description = "(Optional) A free-form text field up to a limit of 1024 bytes to describe a block storage volume.."
2626
}
2727

28+
variable "volume_project_id" {
29+
type = string
30+
description = "(Optional) The id of the project where the vpc will be associated"
31+
}

terraform-modules/digitalocean/vpc/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ No modules.
2525

2626
| Name | Description | Type | Default | Required |
2727
|------|-------------|------|---------|:--------:|
28-
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | (Optional) The id of the project where the vpc will be associated | `string` | n/a | yes |
2928
| <a name="input_vpc_description"></a> [vpc\_description](#input\_vpc\_description) | (Optional) A free-form text field up to a limit of 255 characters to describe the VPC. | `string` | `"Your new vpc"` | no |
3029
| <a name="input_vpc_ip_range"></a> [vpc\_ip\_range](#input\_vpc\_ip\_range) | (Optional) The range of IP addresses for the VPC in CIDR notation. | `string` | `"10.10.10.0/24"` | no |
3130
| <a name="input_vpc_name"></a> [vpc\_name](#input\_vpc\_name) | (Required) A name for the VPC. Must be unique and contain alphanumeric characters, dashes, and periods only. | `string` | n/a | yes |

terraform-modules/digitalocean/vpc/variables.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,3 @@ variable "vpc_ip_range" {
1818
description = "(Optional) The range of IP addresses for the VPC in CIDR notation."
1919
default = "10.10.10.0/24"
2020
}
21-
variable "project_id" {
22-
type = string
23-
description = "(Optional) The id of the project where the vpc will be associated"
24-
}

0 commit comments

Comments
 (0)