From a13e051f7097eaca0ecad565ef59f3174f09ee56 Mon Sep 17 00:00:00 2001 From: hcornet Date: Thu, 2 Jan 2025 19:33:00 +0100 Subject: [PATCH] first sync --- networks.tf | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ provider.tf | 9 ++++++++ variables.tf | 34 ++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) diff --git a/networks.tf b/networks.tf index e69de29..e5722b9 100644 --- a/networks.tf +++ b/networks.tf @@ -0,0 +1,58 @@ +resource "scaleway_vpc_private_network" "my_company_pn" { + name = "my-company-pn" +} + +resource "scaleway_vpc_public_gateway_dhcp" "my_company_dhcp" { + subnet = "192.168.0.0/24" + push_default_route = true + enable_dynamic = false + pool_low = "192.168.0.20" + pool_high = "192.168.0.249" +} + +resource "scaleway_vpc_public_gateway_ip" "my_company_pg_ip" {} + +resource "scaleway_vpc_public_gateway" "my_company_pg" { + name = "my-company-pg" + type = "VPC-GW-S" + ip_id = scaleway_vpc_public_gateway_ip.my_company_pg_ip.id +} + +resource "scaleway_vpc_gateway_network" "my_company_gn" { + gateway_id = scaleway_vpc_public_gateway.my_company_pg.id + private_network_id = scaleway_vpc_private_network.my_company_pn.id + dhcp_id = scaleway_vpc_public_gateway_dhcp.my_company_dhcp.id + cleanup_dhcp = true + enable_masquerade = true + + depends_on = [ + scaleway_vpc_public_gateway_ip.my_company_pg_ip, + scaleway_vpc_public_gateway.my_company_pg, + scaleway_vpc_private_network.my_company_pn + ] +} + +resource "scaleway_vpc_public_gateway_dhcp_reservation" "my_company_pg_dhcp_res_team_builder_instance" { + gateway_network_id = scaleway_vpc_gateway_network.my_company_gn.id + mac_address = scaleway_instance_private_nic.team_builder_instance_pnic01.mac_address + ip_address = "192.168.0.10" + + depends_on = [ + scaleway_vpc_public_gateway_dhcp.my_company_dhcp, + scaleway_vpc_gateway_network.my_company_gn, + scaleway_instance_private_nic.team_builder_instance_pnic01 + ] +} + +resource "scaleway_vpc_public_gateway_pat_rule" "my_company_pg_pat_rule_team_builder_instance_ssh" { + gateway_id = scaleway_vpc_public_gateway.my_company_pg.id + private_ip = scaleway_vpc_public_gateway_dhcp_reservation.my_company_pg_dhcp_res_team_builder_instance.ip_address + private_port = 22 + public_port = 2202 + protocol = "tcp" + + depends_on = [ + scaleway_vpc_gateway_network.my_company_gn, + scaleway_vpc_private_network.my_company_pn + ] +} \ No newline at end of file diff --git a/provider.tf b/provider.tf index e69de29..7d86192 100644 --- a/provider.tf +++ b/provider.tf @@ -0,0 +1,9 @@ +terraform { + required_providers { + scaleway = { + source = "scaleway/scaleway" + version = "~> 2.41.0" + } + } + required_version = ">= 1.7.5" +} \ No newline at end of file diff --git a/variables.tf b/variables.tf index e69de29..f1d7fea 100644 --- a/variables.tf +++ b/variables.tf @@ -0,0 +1,34 @@ +variable "access_key" { + type = string + sensitive = true + description = "Id du key" + default = "SCW9R1R3SE3JGPJSWEP2" +} + +variable "secret_key" { + type = string + sensitive = true + description = "Id du secret" + default = "7c0502ba-5a74-4ff7-b936-b5552c6554ca" +} + +variable "organization_id" { + type = string + sensitive = true + description = "Id de l'organisation" + default = "1a2b3c4d-1a2b-1a2b-1a2b-1a2b3c4d5e6f" +} + +variable "project_id" { + type = string + sensitive = true + description = "Id du projet associƩ" + default = "1a2b3c4d-1a2b-1a2b-1a2b-1a2b3c4d5e6f" +} + +provider "scaleway" { + access_key = var.access_key + secret_key = var.secret_key + organization_id = var.organization_id + project_id = var.project_id +}