From 745babd999c26e7ef3f616c9ec823ed6fccd7043 Mon Sep 17 00:00:00 2001 From: ducreux Date: Thu, 4 Dec 2025 09:41:31 +0000 Subject: [PATCH] =?UTF-8?q?1=20bonus=20pas=20cat=C3=A9gorie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- terraform/environments/dev/terraform.tfstate | 37 +++++++- .../environments/dev/terraform.tfstate.backup | 92 ++++++++++++++++++- terraform/modules/compute/main.tf | 2 + terraform/modules/iam/main.tf | 11 +++ 4 files changed, 136 insertions(+), 6 deletions(-) diff --git a/terraform/environments/dev/terraform.tfstate b/terraform/environments/dev/terraform.tfstate index c0de575..5834836 100644 --- a/terraform/environments/dev/terraform.tfstate +++ b/terraform/environments/dev/terraform.tfstate @@ -1,7 +1,7 @@ { "version": 4, "terraform_version": "1.14.1", - "serial": 54, + "serial": 58, "lineage": "39fa9bd0-98c8-1759-7f73-ed127b902d8b", "outputs": { "frontend_public_ip": { @@ -282,9 +282,11 @@ "labels": {}, "machine_type": "e2-small", "metadata": { - "enable-oslogin": "TRUE" + "enable-oslogin": "TRUE", + "environment": "dev", + "owner": "clemence" }, - "metadata_fingerprint": "VIFIa5rN4V4=", + "metadata_fingerprint": "o5AWSB3O6Qs=", "metadata_startup_script": null, "min_cpu_platform": "", "name": "database-instance", @@ -609,6 +611,35 @@ } ] }, + { + "module": "module.iam", + "mode": "managed", + "type": "google_project_iam_custom_role", + "name": "custom_viewer", + "provider": "provider[\"registry.terraform.io/hashicorp/google\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "deleted": false, + "description": "Role custom pour TP", + "id": "projects/western-diorama-374821/roles/customBasicViewer", + "name": "projects/western-diorama-374821/roles/customBasicViewer", + "permissions": [ + "compute.instances.get", + "compute.instances.list" + ], + "project": "western-diorama-374821", + "role_id": "customBasicViewer", + "stage": "GA", + "title": "Custom Basic Viewer" + }, + "sensitive_attributes": [], + "identity_schema_version": 0, + "private": "bnVsbA==" + } + ] + }, { "module": "module.iam", "mode": "managed", diff --git a/terraform/environments/dev/terraform.tfstate.backup b/terraform/environments/dev/terraform.tfstate.backup index ca95b87..2111e49 100644 --- a/terraform/environments/dev/terraform.tfstate.backup +++ b/terraform/environments/dev/terraform.tfstate.backup @@ -1,7 +1,7 @@ { "version": 4, "terraform_version": "1.14.1", - "serial": 51, + "serial": 56, "lineage": "39fa9bd0-98c8-1759-7f73-ed127b902d8b", "outputs": { "frontend_public_ip": { @@ -282,9 +282,11 @@ "labels": {}, "machine_type": "e2-small", "metadata": { - "enable-oslogin": "TRUE" + "enable-oslogin": "TRUE", + "environment": "dev", + "owner": "clemence" }, - "metadata_fingerprint": "VIFIa5rN4V4=", + "metadata_fingerprint": "o5AWSB3O6Qs=", "metadata_startup_script": null, "min_cpu_platform": "", "name": "database-instance", @@ -916,6 +918,90 @@ } ] }, + { + "module": "module.network", + "mode": "managed", + "type": "google_compute_router", + "name": "nat_router", + "provider": "provider[\"registry.terraform.io/hashicorp/google\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "bgp": [], + "creation_timestamp": "2025-12-04T01:14:24.736-08:00", + "description": "", + "encrypted_interconnect_router": false, + "id": "projects/western-diorama-374821/regions/us-central1/routers/western-diorama-374821-nat-router", + "name": "western-diorama-374821-nat-router", + "network": "https://www.googleapis.com/compute/v1/projects/western-diorama-374821/global/networks/western-diorama-374821-vpc", + "project": "western-diorama-374821", + "region": "us-central1", + "self_link": "https://www.googleapis.com/compute/v1/projects/western-diorama-374821/regions/us-central1/routers/western-diorama-374821-nat-router", + "timeouts": null + }, + "sensitive_attributes": [], + "identity_schema_version": 0, + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxMjAwMDAwMDAwMDAwLCJkZWxldGUiOjEyMDAwMDAwMDAwMDAsInVwZGF0ZSI6MTIwMDAwMDAwMDAwMH19", + "dependencies": [ + "module.network.google_compute_network.vpc" + ] + } + ] + }, + { + "module": "module.network", + "mode": "managed", + "type": "google_compute_router_nat", + "name": "nat_config", + "provider": "provider[\"registry.terraform.io/hashicorp/google\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "auto_network_tier": "PREMIUM", + "drain_nat_ips": [], + "enable_dynamic_port_allocation": false, + "enable_endpoint_independent_mapping": false, + "endpoint_types": [ + "ENDPOINT_TYPE_VM" + ], + "icmp_idle_timeout_sec": 30, + "id": "western-diorama-374821/us-central1/western-diorama-374821-nat-router/western-diorama-374821-nat-config", + "initial_nat_ips": null, + "log_config": [ + { + "enable": false, + "filter": "ALL" + } + ], + "max_ports_per_vm": 0, + "min_ports_per_vm": 0, + "name": "western-diorama-374821-nat-config", + "nat_ip_allocate_option": "AUTO_ONLY", + "nat_ips": [], + "project": "western-diorama-374821", + "region": "us-central1", + "router": "western-diorama-374821-nat-router", + "rules": [], + "source_subnetwork_ip_ranges_to_nat": "ALL_SUBNETWORKS_ALL_IP_RANGES", + "subnetwork": [], + "tcp_established_idle_timeout_sec": 1200, + "tcp_time_wait_timeout_sec": 120, + "tcp_transitory_idle_timeout_sec": 30, + "timeouts": null, + "udp_idle_timeout_sec": 30 + }, + "sensitive_attributes": [], + "identity_schema_version": 0, + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxMjAwMDAwMDAwMDAwLCJkZWxldGUiOjEyMDAwMDAwMDAwMDAsInVwZGF0ZSI6MTIwMDAwMDAwMDAwMH19", + "dependencies": [ + "module.network.google_compute_network.vpc", + "module.network.google_compute_router.nat_router" + ] + } + ] + }, { "module": "module.network", "mode": "managed", diff --git a/terraform/modules/compute/main.tf b/terraform/modules/compute/main.tf index d5a0aa5..a6e98e9 100644 --- a/terraform/modules/compute/main.tf +++ b/terraform/modules/compute/main.tf @@ -76,5 +76,7 @@ resource "google_compute_instance" "database" { metadata = { enable-oslogin = "TRUE" + environment = "dev" + owner = "clemence" } } diff --git a/terraform/modules/iam/main.tf b/terraform/modules/iam/main.tf index d838502..9812481 100644 --- a/terraform/modules/iam/main.tf +++ b/terraform/modules/iam/main.tf @@ -28,3 +28,14 @@ resource "google_os_login_ssh_public_key" "ssh_key" { key = file(pathexpand("~/.ssh/id_ed25519.pub")) } +resource "google_project_iam_custom_role" "custom_viewer" { + role_id = "customBasicViewer" + title = "Custom Basic Viewer" + project = var.project_id + description = "Role custom pour TP" + + permissions = [ + "compute.instances.get", + "compute.instances.list", + ] +}