Skip to content

Commit

Permalink
V4-iam on v4-temp-design-2.0 (#20)
Browse files Browse the repository at this point in the history
* Feat/1.9.3 (#633)

Co-authored-by: Abhishekism9450 <[email protected]>
Co-authored-by: Deepak Muley <[email protected]>
Co-authored-by: Abhishek <[email protected]>

* Feat/1.9.4 (#645)

Co-authored-by: Frederic M <[email protected]>
Co-authored-by: ArtemProt <[email protected]>
Co-authored-by: Abhishekism9450 <[email protected]>

* new tf design

* import changes

* package name change for fc

* package name for fc is foundationCentral

* package name to foundationcentral

* fixes around acctest

* examples folder

* v4 design

* some fixes after merging

* datasource for subnets,vpcs, fips

* 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

* datadource for clusters

* lint fixes

* host datasource

* lint fixes

* resource for user

* adding flatten funcs

* resource for subnets

* adding go mod for public repo

* lint fixes

* lint fix

* lint fix for client name

* test config as client will be different for sdks

* adding crud for fips

* address groups v4

* service groups

* resource for service groups

* crud for service groups

* CRUD for address groups

* data source for network security

* CRUD for network security

* microseg sdk pointing to internals

* datasource for directory services

* CRUD for directory service

* datasource for saml

* CRUD for idp

* CRUD auth policy

* delete Operation for directory service

* CRUD for user groups

* Roles info +CRUD logic

* change err check logic

* acc test for roles

* Docs & examples

* fix err message

* test_roles_config file for Testing

* d9ocs and examples for user groups

* setup and write test cases for user groups, Test is in progress

* fix user group destroy(If-Match header required for delete API) and change 'distinguished_name' attribute to required bcs we can not create user group without `distinguished_name`

* Skipping test as it requires a valid user group configuration,  and setup test_config_v4.json file

* fix test configuration v4 file

* fix test configuration v4 file

* fix test cases to use test_config_v4

* TestAccRolesV4Resource_Basic remove double check on client_name

* fix docs

* Docs and examples

* Add test configuration file and test cases for directory services, Skipping tests as configurations is not available yet

* add secondary_urls to directory service schema

* fix idp_metadata in datasource, add If-Match Header on delete resource and fix delete response, API just return response code

* add SamlIdpV4 to resource Map

* write acc test cases, datasorce test cases verified, resource test cases blocked bcs of idp_metadata.error_url issue

* fix error url issue, update resource test case , write docs

* test_config_v4 for nutanix_saml_identity_providers_v4

* update sdk to v4.0.2-beta.1,
users info done,
test cases need to be verified

* acc test cases for resource_users_v4

* fix username mistype

* docs for users_v4

* fix user resource

* fix CRUD and info for auth policies, there is a bug in CRUD , and info . identities.reserved and entities.reserved treated as JSONString

* fix bug on update auth policy

* acc test for authorization policy

* authorization policy v4 docs

* fix acc test cases, add more test cases to cover more scenarios in create user, test cases not verified duo to sdk upgrade  issue

* update provider, add "nutanix_user_v4" to resource and datasource  Map

* merge feat/v4-permissions  into v4-iam

* merge feat/v4-user-groups  into v4-iam

* remove all other modules, add sdk, fix operation module name update provider resource/data maps, fix the structure of  test_config_v4.json file

* add more roles test cases

* fix user test cases

* fix user test cases for data sources

* remove unnecessary temp folder

* remove unnecessary vendor folder

* exclude vendor

* exclude vendor

* add more acc tests cases, change the module name from v4 to v2,

* change the user module name from v4 to v2,

* change the roles module name from v4 to v2,

* change the operations module name from v4 to v2,

* change the authorization policy  module name from v4 to v2, add examples, update acc test for acps

* change the operation module files name from permissions to operations

* fix authorization_policy_v2 data_source  acc test case

* change the saml idp   module name from v4 to v2, add examples, update acc

* change the directory_service module name from v4 to v2, add and check acc tests, fix some bugs, add examples

* change the v2 iam package from iam to iamv2

* change the Roles, User Groups functions names from v4 to v2

* change the test configuration file name from v4 to v2

* Revert "exclude vendor"

This reverts commit 14c9f4c.

---------

Co-authored-by: Abhishek Chaudhary <[email protected]>
Co-authored-by: Abhishekism9450 <[email protected]>
Co-authored-by: Deepak Muley <[email protected]>
Co-authored-by: Abhishek <[email protected]>
Co-authored-by: Frederic M <[email protected]>
Co-authored-by: ArtemProt <[email protected]>
  • Loading branch information
7 people authored Sep 9, 2024
1 parent 91afc14 commit 81820b5
Show file tree
Hide file tree
Showing 93 changed files with 11,527 additions and 1 deletion.
48 changes: 48 additions & 0 deletions examples/authorization_policies_v2/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#Here we will get and list permissions
#the variable "" present in terraform.tfvars file.
#Note - Replace appropriate values of variables in terraform.tfvars file as per setup

terraform {
required_providers {
nutanix = {
source = "nutanix/nutanix"
version = "1.3.0"
}
}
}

#definig nutanix configuration
provider "nutanix" {
username = var.nutanix_username
password = var.nutanix_password
endpoint = var.nutanix_endpoint
port = var.nutanix_port
insecure = true
}

# creat authorization policy
resource "nutanix_authorization_policy_v2" "auth_policy_example" {
role = "<role_uuid>"
display_name = "<acp name>"
description = "<acp description>"
authorization_policy_type = "<acp type>"
# identity and entity will defined as a json string
identities {
reserved = "<identity_uuid>" # ex : "{\"user\":{\"uuid\":{\"anyof\":[\"00000000-0000-0000-0000-000000000000\"]}}}"
}
entities {
reserved = "<entity_uuid>" # ex : "{\"images\":{\"*\":{\"eq\":\"*\"}}}"
}
}

#get authorization policy by id
data "nutanix_authorization_policy_v2" "example" {
ext_id = nutanix_authorization_policy_v2.auth_policy_example.id
}


#list of authorization policies, with limit and filter
data "nutanix_authorization_policies_v2" "examples" {
limit = 2
filter = "display_name eq '<acp name>'"
}
8 changes: 8 additions & 0 deletions examples/authorization_policies_v2/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#replace the values as per setup configuration
nutanix_username = "admin"
nutanix_password = "Nutanix/123456"
nutanix_endpoint = "10.xx.xx.xx"
nutanix_port = 9440

#replace this values as per the setup
permission_ext_id = "<ext-id>"
17 changes: 17 additions & 0 deletions examples/authorization_policies_v2/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

#variable definations
variable "nutanix_username" {
type = string
}
variable "nutanix_password" {
type = string
}
variable "nutanix_endpoint" {
type = string
}
variable "nutanix_port" {
type = string
}
variable "permission_ext_id" {
type = string
}
40 changes: 40 additions & 0 deletions examples/directory_services_v2/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
terraform {
required_providers {
nutanix = {
source = "nutanix/nutanix"
version = "1.7.0"
}
}
}

#definig nutanix configuration
provider "nutanix" {
username = var.nutanix_username
password = var.nutanix_password
endpoint = var.nutanix_endpoint
port = 9440
insecure = true
}



# Add Directory Service .
resource "nutanix_directory_services_v2" "example" {
name = "<name of directory service>"
url = "<URL for the Directory Service>"
directory_type = "<Type of Directory Service.>"
domain_name = "<Domain name for the Directory Service.>"
service_account {
username = "<Username to connect to the Directory Service>"
password = "<Password to connect to the Directory Service>"
}
white_listed_groups = ["example"]
}

# List all Directory Services.
data "nutanix_directory_services_v2" "example" {}

# Get a Directory Service.
data "nutanix_directory_service_v2" "example" {
ext_id = "<Directory Service UUID>"
}
5 changes: 5 additions & 0 deletions examples/directory_services_v2/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#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
13 changes: 13 additions & 0 deletions examples/directory_services_v2/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#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
}
34 changes: 34 additions & 0 deletions examples/operations_v2/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#Here we will get and list permissions
#the variable "" present in terraform.tfvars file.
#Note - Replace appropriate values of variables in terraform.tfvars file as per setup

terraform {
required_providers {
nutanix = {
source = "nutanix/nutanix"
version = "1.3.0"
}
}
}

#definig nutanix configuration
provider "nutanix" {
username = var.nutanix_username
password = var.nutanix_password
endpoint = var.nutanix_endpoint
port = var.nutanix_port
insecure = true
}

#get permission by ext-id
data "nutanix_operation_v2" "permission" {
ext_id = var.permission_ext_id
}


#list permissions
data "nutanix_operations_v2" "permissions" {
page = 0
limit = 2
filter = "display_name eq 'test-Permission-filter'"
}
8 changes: 8 additions & 0 deletions examples/operations_v2/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#replace the values as per setup configuration
nutanix_username = "admin"
nutanix_password = "Nutanix/123456"
nutanix_endpoint = "10.xx.xx.xx"
nutanix_port = 9440

#replace this values as per the setup
permission_ext_id = "<ext-id>"
17 changes: 17 additions & 0 deletions examples/operations_v2/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

#variable definations
variable "nutanix_username" {
type = string
}
variable "nutanix_password" {
type = string
}
variable "nutanix_endpoint" {
type = string
}
variable "nutanix_port" {
type = string
}
variable "permission_ext_id" {
type = string
}
24 changes: 24 additions & 0 deletions examples/roles_v2/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
provider "nutanix" {
username = var.user
password = var.password
endpoint = var.endpoint
insecure = var.insecure
port = var.port
wait_timeout = 60
}

# Create role
resource "nutanix_roles_v2" "test" {
display_name = "test_role"
description = "creat a test role using terraform"
operations = var.operations
}

# list Roles
data "nutanix_roles_v2" "test"{}

# get a specific role by id
data "nutanix_role_v2" "test" {
ext_id = resource.nutanix_roles_v2.test.id
}

26 changes: 26 additions & 0 deletions examples/roles_v2/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
variable "user" {
type = string
}
variable "password" {
type = string
}
variable "endpoint" {
type = string
}
variable "insecure" {
type = bool
}
variable "port" {
type = number
}

variable "operations" {
type = list(string)
default = [
"operation_1_ext_id",
"operation_2_ext_id",
"operation_3_ext_id",
]
}


45 changes: 45 additions & 0 deletions examples/saml_idp_v2/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#Here we will get and list permissions
#the variable "" present in terraform.tfvars file.
#Note - Replace appropriate values of variables in terraform.tfvars file as per setup

terraform {
required_providers {
nutanix = {
source = "nutanix/nutanix"
version = "1.3.0"
}
}
}

#definig nutanix configuration
provider "nutanix" {
username = var.nutanix_username
password = var.nutanix_password
endpoint = var.nutanix_endpoint
port = var.nutanix_port
insecure = true
}

resource "nutanix_saml_identity_providers_v2" "example" {
name = "<IDENTITY_PROVIDER_NAME>"
username_attribute = "<IDENTITY_PROVIDER_USERNAME>"
email_attribute = "<IDENTITY_PROVIDER_EMAIL>"
groups_attribute = "<IDENTITY_PROVIDER_GROUPS>"
groups_delim = "<IDENTITY_PROVIDER_GROUPS_DELIM>" # such as ',' or ';'
idp_metadata_xml = "<IDENTITY_PROVIDER_METADATA_XML>"
entity_issuer = "<IDENTITY_PROVIDER_ENTITY_ISSUER>"
is_signed_authn_req_enabled = "<IDENTITY_PROVIDER_IS_SIGNED_AUTHN_REQ_ENABLED>"
custom_attributes = "<IDENTITY_PROVIDER_CUSTOM_ATTRIBUTES>"
}

#get saml identity provider by external id
data "nutanix_operation_v2" "permission" {
ext_id = nutanix_saml_identity_providers_v2.example.id
}


#list permissions
data "nutanix_operations_v2" "permissions" {
page = 0
limit = 2
}
8 changes: 8 additions & 0 deletions examples/saml_idp_v2/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#replace the values as per setup configuration
nutanix_username = "admin"
nutanix_password = "Nutanix/123456"
nutanix_endpoint = "10.xx.xx.xx"
nutanix_port = 9440

#replace this values as per the setup
permission_ext_id = "<ext-id>"
17 changes: 17 additions & 0 deletions examples/saml_idp_v2/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

#variable definations
variable "nutanix_username" {
type = string
}
variable "nutanix_password" {
type = string
}
variable "nutanix_endpoint" {
type = string
}
variable "nutanix_port" {
type = string
}
variable "permission_ext_id" {
type = string
}
36 changes: 36 additions & 0 deletions examples/user_groups_v2/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
terraform {
required_providers {
nutanix = {
source = "nutanix/nutanix"
version = "1.7.0"
}
}
}

#definig nutanix configuration
provider "nutanix" {
username = var.nutanix_username
password = var.nutanix_password
endpoint = var.nutanix_endpoint
port = 9440
insecure = true
}

# Add a User group to the system.

resource "nutanix_user_groups_v2" "example" {
# Type of the User Group. LDAP, SAML
group_type = "<group Type>"
idp_id = "<idp uuid of user group>"
name = "<group name>"
distinguished_name = "<distinguished name of the user group>"
}


# List all the user groups in the system.
data "nutanix_user_groups_v2" "example"{}

# Get the details of a user group.
data "nutanix_user_group_v2" "example" {
ext_id = nutanix_user_groups_v2.example.id
}
5 changes: 5 additions & 0 deletions examples/user_groups_v2/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#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
13 changes: 13 additions & 0 deletions examples/user_groups_v2/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#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
}
Loading

0 comments on commit 81820b5

Please sign in to comment.