This is an automated email from the ASF dual-hosted git repository.
omartushevskyi pushed a commit to branch DLAB-1467
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
The following commit(s) were added to refs/heads/DLAB-1467 by this push:
new ca9ad21 [DLAB-1467]: Added terraform scripts for endpoint deployment
on Azure
ca9ad21 is described below
commit ca9ad219ea81ba66b4131a630160f8bf3df79670
Author: Oleh Martushevskyi <[email protected]>
AuthorDate: Mon Jan 27 16:49:20 2020 +0200
[DLAB-1467]: Added terraform scripts for endpoint deployment on Azure
---
.../terraform/azure/endpoint/main/main.tf | 16 +++++-
.../terraform/azure/endpoint/main/network.tf | 62 ++++++++++++++++++++++
.../terraform/azure/endpoint/main/variables.tf | 34 +++++++++++-
3 files changed, 110 insertions(+), 2 deletions(-)
diff --git a/infrastructure-provisioning/terraform/azure/endpoint/main/main.tf
b/infrastructure-provisioning/terraform/azure/endpoint/main/main.tf
index fd6c252..f9501d8 100644
--- a/infrastructure-provisioning/terraform/azure/endpoint/main/main.tf
+++ b/infrastructure-provisioning/terraform/azure/endpoint/main/main.tf
@@ -28,4 +28,18 @@ provider "azurerm" {
client_id = local.json_data.clientId
client_secret = local.json_data.clientSecret
tenant_id = local.json_data.tenantId
-}
\ No newline at end of file
+}
+
+resource "azurerm_resource_group" "endpoint-resource-group" {
+ count = var.resource_group_name == "" ? 1 : 0
+ name = var.service_base_name
+ location = var.region
+
+ tags = {
+ Name = var.service_base_name
+ }
+}
+
+data "azurerm_resource_group" "data-endpoint-resource-group" {
+ name = var.resource_group_name == "" ?
azurerm_resource_group.endpoint-resource-group.name : var.resource_group_name
+}
diff --git
a/infrastructure-provisioning/terraform/azure/endpoint/main/network.tf
b/infrastructure-provisioning/terraform/azure/endpoint/main/network.tf
new file mode 100644
index 0000000..96973a7
--- /dev/null
+++ b/infrastructure-provisioning/terraform/azure/endpoint/main/network.tf
@@ -0,0 +1,62 @@
+# *****************************************************************************
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
******************************************************************************
+
+locals {
+ endpoint_subnet_name =
"${var.service_base_name}-${var.endpoint_id}-subnet"
+ endpoint_sg_name = "${var.service_base_name}-${var.endpoint_id}-sg"
+ endpoint_vpc_name = "${var.service_base_name}-endpoint-vpc"
+ additional_tag = split(":", var.additional_tag)
+ endpoint_ip_name =
"${var.service_base_name}-${var.endpoint_id}-eip"
+}
+
+resource "azurerm_virtual_network" "endpoint-network" {
+ count = var.vpc_id == "" ? 1 : 0
+ name = local.endpoint_vpc_name
+ location =
data.azurerm_resource_group.data-endpoint-resource-group.location
+ resource_group_name =
data.azurerm_resource_group.data-endpoint-resource-group.name
+ address_space = [var.vpc_cidr]
+
+ tags = {
+ Name = local.endpoint_vpc_name
+ "${local.additional_tag[0]}" = local.additional_tag[1]
+ "${var.tag_resource_id}" =
"${var.service_base_name}:${local.endpoint_vpc_name}"
+ "${var.service_base_name}-Tag" = local.endpoint_vpc_name
+ }
+}
+
+data "azurerm_virtual_network" "data-endpoint-network" {
+ name = var.vpc_id == "" ?
azurerm_virtual_network.endpoint-network.name : var.vpc_id
+ resource_group_name =
data.azurerm_resource_group.data-endpoint-resource-group.name
+}
+
+resource "azurerm_subnet" "endpoint-subnet" {
+ count = var.subnet_id == "" ? 1 : 0
+ name = local.endpoint_subnet_name
+ resource_group_name =
data.azurerm_resource_group.data-endpoint-resource-group.name
+ virtual_network_name =
data.azurerm_virtual_network.data-endpoint-network.name
+ address_prefix = var.subnet_cidr
+}
+
+data "azurerm_subnet" "data-endpoint-subnet" {
+ name = var.subnet_id == "" ?
azurerm_subnet.endpoint-subnet.name : var.subnet_id
+ virtual_network_name =
data.azurerm_virtual_network.data-endpoint-network.name
+ resource_group_name =
data.azurerm_resource_group.data-endpoint-resource-group.name
+}
\ No newline at end of file
diff --git
a/infrastructure-provisioning/terraform/azure/endpoint/main/variables.tf
b/infrastructure-provisioning/terraform/azure/endpoint/main/variables.tf
index 0d51b0e..1ed010d 100644
--- a/infrastructure-provisioning/terraform/azure/endpoint/main/variables.tf
+++ b/infrastructure-provisioning/terraform/azure/endpoint/main/variables.tf
@@ -19,4 +19,36 @@
#
#
******************************************************************************
-variable "auth_file_path" {}
\ No newline at end of file
+variable "auth_file_path" {}
+
+variable "resource_group_name" {
+ default = ""
+}
+
+variable "region" {
+ default = "West US 2"
+}
+
+variable "service_base_name" {}
+
+variable "endpoint_id" {}
+
+variable "additional_tag" {
+ default = "product:dlab"
+}
+
+variable "vpc_cidr" {}
+
+variable "tag_resource_id" {
+ default = "user:tag"
+}
+
+variable "vpc_id" {
+ default = ""
+}
+
+variable "subnet_id" {
+ default = ""
+}
+
+variable "subnet_cidr" {}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]