Skip to content

Commit 482b56c

Browse files
committed
droplet sutff
1 parent 42a7ab0 commit 482b56c

File tree

7 files changed

+68
-3
lines changed

7 files changed

+68
-3
lines changed

terraform-environments/digitalocean/terragrunt-dev/SFO3/terragrunt-dev/0200-volume/terragrunt.hcl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ locals {
2323

2424
# Load environment-level variables
2525
environment_vars = read_terragrunt_config(find_in_parent_folders("environment.hcl"))
26+
27+
2628
}
2729

2830
# ---------------------------------------------------------------------------------------------------------------------
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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/droplet?ref=digitalocean-kube-ops"
8+
}
9+
10+
dependency "project" {
11+
config_path = "${get_terragrunt_dir()}/../050-project"
12+
}
13+
14+
dependency "vpc" {
15+
config_path = "${get_terragrunt_dir()}/../0100-project"
16+
}
17+
18+
# ---------------------------------------------------------------------------------------------------------------------
19+
# Locals are named constants that are reusable within the configuration.
20+
# ---------------------------------------------------------------------------------------------------------------------
21+
locals {
22+
# Load common variables shared across all accounts
23+
common_vars = read_terragrunt_config(find_in_parent_folders("common.hcl"))
24+
25+
# Load region-level variables
26+
region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
27+
28+
# Load environment-level variables
29+
environment_vars = read_terragrunt_config(find_in_parent_folders("environment.hcl"))
30+
31+
# Project name
32+
project_name = local.environment_vars.locals.project_name
33+
34+
# Region name
35+
region_name=local.region_vars.locals.digitalocean_region
36+
}
37+
38+
# ---------------------------------------------------------------------------------------------------------------------
39+
# MODULE PARAMETERS
40+
# These are the variables we have to pass in to use the module specified in the terragrunt configuration above
41+
# ---------------------------------------------------------------------------------------------------------------------
42+
inputs = {
43+
droplet_name = "drop-${local.project_name}"
44+
droplet_image = "ubuntu-18-04-x64"
45+
droplet_monitoring = true
46+
droplet_region = "${local.region_name}"
47+
droplet_size = "s-1vcpu-1gb"
48+
droplet_user_data = ""
49+
droplet_vpc_uuid = dependency.project.outputs.project_id
50+
}

terraform-modules/digitalocean/droplet/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ No modules.
2323
| Name | Type |
2424
|------|------|
2525
| [digitalocean_droplet.this](https://registry.terraform.io/providers/digitalocean/digitalocean/2.19.0/docs/resources/droplet) | resource |
26+
| [digitalocean_project_resources.project](https://registry.terraform.io/providers/digitalocean/digitalocean/2.19.0/docs/resources/project_resources) | resource |
2627

2728
## Inputs
2829

@@ -31,6 +32,7 @@ No modules.
3132
| <a name="input_droplet_image"></a> [droplet\_image](#input\_droplet\_image) | (Required) The Droplet image ID or slug | `string` | n/a | yes |
3233
| <a name="input_droplet_monitoring"></a> [droplet\_monitoring](#input\_droplet\_monitoring) | (Optional) Boolean controlling whether monitoring agent is installed. Defaults to false. If set to true, you can configure monitor alert policies monitor alert | `bool` | `false` | no |
3334
| <a name="input_droplet_name"></a> [droplet\_name](#input\_droplet\_name) | (Required) The Droplet name. | `string` | n/a | yes |
35+
| <a name="input_droplet_project_id"></a> [droplet\_project\_id](#input\_droplet\_project\_id) | (Optional) The id of the project where the droplet will be associated | `string` | n/a | yes |
3436
| <a name="input_droplet_region"></a> [droplet\_region](#input\_droplet\_region) | (Required) The region to start in. | `string` | n/a | yes |
3537
| <a name="input_droplet_size"></a> [droplet\_size](#input\_droplet\_size) | (Required) The unique slug that indentifies the type of Droplet. You can find a list of available slugs on DigitalOcean API documentation. | `string` | n/a | yes |
3638
| <a name="input_droplet_user_data"></a> [droplet\_user\_data](#input\_droplet\_user\_data) | (Optional) A string of the desired User Data for the Droplet. | `string` | n/a | yes |

terraform-modules/digitalocean/droplet/main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,11 @@ resource "digitalocean_droplet" "this" {
1414
size = var.droplet_size
1515
monitoring = var.droplet_monitoring
1616
vpc_uuid = var.droplet_vpc_uuid
17+
}
18+
19+
resource "digitalocean_project_resources" "project" {
20+
project = var.droplet_project_id
21+
resources = [
22+
digitalocean_droplet.this.urn
23+
]
1724
}

terraform-modules/digitalocean/droplet/variables.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,8 @@ variable "droplet_user_data" {
3434
type = string
3535
description = "(Optional) A string of the desired User Data for the Droplet."
3636
}
37-
37+
38+
variable "droplet_project_id" {
39+
type = string
40+
description = "(Optional) The id of the project where the droplet will be associated"
41+
}

terraform-modules/digitalocean/volume/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ No modules.
2929
| <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 |
3030
| <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 |
3131
| <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 |
32+
| <a name="input_volume_project_id"></a> [volume\_project\_id](#input\_volume\_project\_id) | (Optional) The id of the project where the volume will be associated | `string` | n/a | yes |
3333
| <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 |
3434
| <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 |
3535

terraform-modules/digitalocean/volume/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ variable "volume_description" {
2727

2828
variable "volume_project_id" {
2929
type = string
30-
description = "(Optional) The id of the project where the vpc will be associated"
30+
description = "(Optional) The id of the project where the volume will be associated"
3131
}

0 commit comments

Comments
 (0)