Skip to content

AD Computers with Terraform»

Terraform KopiCloud_AD_API

Manage AD Computers in Microsoft Active Directory using the KopiCloud AD API Terraform Provider


Resources»

Register (Create) AD Computer»

Use the optional ou_path parameter to store the computer inside a specific OU, if not it will be stored in the Computers OU.

Create New Computer:

1
2
3
4
5
resource "kopicloud_computer" "test" {
  ad_computer_name = "KOPISSRV1"
  description      = "Test Server"
  ou_path          = "OU=kopicloud-europe,DC=kopicloud,DC=local"    
}

Return Created Computer:

1
2
3
4
output "OUTPUT_new_computer" {
  description = "Created Computer"
  value       = resource.kopicloud_computer.test
}

Schema

Required:

  • ad_computer_name (String) Computer Name

Optional:

  • description (String) Computer Description
  • ou_path (String) OU Path (Distinguished Name)

Read-Only:

  • id (String) The ID of this Resource
  • result (List of Objects) Single AD Computer (see below for nested schema)

Update AD Computer Description»

Update a Computer:

1
2
3
4
5
resource "kopicloud_computer" "test" {
  ad_computer_name = "KOPISRV1"
  description      = "DevOps Server"
  ou_path          = "OU=kopicloud-europe,DC=kopicloud,DC=local"    
}

Return Updated Computer:

1
2
3
4
output "OUTPUT_new_computer" {
  description = "Created Computer"
  value       = resource.kopicloud_computer.test
}

Schema

Required:

  • ad_computer_name (String) Computer Name

Optional:

  • description (String) Computer Description
  • ou_path (String) OU Path (Distinguished Name)

Read-Only:

  • id (String) The ID of this Resource
  • result (List of Objects) Single AD Computer (see below for nested schema)

Data Sources»

List of All AD Computers»

List All Computers:

1
data "kopicloud_computer_list" "test_all" {}

Returns All Computers:

1
2
3
4
output "OUTPUT_all_computers_list" {
  description = "List ALL Existing Computers"
  value       = data.kopicloud_computer_list.test_all
}

Schema

Optional:

  • ou_path (String) AD OU Path (Distinguished Name)

Read-Only:

  • id (String) The ID of this Resource
  • result (List of Objects) List of AD Computers (see below for nested schema)

List of All AD Computers Inside an AD OU»

List All Computers Inside an OU:

1
2
3
data "kopicloud_computer_list" "test" {
  ou_path = "OU=Domain Controllers,DC=kopicloud,DC=local"
}

Returns All Computers Inside an OU:

1
2
3
4
output "OUTPUT_all_computers_list_inside_ou" {
  description = "All Existing Computers Inside an OU"
  value       = data.kopicloud_computer_list.test
}

Schema

Optional:

  • ou_path (String) AD OU Path (Distinguished Name)

Read-Only:

  • id (String) The ID of this Resource
  • result (List of Objects) List of AD Computers (see below for nested schema)

Nested Schema for Result»

Read-Only:

  • computer_name (String) AD Computer Name
  • created (String) Creation Date
  • description (String) Computer Description
  • dns_name (String) DNS Name
  • operating_system (String) Operating System
  • path (String) AD OU Path (Distinguished Name)
  • sid (String) Computer SID

Notes»

Running this resource with terraform apply will create or update an AD computer resource and running terraform destroy will remove this machine from Active Directory.


Source Code»

Source code available here