Skip to content

Commit

Permalink
Merge pull request #56 from avinetworks/AV-66420-new
Browse files Browse the repository at this point in the history
AV-66420 Added examples for avi virtualservices
  • Loading branch information
Gaurav Rastogi authored Apr 17, 2020
2 parents fda530c + 897f145 commit f9ab67e
Show file tree
Hide file tree
Showing 12 changed files with 572 additions and 0 deletions.
77 changes: 77 additions & 0 deletions examples/virtualservice/dns_vs/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
provider "avi" {
avi_username = var.avi_username
avi_tenant = "admin"
avi_password = var.avi_password
avi_controller = var.avi_controller
avi_version = var.avi_version
avi_api_timeout = 50
}

data "avi_tenant" "default_tenant" {
name = "admin"
}
data "avi_cloud" "default_cloud" {
name = "Default-Cloud"
}
data "avi_sslkeyandcertificate" "ssl_cert1" {
name = var.ssl_key_cert1
}
data "avi_sslprofile" "ssl_profile1" {
name = var.ssl_profile1
}
data "avi_applicationprofile" "application_profile1" {
name = var.application_profile1
}
data "avi_networkprofile" "network_profile1" {
name = var.network_profile
}

resource "avi_pool" "lb_pool" {
name = var.pool_name
lb_algorithm = var.lb_algorithm
servers {
ip {
type = "V4"
addr = var.server1_ip
}
port = var.server1_port
}
tenant_ref = data.avi_tenant.default_tenant.id
}

resource "avi_poolgroup" "poolgroup1" {
name = var.poolgroup_name
members {
pool_ref = avi_pool.lb_pool.id
ratio = 100
}
tenant_ref = data.avi_tenant.default_tenant.id
}

resource "avi_vsvip" "test_vsvip" {
name = "terraform-vip"
vip {
vip_id = "0"
ip_address {
type = "V4"
addr = var.avi_terraform_vs_vip
}
}
tenant_ref = data.avi_tenant.default_tenant.id
}

resource "avi_virtualservice" "dns_vs" {
name = var.vs_name
pool_group_ref = avi_poolgroup.poolgroup1.id
tenant_ref = data.avi_tenant.default_tenant.id
vsvip_ref = avi_vsvip.test_vsvip.id
cloud_ref = data.avi_cloud.default_cloud.id
ssl_key_and_certificate_refs = [data.avi_sslkeyandcertificate.ssl_cert1.id]
ssl_profile_ref = data.avi_sslprofile.ssl_profile1.id
application_profile_ref = data.avi_applicationprofile.application_profile1.id
network_profile_ref = data.avi_networkprofile.network_profile1.id
services {
port = var.vs_port
enable_ssl = true
}
}
9 changes: 9 additions & 0 deletions examples/virtualservice/dns_vs/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
output "virtual_service" {
value = avi_virtualservice.dns_vs
}
output "pool" {
value = avi_pool.lb_pool
}
output "pool_group" {
value = avi_poolgroup.poolgroup1
}
65 changes: 65 additions & 0 deletions examples/virtualservice/dns_vs/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
variable "avi_username" {
type = string
default = ""
}
variable "avi_password" {
type = string
default = ""
}
variable "avi_controller" {
type = string
default = ""
}
variable "avi_version" {
type = string
default = ""
}
variable "pool_name" {
type = string
default = "pool1"
}
variable "lb_algorithm" {
type = string
default = "LB_ALGORITHM_ROUND_ROBIN"
}
variable "server1_ip" {
type = string
default = ""
}
variable "server1_port" {
type = number
default = 8000
}
variable "ssl_key_cert1" {
type = string
default = "System-Default-Cert"
}
variable "ssl_profile1" {
type = string
default = "System-Standard"
}
variable "application_profile1" {
type = string
default = "System-DNS"
}
variable "poolgroup_name" {
type = string
default = "poolgroup1"
}
variable "avi_terraform_vs_vip" {
type = string
default = ""
}
variable "vs_name" {
type = string
default = "vs1"
}
variable "vs_port" {
type = number
default = "8990"
}
variable "network_profile" {
type = string
default = "System-UDP-Per-Pkt"
}

69 changes: 69 additions & 0 deletions examples/virtualservice/http_vs/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
provider "avi" {
avi_username = var.avi_username
avi_tenant = "admin"
avi_password = var.avi_password
avi_controller = var.avi_controller
avi_version = var.avi_version
avi_api_timeout = 50
}

data "avi_tenant" "default_tenant" {
name = "admin"
}
data "avi_cloud" "default_cloud" {
name = "Default-Cloud"
}
data "avi_applicationprofile" "application_profile1" {
name = var.application_profile1
}
data "avi_networkprofile" "network_profile1" {
name = var.network_profile
}

resource "avi_pool" "lb_pool" {
name = var.pool_name
lb_algorithm = var.lb_algorithm
servers {
ip {
type = "V4"
addr = var.server1_ip
}
port = var.server1_port
}
tenant_ref = data.avi_tenant.default_tenant.id
}

resource "avi_poolgroup" "poolgroup1" {
name = var.poolgroup_name
members {
pool_ref = avi_pool.lb_pool.id
ratio = 100
}
tenant_ref = data.avi_tenant.default_tenant.id
}

resource "avi_vsvip" "test_vsvip" {
name = "terraform-vip"
vip {
vip_id = "0"
ip_address {
type = "V4"
addr = var.avi_terraform_vs_vip
}
}
tenant_ref = data.avi_tenant.default_tenant.id
}

resource "avi_virtualservice" "http_vs" {
name = var.vs_name
pool_group_ref = avi_poolgroup.poolgroup1.id
tenant_ref = data.avi_tenant.default_tenant.id
vsvip_ref = avi_vsvip.test_vsvip.id
cloud_ref = data.avi_cloud.default_cloud.id
application_profile_ref = data.avi_applicationprofile.application_profile1.id
network_profile_ref = data.avi_networkprofile.network_profile1.id
services {
port = var.vs_port
enable_ssl = false
}
}
9 changes: 9 additions & 0 deletions examples/virtualservice/http_vs/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
output "virtual_service" {
value = avi_virtualservice.http_vs
}
output "pool" {
value = avi_pool.lb_pool
}
output "pool_group" {
value = avi_poolgroup.poolgroup1
}
57 changes: 57 additions & 0 deletions examples/virtualservice/http_vs/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
variable "avi_username" {
type = string
default = ""
}
variable "avi_password" {
type = string
default = ""
}
variable "avi_controller" {
type = string
default = ""
}
variable "avi_version" {
type = string
default = ""
}
variable "pool_name" {
type = string
default = "pool1"
}
variable "lb_algorithm" {
type = string
default = "LB_ALGORITHM_ROUND_ROBIN"
}
variable "server1_ip" {
type = string
default = ""
}
variable "server1_port" {
type = number
default = 8000
}
variable "application_profile1" {
type = string
default = "System-HTTP"
}
variable "poolgroup_name" {
type = string
default = "poolgroup1"
}
variable "avi_terraform_vs_vip" {
type = string
default = ""
}
variable "vs_name" {
type = string
default = "vs1"
}
variable "vs_port" {
type = number
default = "8990"
}
variable "network_profile" {
type = string
default = "System-TCP-Proxy"
}

77 changes: 77 additions & 0 deletions examples/virtualservice/https_vs/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
provider "avi" {
avi_username = var.avi_username
avi_tenant = "admin"
avi_password = var.avi_password
avi_controller = var.avi_controller
avi_version = var.avi_version
avi_api_timeout = 50
}

data "avi_tenant" "default_tenant" {
name = "admin"
}
data "avi_cloud" "default_cloud" {
name = "Default-Cloud"
}
data "avi_sslkeyandcertificate" "ssl_cert1" {
name = var.ssl_key_cert1
}
data "avi_sslprofile" "ssl_profile1" {
name = var.ssl_profile1
}
data "avi_applicationprofile" "application_profile1" {
name = var.application_profile1
}
data "avi_networkprofile" "network_profile1" {
name = var.network_profile
}

resource "avi_pool" "lb_pool" {
name = var.pool_name
lb_algorithm = var.lb_algorithm
servers {
ip {
type = "V4"
addr = var.server1_ip
}
port = var.server1_port
}
tenant_ref = data.avi_tenant.default_tenant.id
}

resource "avi_poolgroup" "poolgroup1" {
name = var.poolgroup_name
members {
pool_ref = avi_pool.lb_pool.id
ratio = 100
}
tenant_ref = data.avi_tenant.default_tenant.id
}

resource "avi_vsvip" "test_vsvip" {
name = "terraform-vip"
vip {
vip_id = "0"
ip_address {
type = "V4"
addr = var.avi_terraform_vs_vip
}
}
tenant_ref = data.avi_tenant.default_tenant.id
}

resource "avi_virtualservice" "https_vs" {
name = var.vs_name
pool_group_ref = avi_poolgroup.poolgroup1.id
tenant_ref = data.avi_tenant.default_tenant.id
vsvip_ref = avi_vsvip.test_vsvip.id
cloud_ref = data.avi_cloud.default_cloud.id
ssl_key_and_certificate_refs = [data.avi_sslkeyandcertificate.ssl_cert1.id]
ssl_profile_ref = data.avi_sslprofile.ssl_profile1.id
application_profile_ref = data.avi_applicationprofile.application_profile1.id
network_profile_ref = data.avi_networkprofile.network_profile1.id
services {
port = var.vs_port
enable_ssl = true
}
}
9 changes: 9 additions & 0 deletions examples/virtualservice/https_vs/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
output "virtual_service" {
value = avi_virtualservice.https_vs
}
output "pool" {
value = avi_pool.lb_pool
}
output "pool_group" {
value = avi_poolgroup.poolgroup1
}
Loading

0 comments on commit f9ab67e

Please sign in to comment.