-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* datasource for pbrs * lint fixes. go error (gomnd, gosimple, golint) * go checks, magic numbers(gomnd) * fix config testcase as base client will differ in sdks * tests and docs for pbrs * change module name from v4 to v2 * change package name to networkingv2 * add pbr_v2 example * fix import --------- Co-authored-by: Abhishek <[email protected]>
- Loading branch information
1 parent
518378f
commit 4ff3f14
Showing
18 changed files
with
2,929 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
terraform{ | ||
required_providers { | ||
nutanix = { | ||
source = "nutanix/nutanix" | ||
version = "1.6.0" | ||
} | ||
} | ||
} | ||
|
||
#defining nutanix configuration | ||
provider "nutanix"{ | ||
username = var.nutanix_username | ||
password = var.nutanix_password | ||
endpoint = var.nutanix_endpoint | ||
port = 9440 | ||
insecure = true | ||
} | ||
|
||
# create PBR with vpc name with any source or destination or protocol with permit action | ||
|
||
resource "nutanix_pbr_v2" "pbr1" { | ||
name = "%[1]s" | ||
description = "%[2]s" | ||
vpc_ext_id = var.vpc_reference_uuid | ||
priority = 14 | ||
policies{ | ||
policy_match{ | ||
source{ | ||
address_type = "ANY" | ||
} | ||
destination{ | ||
address_type = "ANY" | ||
} | ||
protocol_type = "UDP" | ||
} | ||
policy_action{ | ||
action_type = "PERMIT" | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
# create PBR with vpc uuid with source external | ||
|
||
resource "nutanix_pbr_v2" "pbr2" { | ||
name = "%[1]s" | ||
description = "%[2]s" | ||
vpc_ext_id = var.vpc_reference_uuid | ||
priority = 11 | ||
policies{ | ||
policy_match{ | ||
source{ | ||
address_type = "EXTERNAL" | ||
} | ||
destination{ | ||
address_type = "SUBNET" | ||
subnet_prefix{ | ||
ipv4{ | ||
ip{ | ||
value= "10.10.10.0" | ||
prefix_length = 24 | ||
} | ||
} | ||
} | ||
} | ||
protocol_type = "ANY" | ||
} | ||
policy_action{ | ||
action_type = "FORWARD" | ||
nexthop_ip_address{ | ||
ipv4{ | ||
value = "10.10.10.10" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
#create PBR with vpc name with source Any and destination external | ||
resource "nutanix_pbr_v2" "pbr3" { | ||
name = "%[1]s" | ||
description = "%[2]s" | ||
vpc_ext_id = var.vpc_reference_uuid | ||
priority = 14 | ||
policies{ | ||
policy_match{ | ||
source{ | ||
address_type = "ALL" | ||
} | ||
destination{ | ||
address_type = "INTERNET" | ||
} | ||
protocol_type = "UDP" | ||
} | ||
policy_action{ | ||
action_type = "PERMIT" | ||
} | ||
} | ||
} | ||
|
||
# list pbr | ||
|
||
data "nutanix_pbrs_v2" "pbr4" { | ||
} | ||
|
||
|
||
|
||
# get an entity with pbr uuid | ||
|
||
data "nutanix_pbr_v2" "pbr5" { | ||
ext_id = resource.nutanix_pbr_v2.rtest.ext_id | ||
depends_on = [ | ||
resource.nutanix_pbr_v2.rtest | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#define values to the variables to be used in terraform file | ||
nutanix_username = "admin" | ||
nutanix_password = "password" | ||
nutanix_endpoint = "10.xx.xx.xx" | ||
nutanix_port = 9440 | ||
vpc_reference_uuid = "<vpc_uuid>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#define the type of variables to be used in terraform file | ||
variable "nutanix_username" { | ||
type = string | ||
} | ||
variable "nutanix_password" { | ||
type = string | ||
} | ||
variable "nutanix_endpoint" { | ||
type = string | ||
} | ||
variable "nutanix_port" { | ||
type = string | ||
} | ||
|
||
variable "vpc_reference_uuid" { | ||
type = string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.