This is an automated email from the ASF dual-hosted git repository.

dmysakovets pushed a commit to branch terraform
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git


The following commit(s) were added to refs/heads/terraform by this push:
     new 7b79f32  [terraform] Refactoring variables[1]
7b79f32 is described below

commit 7b79f32d08e9b829d1b105dc371d14c04d334eb9
Author: Demyan Mysakovets <[email protected]>
AuthorDate: Thu May 30 23:54:04 2019 +0300

    [terraform] Refactoring variables[1]
---
 infrastructure-provisioning/terraform/main/main.tf |  1 +
 .../terraform/main/variables.tf                    |  2 +-
 .../terraform/modules/ssn/instance.tf              | 17 ++++++++++-------
 .../terraform/modules/ssn/network.tf               | 11 ++++++++---
 .../terraform/modules/ssn/service_accounts.tf      | 22 ----------------------
 .../terraform/modules/ssn/variables.tf             | 12 +++++++-----
 6 files changed, 27 insertions(+), 38 deletions(-)

diff --git a/infrastructure-provisioning/terraform/main/main.tf 
b/infrastructure-provisioning/terraform/main/main.tf
index a008df0..fe0fc95 100644
--- a/infrastructure-provisioning/terraform/main/main.tf
+++ b/infrastructure-provisioning/terraform/main/main.tf
@@ -1,5 +1,6 @@
 provider "google" {
   version     = "~> 2.7"
+  credentials = "${file("/home/demianmysakovets/.keys/service_account.json")}"
   project     = "${var.project_var}"
   region      = "${var.region_var}"
   zone        = "${var.zone_var}"
diff --git a/infrastructure-provisioning/terraform/main/variables.tf 
b/infrastructure-provisioning/terraform/main/variables.tf
index 1e08c1e..f523595 100644
--- a/infrastructure-provisioning/terraform/main/variables.tf
+++ b/infrastructure-provisioning/terraform/main/variables.tf
@@ -3,7 +3,7 @@ variable "project_var" {
 }
 
 variable "project_name_var" {
-  default = "dem-test-terraform2"
+  default = "dem-test-terraform4"
 }
 
 variable "region_var" {
diff --git a/infrastructure-provisioning/terraform/modules/ssn/instance.tf 
b/infrastructure-provisioning/terraform/modules/ssn/instance.tf
index 4cc0527..cbf5238 100644
--- a/infrastructure-provisioning/terraform/modules/ssn/instance.tf
+++ b/infrastructure-provisioning/terraform/modules/ssn/instance.tf
@@ -1,3 +1,6 @@
+locals {
+  compute_instance_name = "${var.env_name}-${var.instance_name}"
+}
 provider "google" {
   project     = "${var.project_var}"
   region = "${var.region}"
@@ -9,7 +12,7 @@ resource "google_compute_address" "ssn-ip" {
 }
 
 resource "google_compute_instance" "ssn" {
-  name = "${var.}"
+  name = "${local.compute_instance_name}"
   machine_type = "${var.machine_type_var}"
   tags = ["${var.tags_var}"]
   zone  = "${var.zone}"
@@ -22,13 +25,13 @@ resource "google_compute_instance" "ssn" {
   }
 
   labels = {
-    name = "${var.project_name_var}-ssn"
-    product = "dlab"
-    sbn = "${var.project_name_var}"
+    name = "${local.compute_instance_name}"
+    product = "${var.product_name}"
+    sbn = "${var.env_name}"
   }
 
   metadata = {
-    ssh-keys = "ubuntu:${file("~/keys/id_rsa.pub")}"
+    ssh-keys = "ubuntu:${file("~/.keys/id_rsa.pub")}"
   }
 
 /*  service_account {
@@ -37,8 +40,8 @@ resource "google_compute_instance" "ssn" {
   }
 */
   network_interface {
-    network = "${var.project_name_var}-vpc"
-    subnetwork = "${var.project_name_var}-subnet"
+    network = "${google_compute_network.vpc.name}"
+    subnetwork = "${google_compute_subnetwork.subnet.name}"
     access_config {
       nat_ip = "${google_compute_address.ssn-ip.address}"
     }
diff --git a/infrastructure-provisioning/terraform/modules/ssn/network.tf 
b/infrastructure-provisioning/terraform/modules/ssn/network.tf
index 8cb9c0b..f4832c0 100644
--- a/infrastructure-provisioning/terraform/modules/ssn/network.tf
+++ b/infrastructure-provisioning/terraform/modules/ssn/network.tf
@@ -1,18 +1,23 @@
+locals {
+  subnet_name = "${var.env_name}-${var.instance_name}-subnet"
+  firewall_ingress_name = "${var.env_name}"
+}
+
 resource "google_compute_network" "vpc" {
-  name          =  "${var.project_name_var}-vpc"
+  name          =  "${var.env_name}-vpc"
   auto_create_subnetworks = "false"
   routing_mode            = "GLOBAL"
 }
 
 resource "google_compute_subnetwork" "subnet" {
-  name          = "${var.subnet}"
+  name          = "${local.subnet_name}"
   ip_cidr_range = "${var.cidr}"
   region        = "${var.region}"
   network       = "${google_compute_network.vpc.self_link}"
 }
 
 resource "google_compute_firewall" "firewall-ingress" {
-  name    = "${var.firewall_ingress_name}"
+  name    = "${local.firewall_ingress_name}"
   network = "${google_compute_network.vpc.name}"
   allow {
     protocol = "tcp"
diff --git 
a/infrastructure-provisioning/terraform/modules/ssn/service_accounts.tf 
b/infrastructure-provisioning/terraform/modules/ssn/service_accounts.tf
deleted file mode 100644
index 37c4e5f..0000000
--- a/infrastructure-provisioning/terraform/modules/ssn/service_accounts.tf
+++ /dev/null
@@ -1,22 +0,0 @@
-resource "google_service_account" "ssn_sa" {
-  account_id   = "${var.service_name}-ssn-sa"
-  display_name = "${var.service_name}-ssn-sa"
-}
-
-# Create a Service Account key by default
-resource "google_service_account_key" "ssn_sa_key" {
-  depends_on         = [google_project_iam_member.iam]
-  service_account_id = google_service_account.ssn_sa.name
-}
-
-resource "google_project_iam_custom_role" "custom_ssn_role" {
-  role_id     = "${var.service_name}-ssn-role"
-  title       = "${var.service_name}-ssn-role"
-  permissions = "${var.ssn_policy}"
-}
-
-resource "google_project_iam_member" "iam" {
-  count  = "${length(var.ssn_roles)}"
-  member = "serviceAccount:${google_service_account.ssn_sa.email}"
-  role   = "${element(var.ssn_roles, count.index)}"
-}
diff --git a/infrastructure-provisioning/terraform/modules/ssn/variables.tf 
b/infrastructure-provisioning/terraform/modules/ssn/variables.tf
index f181e2d..c4724d6 100644
--- a/infrastructure-provisioning/terraform/modules/ssn/variables.tf
+++ b/infrastructure-provisioning/terraform/modules/ssn/variables.tf
@@ -2,14 +2,16 @@ variable "project_var" {
   default = "or2-msq-epmc-dlab-t1iylu"
 }
 
-variable "project_name_var" {
-  default = "dem-test-terraform"
+variable "env_name" {
+  default = "dem-test-terraform4"
 }
 
-variable "proje" {}
+variable "instance_name" {
+  default = "ssn"
+}
 
-variable "subnet_name" {
-  default = "dem-test-terraform-ssn-subnet"
+variable "product_name" {
+  default = "dlab"
 }
 
 variable "firewall_ingress_name" {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to