From 14f6d19d8894c7d8be84eb0df117279c383da123 Mon Sep 17 00:00:00 2001 From: Benoit Garcia Date: Sun, 5 Feb 2023 16:25:20 +0100 Subject: [PATCH] feat: Add option to set Project ID and zone. --- README.md | 2 ++ main.tf | 7 +++++++ variables.tf | 17 +++++++++++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e93b5de..bcd6a2c 100644 --- a/README.md +++ b/README.md @@ -58,9 +58,11 @@ module "my_instance" { | [name](#input_name) | Name of the server. | `string` | `null` | no | | [placement_group_id](#input_placement_group_id) | ID of the placement group the server is attached to. | `string` | `null` | no | | [private_networks](#input_private_networks) | Private networks associated with the server. | `list(string)` | `[]` | no | +| [project_id](#input_project_id) | ID of the project the namespace is associated with. Ressource will be created in the project set at the provider level if null. | `string` | `null` | no | | [security_group_id](#input_security_group_id) | ID of the security group the server is attached to. | `string` | `null` | no | | [state](#input_state) | State of the server. Default to 'started'. Possible values are: 'started', 'stopped' or 'standby'. | `string` | `"started"` | no | | [tags](#input_tags) | Tags associated with the server and dedicated ip address. | `list(any)` | `[]` | no | +| [zone](#input_zone) | The zone in which the instance should be created. Ressource will be created in the zone set at the provider level if null. | `string` | `null` | no | ## Authors diff --git a/main.tf b/main.tf index f8a3cc5..a39e56e 100644 --- a/main.tf +++ b/main.tf @@ -5,6 +5,9 @@ moved { resource "scaleway_instance_ip" "this" { count = var.enable_public_ipv4 == true ? 1 : 0 + + project_id = var.project_id + zone = var.zone } resource "scaleway_instance_ip_reverse_dns" "this" { @@ -12,6 +15,7 @@ resource "scaleway_instance_ip_reverse_dns" "this" { ip_id = scaleway_instance_ip.this[count.index].id reverse = format("%s.%s", var.name, var.dns_zone) + zone = var.zone } resource "scaleway_instance_server" "this" { @@ -41,6 +45,9 @@ resource "scaleway_instance_server" "this" { bootscript_id = var.bootscript_id state = var.state # user_data = var.user_data + + project_id = var.project_id + zone = var.zone } resource "scaleway_domain_record" "ip4" { diff --git a/variables.tf b/variables.tf index 412ad30..a274766 100644 --- a/variables.tf +++ b/variables.tf @@ -67,9 +67,9 @@ variable "enable_public_ipv4" { } variable "private_networks" { - type = list(string) + type = list(string) description = "Private networks associated with the server." - default = [] + default = [] } # Start settings @@ -106,3 +106,16 @@ variable "state" { # description = "User data associated with the server. Use the cloud-init key to use cloud-init on your instance. You can define values using:\n- string\n- UTF-8 encoded file content using file\n- Binary files using filebase64." # default = null # } + +# Location & Tenancy +variable "project_id" { + description = "ID of the project the namespace is associated with. Ressource will be created in the project set at the provider level if null." + type = string + default = null +} + +variable "zone" { + description = "The zone in which the instance should be created. Ressource will be created in the zone set at the provider level if null." + type = string + default = null +}