Skip to content

Commit

Permalink
Added generation of VNET
Browse files Browse the repository at this point in the history
  • Loading branch information
seriva committed Aug 13, 2019
1 parent c61561d commit 3b8f88a
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ def __init__(self, docs):
self.cluster_model = select_single(docs, lambda x: x.kind == 'epiphany-cluster')
self.cluster_name = self.cluster_model.specification.name.lower()
self.cluster_prefix = self.cluster_model.specification.prefix.lower()
self.resource_group_name = resource_name(self.cluster_prefix, self.cluster_name, 'rg')
self.region = self.cluster_model.specification.cloud.region
self.docs = docs

def run(self):
Expand All @@ -18,13 +20,24 @@ def run(self):
resource_group = self.get_resource_group()
infrastructure.append(resource_group)

vnet = self.get_virtual_network()
infrastructure.append(vnet)

return infrastructure

def get_resource_group(self):
resource_group = self.get_config_or_default(self.docs, 'infrastructure/resource-group')
resource_group.specification.name = resource_name(self.cluster_prefix, self.cluster_name, 'rg')
resource_group.specification.name = self.resource_group_name
resource_group.specification.region = self.cluster_model.specification.cloud.region
return resource_group

def get_virtual_network(self):
vnet = self.get_config_or_default(self.docs, 'infrastructure/vnet')
vnet.specification.name = resource_name(self.cluster_prefix, self.cluster_name, 'vnet')
vnet.specification.address_space = self.cluster_model.specification.cloud.vnet_address_pool
vnet.specification.resource_group_name = self.resource_group_name
vnet.specification.location = self.cluster_model.specification.cloud.region
return vnet

@staticmethod
def get_config_or_default(docs, kind):
Expand Down

This file was deleted.

10 changes: 10 additions & 0 deletions core/src/epicli/data/azure/defaults/infrastructure/vnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
kind: infrastructure/vnet
version: 0.3.0
title: "VNET Config"
provider: azure
name: default
specification:
name: SET_BY_AUTOMATION
address_space: SET_BY_AUTOMATION
location: SET_BY_AUTOMATION
resource_group_name: SET_BY_AUTOMATION
1 change: 0 additions & 1 deletion core/src/epicli/data/azure/terraform/infrastructure/net.j2

This file was deleted.

This file was deleted.

18 changes: 18 additions & 0 deletions core/src/epicli/data/azure/terraform/infrastructure/vnet.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#####################################################
# DO NOT Modify by hand - Managed by Automation
#####################################################
#####################################################
# This file can be used as a base template to build other Terraform files. It attempts to use as much
# Terraform interprolation as possible by creating Terraform variables instead of changing inline
# this approach provides an easier way to do creative looping, fetch IDs of created resources etc.
#####################################################
#####################################################
# {{ specification.name }}
#####################################################

resource "azurerm_virtual_network" "vnet" {
name = "{{ specification.name }}"
address_space = ["{{ specification.address_space }}"]
location = "{{ specification.location }}"
resource_group_name = "{{ specification.resource_group_name }}"
}

0 comments on commit 3b8f88a

Please sign in to comment.