You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by dm...@apache.org on 2019/05/31 13:23:56 UTC
[incubator-dlab] branch terraform updated (95a8dcb -> 44b4409)
This is an automated email from the ASF dual-hosted git repository.
dmysakovets pushed a change to branch terraform
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git.
from 95a8dcb [terraform] Refactoring variables[2] / added service account creation
new 0f76338 [terraform] Refactoring variables
new 44b4409 [terraform] Refactoring variables / bugfixing
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
infrastructure-provisioning/terraform/main/main.tf | 4 +++
.../terraform/main/variables.tf | 4 +--
.../terraform/modules/ssn/instance.tf | 19 +++++------
.../terraform/modules/ssn/network.tf | 19 ++++-------
.../terraform/modules/ssn/service_accounts.tf | 15 ++++++---
.../terraform/modules/ssn/variables.tf | 37 +++++++---------------
6 files changed, 42 insertions(+), 56 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org
[incubator-dlab] 01/02: [terraform] Refactoring variables
Posted by dm...@apache.org.
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
commit 0f763386303457e812ad61e7b1a76481581aec5b
Author: Dyoma33 <de...@gmail.com>
AuthorDate: Fri May 31 15:30:03 2019 +0300
[terraform] Refactoring variables
---
infrastructure-provisioning/terraform/main/main.tf | 4 +++
.../terraform/main/variables.tf | 2 +-
.../terraform/modules/ssn/instance.tf | 19 +++++------
.../terraform/modules/ssn/network.tf | 19 ++++-------
.../terraform/modules/ssn/service_accounts.tf | 8 ++---
.../terraform/modules/ssn/variables.tf | 37 +++++++---------------
6 files changed, 35 insertions(+), 54 deletions(-)
diff --git a/infrastructure-provisioning/terraform/main/main.tf b/infrastructure-provisioning/terraform/main/main.tf
index fe0fc95..3573340 100644
--- a/infrastructure-provisioning/terraform/main/main.tf
+++ b/infrastructure-provisioning/terraform/main/main.tf
@@ -8,4 +8,8 @@ provider "google" {
module "ssn" {
source = "../modules/ssn"
+ project_var = "${var.project_var}"
+ env_name = "${var.env_name}"
+ region_var = "${var.region_var}"
+ zone_var = "${var.zone_var}"
}
\ No newline at end of file
diff --git a/infrastructure-provisioning/terraform/main/variables.tf b/infrastructure-provisioning/terraform/main/variables.tf
index f523595..55012ad 100644
--- a/infrastructure-provisioning/terraform/main/variables.tf
+++ b/infrastructure-provisioning/terraform/main/variables.tf
@@ -2,7 +2,7 @@ variable "project_var" {
default = "or2-msq-epmc-dlab-t1iylu"
}
-variable "project_name_var" {
+variable "env_name" {
default = "dem-test-terraform4"
}
diff --git a/infrastructure-provisioning/terraform/modules/ssn/instance.tf b/infrastructure-provisioning/terraform/modules/ssn/instance.tf
index f193b88..0c6dd57 100644
--- a/infrastructure-provisioning/terraform/modules/ssn/instance.tf
+++ b/infrastructure-provisioning/terraform/modules/ssn/instance.tf
@@ -1,31 +1,28 @@
-locals {
- compute_instance_name = "${var.env_name}-${var.instance_name}"
-}
provider "google" {
project = "${var.project_var}"
- region = "${var.region}"
+ region = "${var.region_var}"
}
resource "google_compute_address" "ssn-ip" {
- name = "${var.ssn-ip}"
+ name = "${var.env_name}-${var.instance_name}-ip"
address_type = "EXTERNAL"
}
resource "google_compute_instance" "ssn" {
- name = "${local.compute_instance_name}"
+ name = "${var.env_name}-${var.instance_name}-ssn"
machine_type = "${var.machine_type_var}"
- tags = ["${var.tags_var}"]
- zone = "${var.zone}"
+ tags = ["${var.env_name}-${var.instance_name}"]
+ zone = "${var.zone_var}"
boot_disk {
initialize_params {
image = "${var.image_name}"
- size = 20
+ size = "${var.boot_disk_size}"
}
}
labels = {
- name = "${local.compute_instance_name}"
+ name = "${var.env_name}-${var.instance_name}-ssn"
product = "${var.product_name}"
sbn = "${var.env_name}"
}
@@ -35,7 +32,7 @@ resource "google_compute_instance" "ssn" {
}
service_account {
- email = "${google_service_account.ssn_sa.email}" #"${var.project_name_var}-ssn-sa@${var.project_var}.iam.gserviceaccount.com"
+ email = "${google_service_account.ssn_sa.email}"
scopes = ["https://www.googleapis.com/auth/cloud-platform", "https://www.googleapis.com/auth/compute"]
}
diff --git a/infrastructure-provisioning/terraform/modules/ssn/network.tf b/infrastructure-provisioning/terraform/modules/ssn/network.tf
index f4832c0..536a532 100644
--- a/infrastructure-provisioning/terraform/modules/ssn/network.tf
+++ b/infrastructure-provisioning/terraform/modules/ssn/network.tf
@@ -1,8 +1,3 @@
-locals {
- subnet_name = "${var.env_name}-${var.instance_name}-subnet"
- firewall_ingress_name = "${var.env_name}"
-}
-
resource "google_compute_network" "vpc" {
name = "${var.env_name}-vpc"
auto_create_subnetworks = "false"
@@ -10,30 +5,30 @@ resource "google_compute_network" "vpc" {
}
resource "google_compute_subnetwork" "subnet" {
- name = "${local.subnet_name}"
+ name = "${var.env_name}-${var.instance_name}-subnet"
ip_cidr_range = "${var.cidr}"
- region = "${var.region}"
+ region = "${var.region_var}"
network = "${google_compute_network.vpc.self_link}"
}
resource "google_compute_firewall" "firewall-ingress" {
- name = "${local.firewall_ingress_name}"
+ name = "${var.env_name}-${var.instance_name}-firewall_ingress"
network = "${google_compute_network.vpc.name}"
allow {
protocol = "tcp"
- ports = ["22", "80", "443"]
+ ports = "${var.ssn_ports_var}"
}
- target_tags = ["${var.tags_var}"]
+ target_tags = ["${var.env_name}-${var.instance_name}"]
source_ranges = ["${var.firewall_cidr_ranges}"]
}
resource "google_compute_firewall" "firewall-egress" {
- name = "${var.firewall_egress_name}"
+ name = "${var.env_name}-${var.instance_name}-firewall_egress"
network = "${google_compute_network.vpc.name}"
direction = "EGRESS"
allow {
protocol = "all"
}
- target_tags = ["${var.tags_var}"]
+ target_tags = ["${var.env_name}-${var.instance_name}"]
destination_ranges = ["${var.firewall_cidr_ranges}"]
}
diff --git a/infrastructure-provisioning/terraform/modules/ssn/service_accounts.tf b/infrastructure-provisioning/terraform/modules/ssn/service_accounts.tf
index cf3d863..8595e4e 100644
--- a/infrastructure-provisioning/terraform/modules/ssn/service_accounts.tf
+++ b/infrastructure-provisioning/terraform/modules/ssn/service_accounts.tf
@@ -4,8 +4,8 @@ locals {
}
resource "google_service_account" "ssn_sa" {
- account_id = "${local.service_name}"
- display_name = "${local.service_name}"
+ account_id = "${var.env_name}-ssn-sa"
+ display_name = "${var.env_name}-ssn-sa"
}
# Create a Service Account key by default
@@ -15,8 +15,8 @@ resource "google_service_account_key" "ssn_sa_key" {
}
resource "google_project_iam_custom_role" "my-custom-role" {
- role_id = "${replace(local.role_name, "-", "_")}"
- title = "${local.role_name}"
+ role_id = "${replace(${var.env_name}-ssn-role, "-", "_")}"
+ title = "${var.env_name}-ssn-role"
permissions = "${var.ssn_policy}"
}
diff --git a/infrastructure-provisioning/terraform/modules/ssn/variables.tf b/infrastructure-provisioning/terraform/modules/ssn/variables.tf
index f0513a0..5971749 100644
--- a/infrastructure-provisioning/terraform/modules/ssn/variables.tf
+++ b/infrastructure-provisioning/terraform/modules/ssn/variables.tf
@@ -1,10 +1,10 @@
-variable "project_var" {
- default = "or2-msq-epmc-dlab-t1iylu"
-}
+variable "project_var" {}
-variable "env_name" {
- default = "dem-test-terraform4"
-}
+variable "env_name" {}
+
+variable "region_var" {}
+
+variable "zone_var" {}
variable "instance_name" {
default = "ssn"
@@ -14,42 +14,27 @@ variable "product_name" {
default = "dlab"
}
-variable "firewall_ingress_name" {
- default = "dem-test-terraform-ssn-firewall-ingress"
+variable "boot_disk_size" {
+ default = 20
}
-variable "firewall_egress_name" {
- default = "dem-test-terraform-ssn-firewal-egress"
-}
-
-variable "tags_var" {
- default = "dem-test-terraform-ssn"
+variable "ssn_ports_var" {
+ type = "list"
+ default = ["22", "80", "443"]
}
variable "firewall_cidr_ranges" {
default = "0.0.0.0/0"
}
-variable "ssn-ip" {
- default = "dem-test-terraform-ssn"
-}
-
variable "machine_type_var" {
default = "n1-standard-1"
}
-variable "region" {
- default = "us-east1"
-}
-
variable "cidr" {
default = "172.31.0.0/20"
}
-variable "zone" {
- default = "us-east1-c"
-}
-
variable "image_name" {
default = "ubuntu-1604-xenial-v20170721"
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org
[incubator-dlab] 02/02: [terraform] Refactoring variables /
bugfixing
Posted by dm...@apache.org.
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
commit 44b440992d121ffb02bf39b6736b6e5c4a9ef7b8
Author: Dyoma33 <de...@gmail.com>
AuthorDate: Fri May 31 16:23:43 2019 +0300
[terraform] Refactoring variables / bugfixing
---
infrastructure-provisioning/terraform/main/variables.tf | 2 +-
.../terraform/modules/ssn/service_accounts.tf | 9 +++++++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/infrastructure-provisioning/terraform/main/variables.tf b/infrastructure-provisioning/terraform/main/variables.tf
index 55012ad..b86f04f 100644
--- a/infrastructure-provisioning/terraform/main/variables.tf
+++ b/infrastructure-provisioning/terraform/main/variables.tf
@@ -3,7 +3,7 @@ variable "project_var" {
}
variable "env_name" {
- default = "dem-test-terraform4"
+ default = "dem-test-terraform5"
}
variable "region_var" {
diff --git a/infrastructure-provisioning/terraform/modules/ssn/service_accounts.tf b/infrastructure-provisioning/terraform/modules/ssn/service_accounts.tf
index 8595e4e..c2f1981 100644
--- a/infrastructure-provisioning/terraform/modules/ssn/service_accounts.tf
+++ b/infrastructure-provisioning/terraform/modules/ssn/service_accounts.tf
@@ -14,12 +14,17 @@ resource "google_service_account_key" "ssn_sa_key" {
service_account_id = google_service_account.ssn_sa.name
}
-resource "google_project_iam_custom_role" "my-custom-role" {
- role_id = "${replace(${var.env_name}-ssn-role, "-", "_")}"
+resource "google_project_iam_custom_role" "ssn-custom-role" {
+ role_id = "${replace("${var.env_name}-ssn-role", "-", "_")}"
title = "${var.env_name}-ssn-role"
permissions = "${var.ssn_policy}"
}
+resource "google_project_iam_member" "custom-role" {
+ member = "serviceAccount:${google_service_account.ssn_sa.email}"
+ role = "${google_project_iam_custom_role.ssn-custom-role.id}"
+}
+
resource "google_project_iam_member" "iam" {
count = "${length(var.ssn_roles)}"
member = "serviceAccount:${google_service_account.ssn_sa.email}"
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org