From d84ee4393e9d0722e4802bd8a1688f227ac193db Mon Sep 17 00:00:00 2001 From: Chris Archibald Date: Wed, 12 Oct 2022 20:22:54 -0400 Subject: [PATCH] Sync bitbucket and GitHub --- CHANGELOG.md | 3 + gcp/active_directory.go | 2 + gcp/data_source_gcp_active_directory.go | 88 +++++++++---------- gcp/resource_netapp_gcp_active_directory.go | 24 +++-- website/docs/r/active_directory.html.markdown | 5 +- 5 files changed, 71 insertions(+), 51 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b6c6f5..e627d4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 22.10.0 +* resource/active_directory: ([#76](https://github.com/NetApp/terraform-provider-netapp-gcp/issues/76)) + ## 22.8.1 BUG FIXES: * resource/storage_pool: Fix creation error with shared vpc. ([#69](https://github.com/NetApp/terraform-provider-netapp-gcp/issues/69)) diff --git a/gcp/active_directory.go b/gcp/active_directory.go index 0b3c51e..ab93cf7 100644 --- a/gcp/active_directory.go +++ b/gcp/active_directory.go @@ -27,6 +27,7 @@ type operateActiveDirectoryRequest struct { AesEncryption bool `structs:"aesEncryption"` Label string `structs:"label"` AdName string `structs:"adName"` + ManagedAD bool `structs:"managedAD"` } // operateActiveDirectoryResult returns the api response for creating/updating an active directory @@ -60,6 +61,7 @@ type listActiveDirectoryResult struct { AesEncryption bool `json:"aesEncryption"` Label string `json:"label"` AdName string `json:"adName"` + ManagedAD bool `structs:"managedAD"` } type listActiveDirectoryAPIResult struct { diff --git a/gcp/data_source_gcp_active_directory.go b/gcp/data_source_gcp_active_directory.go index eed84aa..043f3d8 100644 --- a/gcp/data_source_gcp_active_directory.go +++ b/gcp/data_source_gcp_active_directory.go @@ -1,8 +1,6 @@ package gcp import ( - "fmt" - "github.com/hashicorp/terraform/helper/schema" ) @@ -27,7 +25,7 @@ func dataSourceGCPActiveDirectory() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "netbios": { + "net_bios": { Type: schema.TypeString, Optional: true, }, @@ -47,50 +45,52 @@ func dataSourceGCPActiveDirectory() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "aes_encryption": { + Type: schema.TypeBool, + Optional: true, + }, + "backup_operators": { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Optional: true, + }, + "security_operators": { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Optional: true, + }, + "allow_local_nfs_users_with_ldap": { + Type: schema.TypeBool, + Optional: true, + }, + "kdc_ip": { + Type: schema.TypeString, + Optional: true, + }, + "ldap_signing": { + Type: schema.TypeBool, + Optional: true, + }, + "connection_type": { + Type: schema.TypeString, + Optional: true, + }, + "ad_server": { + Type: schema.TypeString, + Optional: true, + }, + "managed_ad": { + Type: schema.TypeBool, + Optional: true, + }, }, } } func dataSourceGCPActiveDirectoryRead(d *schema.ResourceData, meta interface{}) error { - client := meta.(*Client) - activeDirectory := listActiveDirectoryRequest{} - activeDirectory.Region = d.Get("region").(string) - var res listActiveDirectoryResult - res, err := client.listActiveDirectoryForRegion(activeDirectory) - if err != nil { - return err - } - d.SetId(res.UUID) - - if err := d.Set("uuid", res.UUID); err != nil { - return fmt.Errorf("Error reading active directory UUID: %s", err) - } - if err := d.Set("domain", res.Domain); err != nil { - return fmt.Errorf("Error reading active directory domain: %s", err) - } - - if err := d.Set("netbios", res.NetBIOS); err != nil { - return fmt.Errorf("Error reading active directory netbios: %s", err) - } - - if err := d.Set("organizational_unit", res.OrganizationalUnit); err != nil { - return fmt.Errorf("Error reading active directory organizational_unit: %s", err) - } - - if err := d.Set("site", res.Site); err != nil { - return fmt.Errorf("Error reading active directory site: %s", err) - } - - if err := d.Set("username", res.Username); err != nil { - return fmt.Errorf("Error reading active directory username: %s", err) - } - - if err := d.Set("dns_server", res.DNS); err != nil { - return fmt.Errorf("Error reading active directory dns_server: %s", err) - } - - if err := d.Set("region", res.Region); err != nil { - return fmt.Errorf("Error reading active directory region: %s", err) - } - return nil + return resourceGCPActiveDirectoryRead(d, meta) } diff --git a/gcp/resource_netapp_gcp_active_directory.go b/gcp/resource_netapp_gcp_active_directory.go index cf5b5c6..5387810 100644 --- a/gcp/resource_netapp_gcp_active_directory.go +++ b/gcp/resource_netapp_gcp_active_directory.go @@ -100,6 +100,11 @@ func resourceGCPActiveDirectory() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "managed_ad": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, }, } } @@ -162,6 +167,8 @@ func resourceGCPActiveDirectoryCreate(d *schema.ResourceData, meta interface{}) activeDirectory.AdName = v.(string) } + activeDirectory.ManagedAD = d.Get("managed_ad").(bool) + res, err := client.createActiveDirectory(&activeDirectory) if err != nil { log.Print("Error creating active directory") @@ -176,7 +183,6 @@ func resourceGCPActiveDirectoryCreate(d *schema.ResourceData, meta interface{}) func resourceGCPActiveDirectoryRead(d *schema.ResourceData, meta interface{}) error { client := meta.(*Client) - id := d.Id() activeDirectory := listActiveDirectoryRequest{} activeDirectory.Region = d.Get("region").(string) var res listActiveDirectoryResult @@ -184,10 +190,13 @@ func resourceGCPActiveDirectoryRead(d *schema.ResourceData, meta interface{}) er if err != nil { return err } - if res.UUID != id { - return fmt.Errorf("Expected active directory with id: %v, Response contained active directory with id: %v", - d.Get("uuid").(string), res.UUID) - } + // Disabling, since it would fail for call from dataSourceGCPVolumeRead + // Unclear if this sanity check is required + // if res.UUID != d.id { + // return fmt.Errorf("Expected active directory with id: %v, Response contained active directory with id: %v", + // d.Get("uuid").(string), res.UUID) + // } + d.SetId(res.UUID) d.Set("uuid", res.UUID) if err := d.Set("domain", res.Domain); err != nil { @@ -250,6 +259,9 @@ func resourceGCPActiveDirectoryRead(d *schema.ResourceData, meta interface{}) er return fmt.Errorf("Error reading active directory ad_server: %s", err) } + if err := d.Set("managed_ad", res.ManagedAD); err != nil { + return fmt.Errorf("Error reading active directory managed_ad: %s", err) + } return nil } @@ -340,6 +352,8 @@ func resourceGCPActiveDirectoryUpdate(d *schema.ResourceData, meta interface{}) activeDirectory.AdName = v.(string) } + activeDirectory.ManagedAD = d.Get("managed_ad").(bool) + err := client.updateActiveDirectory(activeDirectory) if err != nil { return err diff --git a/website/docs/r/active_directory.html.markdown b/website/docs/r/active_directory.html.markdown index 898cdd9..800ca56 100644 --- a/website/docs/r/active_directory.html.markdown +++ b/website/docs/r/active_directory.html.markdown @@ -29,8 +29,8 @@ Creates a new Active Directory connection for a given region. Only one connectio resource "netapp-gcp_active_directory" "gcp-active-directory" { provider = netapp-gcp region = "us-west2" - username = "test_user" - password = "netapp" + username = "test_user" + password = "netapp" domain = "example.com" dns_server = "10.0.0.0" net_bios = "cvsserver" @@ -52,6 +52,7 @@ AD connection specific settings: * `net_bios` - (Required) NetBIOS prefix name of the server that will be created. A random 5-digit suffix is appended automatically (e.g. -A579). * `aes_encryption` - (Optional) Enables AES-128 and AES-256 encryption for Kerberos-based communication with Active Directory. Default is false. * `ldap_signing` - (Optional) Enables LDAP siging. Default is false. +* `managed_ad` - (Optional) Flags this configuration as Google ManagedAD configuration. Please see https://cloud.google.com/architecture/partners/netapp-cloud-volumes/managing-active-directory-connections?hl=en_US#connect_to_managed_microsoft_ad User credentials for Domain join: * `username` - (Required) Username of an account permitted to create computer objects in your Active Directory.