Skip to content

Commit 9bba6c3

Browse files
Marcel CasadojiaqchenO
authored andcommitted
Added - Support for Create Terraform provider for Secure Desktops Desktop as a Service
1 parent 0dac637 commit 9bba6c3

33 files changed

+4492
-0
lines changed

examples/desktops/description.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Overview
2+
3+
This is a Terraform configuration that creates the secure DesktopPool resources on Oracle Cloud Infrastructure.
4+
5+
The Terraform code is used to create a Resource Manager stack, that creates the required resources and configures the application on the created resources.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
5+
resource "oci_desktops_desktop_pool" "test_desktop_pool" {
6+
#Required
7+
compartment_id = var.compartment_id
8+
display_name = var.desktop_pool_display_name
9+
contact_details = var.desktop_pool_contact_details
10+
11+
are_privileged_users = var.desktop_pool_are_privileged_users
12+
availability_domain = data.oci_identity_availability_domain.ad.name
13+
14+
network_configuration {
15+
#Required
16+
subnet_id = var.desktop_pool_subnet_id
17+
vcn_id = var.desktop_pool_vcn_id
18+
}
19+
20+
device_policy {
21+
#Required
22+
audio_mode = var.desktop_pool_device_policy_audio_mode
23+
cdm_mode = var.desktop_pool_device_policy_cdm_mode
24+
clipboard_mode = var.desktop_pool_device_policy_clipboard_mode
25+
is_display_enabled = var.desktop_pool_device_policy_is_display_enabled
26+
is_keyboard_enabled = var.desktop_pool_device_policy_is_keyboard_enabled
27+
is_pointer_enabled = var.desktop_pool_device_policy_is_pointer_enabled
28+
is_printing_enabled = var.desktop_pool_device_policy_is_printing_enabled
29+
}
30+
31+
image {
32+
#Required
33+
image_id = var.desktop_pool_image_id
34+
image_name = var.desktop_pool_image_name
35+
}
36+
37+
availability_policy {
38+
#Required
39+
start_schedule {
40+
#Required
41+
cron_expression = var.desktop_pool_start_schedule_cron_expr
42+
timezone = var.desktop_pool_start_schedule_timezone
43+
}
44+
stop_schedule {
45+
#Required
46+
cron_expression = var.desktop_pool_stop_schedule_cron_expr
47+
timezone = var.desktop_pool_stop_schedule_timezone
48+
}
49+
}
50+
51+
is_storage_enabled = var.desktop_pool_is_storage_enabled
52+
storage_backup_policy_id = var.desktop_pool_backup_policy_id
53+
storage_size_in_gbs = var.desktop_pool_storage_size_in_gbs
54+
55+
shape_name = var.desktop_pool_shape_name
56+
standby_size = var.desktop_pool_standby_size
57+
maximum_size = var.desktop_pool_maximum_size
58+
59+
#Optional
60+
# defined_tags = map(oci_identity_tag_namespace.tag-namespace1.name.oci_identity_tag.tag1.name, var.desktop_pool_defined_tags_value)
61+
# description = var.desktop_pool_description
62+
# freeform_tags = var.desktop_pool_freeform_tags
63+
# nsg_ids = var.desktop_pool_nsg_ids
64+
# time_start_scheduled = var.desktop_pool_time_start_scheduled
65+
# time_stop_scheduled = var.desktop_pool_time_stop_scheduled
66+
}
67+
68+
data "oci_desktops_desktop_pools" "test_desktop_pools_datasource" {
69+
#Required
70+
compartment_id = var.compartment_id
71+
72+
#Optional
73+
# availability_domain = data.oci_identity_availability_domain.ad.name
74+
# display_name = var.desktop_pool_display_name
75+
# id = var.desktop_pool_id
76+
# state = var.desktop_pool_state
77+
}
78+
79+
data "oci_desktops_desktop_pool" "test_desktop_pool_datasource" {
80+
#Required
81+
desktop_pool_id = oci_desktops_desktop_pool.test_desktop_pool.id
82+
}
83+
84+
data "oci_desktops_desktop_pool_desktops" "test_desktop_pool_desktops_datasource" {
85+
availability_domain = data.oci_identity_availability_domain.ad.name
86+
compartment_id = var.compartment_id
87+
desktop_pool_id = oci_desktops_desktop_pool.test_desktop_pool.id
88+
}
89+
90+
data "oci_desktops_desktop_pool_volumes" "test_desktop_pool_volumes_datasource" {
91+
availability_domain = data.oci_identity_availability_domain.ad.name
92+
compartment_id = var.compartment_id
93+
desktop_pool_id = oci_desktops_desktop_pool.test_desktop_pool.id
94+
#Optional
95+
# display_name = var.desktop_pool_display_name
96+
# state = var.desktop_pool_state
97+
}
98+
99+
data "oci_identity_availability_domain" "ad" {
100+
compartment_id = var.tenancy_ocid
101+
ad_number = 1
102+
}
103+
104+
data "oci_desktops_desktops" "test_desktops_datasource" {
105+
availability_domain = data.oci_identity_availability_domain.ad.name
106+
compartment_id = var.compartment_id
107+
desktop_pool_id = oci_desktops_desktop_pool.test_desktop_pool.id
108+
state = "ACTIVE"
109+
}
110+
111+
data "oci_desktops_desktop" "test_desktop_datasource" {
112+
desktop_id = data.oci_desktops_desktop_pool_desktops.test_desktop_pool_desktops_datasource.desktop_pool_desktop_collection.0.items.0.desktop_id
113+
}
114+
115+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# OCI config profile
2+
config_file_profile="terraform-federation-test"
3+
4+
# region (us-phoenix-1, ca-toronto-1, etc)
5+
region="us-phoenix-1"
6+
7+
# Secure Desktops Example Configuration
8+
9+
compartment_id = "<compartment_ocid>"
10+
11+
desktop_pool_vcn_id = "<vcn_ocid>"
12+
desktop_pool_subnet_id = "<subnet_ocid>"
13+
desktop_pool_image_id = "<image_ocid>"
14+
desktop_pool_image_name = "<image_name"
15+
desktop_pool_backup_policy_id = "<volume_backup_policy_ocid>"
16+
desktop_pool_contact_details = "test%40test.com"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
5+
output "desktop_pool_id" {
6+
value = [data.oci_desktops_desktop_pools.test_desktop_pools_datasource.desktop_pool_collection.0.items.*.id]
7+
}
8+
9+
# Output the desktop IDs of the desktop pool
10+
output "desktop_pool_desktop_ids" {
11+
value = [data.oci_desktops_desktop_pool_desktops.test_desktop_pool_desktops_datasource.desktop_pool_desktop_collection.0.items.*.desktop_id]
12+
}
13+
14+
# Output the volume IDs of the desktop pool
15+
output "desktop_pool_volume_ids" {
16+
value = [data.oci_desktops_desktop_pool_volumes.test_desktop_pool_volumes_datasource.desktop_pool_volume_collection.0.items.*.id]
17+
}
18+
19+
# Output the desktop IDs of the desktop pool
20+
output "desktop_ids" {
21+
value = [data.oci_desktops_desktops.test_desktops_datasource.desktop_collection.0.items.*.id]
22+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
#provider "oci" {
5+
# tenancy_ocid = var.tenancy_ocid
6+
# user_ocid = var.user_ocid
7+
# fingerprint = var.fingerprint
8+
# private_key_path = var.private_key_path
9+
# region = var.region
10+
#}
11+
12+
variable "config_file_profile" {
13+
}
14+
15+
provider "oci" {
16+
auth = "SecurityToken"
17+
config_file_profile = var.config_file_profile
18+
region = var.region
19+
}
20+
21+
provider "local" {
22+
version = ">=1.3.0" # Need this version of the local provider to support base64 encoded inputs
23+
}
24+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# GETTING STARTED
2+
#
3+
# 1. Download and install TerraForm (https://www.terraform.io/downloads.html)
4+
# 2. Download and install the OCI TerraForm provider (https://github.com/oracle/terraform-provider-oci/)
5+
# 3. Make sure that you have an OCI API key setup
6+
# See https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/apisigningkey.htm for directions on creating an API signing key
7+
# See https://docs.us-phoenix-1.oraclecloud.com/Content/Identity/Tasks/managingcredentials.htm on how to manage API keys in the OCI UI or API
8+
# 4. Copy your tenancy OCID below (bottom part of OCI screen, after Tenancy OCID: heading)
9+
# 5. Copy your OCI user account OCID (login to OCI > Identity > Users)
10+
# 6. Copy the required API key fingerprint and private key path (below)
11+
# 7. Fill-in the full path to the SSH public and private keys (this can be used when creating new instances)
12+
# See https://docs.us-phoenix-1.oraclecloud.com/Content/GSG/Tasks/creatingkeys.htm for directions on how to create this key pair
13+
#
14+
# HELPFUL URLs
15+
# * https://github.com/oracle/terraform-provider-oci/blob/master/docs/Table%20of%20Contents.md
16+
#
17+
18+
# RUNNING TerraForm
19+
#
20+
# Once you've gone through the steps mentioned above, you need to populate your environment variables, by sourcing this file... steps are below:
21+
# 1. Modify this file (so it reflects your OCIDs, etc.)
22+
# 2. $ terraform init
23+
# You only have to do this once after installing or upgrading your TerraForm plugins
24+
# 3. $ terraform plan
25+
# This will show you what TerraForm might do if you applied it
26+
# 4. $ terraform apply
27+
28+
# Get this from the bottom of the OCI screen (after logging in, after Tenancy ID: heading)
29+
#tenancy_ocid="<tenancy OCID"
30+
# Get this from OCI > Identity > Users (for your user account)
31+
#user_ocid="<user OCID>"
32+
33+
# the fingerprint can be gathered from your user account (OCI > Identity > Users > click your username > API Keys fingerprint (select it, copy it and paste it below))
34+
#fingerprint="<PEM key fingerprint>"
35+
# this is the full path on your local system to the private key used for the API key pair
36+
private_key_path="<path to the private key that matches the fingerprint above>"
37+
38+
# OCI config profile
39+
config_file_profile="terraform-federation-test"
40+
41+
# region (us-phoenix-1, ca-toronto-1, etc)
42+
region="<your region>"
43+
44+
# To be able to use OCI Secure Desktops it requires to have some customer OCI resources ready in the customer tenancy like a VCN, Subnet and a custom Image.
45+
# Additionally a Dynamic Group, service policies and user policies are required.
46+
# See setting up the Tenancy: https://docs.oracle.com/en-us/iaas/secure-desktops/setup-tenancy.htm for guidance.
47+
# Oracle recommends using the OCI Secure Desktops Resource Manager (ORM) Stack to simplify the process of setting up the tenancy.
48+
# The ORM stack <volume_backup_policy_ocid>assists with several process tasks to help ensure the tenancy is set up according to best practices.
49+
# See https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=228601342054219&id=2948207.1&_afrWindowMode=0&_adf.ctrl-state=5q6cqoqnz_4 on "How To Configure Tenancy Using ORM Stack"
50+
51+
52+
# Secure Desktops Example Configuration
53+
#
54+
55+
compartment_id = "<compartment_ocid>"
56+
57+
desktop_pool_vcn_id = "<vcn_ocid>"
58+
desktop_pool_subnet_id = "<subnet_ocid>"
59+
desktop_pool_image_id = "<image_ocid>"
60+
desktop_pool_image_name = "<image_name>"
61+
desktop_pool_backup_policy_id = "<volume_backup_policy_ocid>"
62+
desktop_pool_contact_details = "<admin_contact_details>"
63+

0 commit comments

Comments
 (0)