1+ // Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+ // Licensed under the Mozilla Public License v2.0
3+ variable "subnet_ocid" {
4+ }
5+
6+ variable "image_ocid" {
7+ }
8+
9+ variable "config_file_profile" {
10+ }
11+
12+ # provider "oci" {
13+ # region = var.region
14+ # auth = "SecurityToken"
15+ # config_file_profile = var.config_file_profile
16+ # version = "7.18.0"
17+ # }
18+
19+ data "oci_identity_availability_domain" "ad" {
20+ compartment_id = var. tenancy_ocid
21+ ad_number = 1
22+ }
23+
24+ resource "oci_core_instance_configuration" "test_instance_configuration_with_aie" {
25+ compartment_id = var. compartment_ocid
26+ display_name = " TestInstanceConfiguration"
27+
28+ instance_details {
29+ instance_type = " compute"
30+
31+ launch_details {
32+ compartment_id = var. compartment_ocid
33+ shape = " BM.GPU.A10.4"
34+ is_ai_enterprise_enabled = true
35+
36+ source_details {
37+ source_type = " image"
38+ image_id = var. image_ocid
39+ }
40+
41+ instance_options {
42+ are_legacy_imds_endpoints_disabled = true
43+ }
44+
45+ create_vnic_details {
46+ subnet_id = var. subnet_ocid
47+ display_name = " Primaryvnic"
48+ }
49+ }
50+ }
51+ }
52+
53+ resource "oci_core_instance_pool" "test_instance_pool_with_aie" {
54+ compartment_id = var. compartment_ocid
55+ instance_configuration_id = oci_core_instance_configuration. test_instance_configuration_with_aie . id
56+ size = 1
57+ state = " RUNNING"
58+ display_name = " TestInstancePool"
59+
60+ placement_configurations {
61+ availability_domain = data. oci_identity_availability_domain . ad . name
62+ primary_subnet_id = var. subnet_ocid
63+ }
64+ }
65+
66+ resource "oci_core_instance" "test_instance_with_aie" {
67+ availability_domain = data. oci_identity_availability_domain . ad . name
68+ compartment_id = var. compartment_ocid
69+ display_name = " TestInstance"
70+ shape = " BM.GPU.A10.4"
71+ is_ai_enterprise_enabled = true
72+
73+ create_vnic_details {
74+ subnet_id = var. subnet_ocid
75+ display_name = " Primaryvnic"
76+ }
77+
78+ source_details {
79+ source_type = " image"
80+ source_id = var. image_ocid
81+ }
82+
83+ instance_options {
84+ are_legacy_imds_endpoints_disabled = true
85+ }
86+
87+ timeouts {
88+ create = " 60m"
89+ }
90+ }
91+
92+ output "aie_instance_config_data" {
93+ value = oci_core_instance_configuration. test_instance_configuration_with_aie
94+ }
95+
96+ data "oci_core_instance_pool_instances" "aie_instance_pool_instance" {
97+ compartment_id = var. compartment_ocid
98+ instance_pool_id = oci_core_instance_pool. test_instance_pool_with_aie . id
99+ }
100+
101+ data "oci_core_instance" "aie_instance_pool_instance_data" {
102+ instance_id = data. oci_core_instance_pool_instances . aie_instance_pool_instance . instances [0 ]. id
103+ }
104+
105+ data "oci_core_instances" "aie_instance_data" {
106+ compartment_id = var. compartment_ocid
107+ filter {
108+ name = " id"
109+ values = [oci_core_instance . test_instance_with_aie . id ]
110+ }
111+ }
112+
113+ output "aie_instance_pool_instance_data" {
114+ value = data. oci_core_instance . aie_instance_pool_instance_data
115+ }
116+
117+ output "aie_instance_data" {
118+ value = data. oci_core_instances . aie_instance_data
119+ }
0 commit comments