1+ provider "oci" {
2+ }
3+
4+ variable "tenancy_ocid" {
5+ default = " "
6+ }
7+
8+ variable "ssh_public_key" {
9+ default = " ssh-rsa KKKLK3NzaC1yc2EAAAADAQABAAABAQC+UC9MFNA55NIVtKPIBCNw7++ACXhD0hx+Zyj25JfHykjz/QU3Q5FAU3DxDbVXyubgXfb/GJnrKRY8O4QDdvnZZRvQFFEOaApThAmCAM5MuFUIHdFvlqP+0W+ZQnmtDhwVe2NCfcmOrMuaPEgOKO3DOW6I/qOOdO691Xe2S9NgT9HhN0ZfFtEODVgvYulgXuCCXsJs+NUqcHAOxxFUmwkbPvYi0P0e2DT8JKeiOOC8VKUEgvVx+GKmqasm+Y6zHFW7vv3g2GstE1aRs3mttHRoC/JPM86PRyIxeWXEMzyG5wHqUu4XZpDbnWNxi6ugxnAGiL3CrIFdCgRNgHz5qS1l MustWin"
10+ }
11+
12+ variable "region" {
13+ default = " "
14+ }
15+
16+ variable "compartment_ocid" {
17+ default = " "
18+ }
19+
20+ variable "defined_tag_namespace_name" {
21+ default = " "
22+ }
23+
24+ resource "oci_core_network_security_group" "test_network_security_group" {
25+ compartment_id = var. compartment_ocid
26+ vcn_id = oci_core_vcn. test_vcn . id
27+ lifecycle {
28+ ignore_changes = [
29+ " defined_tags" ]
30+ }
31+ }
32+
33+ resource "oci_core_vcn" "test_vcn" {
34+ cidr_block = " 10.0.0.0/16"
35+ compartment_id = var. compartment_ocid
36+ dns_label = " testvcn"
37+ lifecycle {
38+ ignore_changes = [
39+ " defined_tags" ]
40+ }
41+ }
42+
43+ resource "oci_core_subnet" "test_subnet" {
44+ cidr_block = " 10.0.0.0/24"
45+ compartment_id = var. compartment_ocid
46+ dns_label = " testsubnet"
47+ route_table_id = oci_core_route_table. test_route_table . id
48+ security_list_ids = [
49+ " ${ oci_core_security_list . test_sec_list . id } " ]
50+ vcn_id = oci_core_vcn. test_vcn . id
51+ lifecycle {
52+ ignore_changes = [
53+ " defined_tags" ]
54+ }
55+ }
56+
57+ resource "oci_core_security_list" "test_sec_list" {
58+ compartment_id = var. compartment_ocid
59+ vcn_id = oci_core_vcn. test_vcn . id
60+ egress_security_rules {
61+ destination = " 0.0.0.0/0"
62+ protocol = " all"
63+ stateless = " false"
64+ }
65+
66+ ingress_security_rules {
67+ protocol = " 6"
68+ source = " 0.0.0.0/0"
69+ stateless = " false"
70+ tcp_options {
71+ max = " 22"
72+ min = " 22"
73+ }
74+ }
75+
76+ ingress_security_rules {
77+ protocol = " 6"
78+ source = " 0.0.0.0/0"
79+ stateless = " false"
80+ tcp_options {
81+ max = " 80"
82+ min = " 80"
83+ }
84+ }
85+
86+ ingress_security_rules {
87+ protocol = " 1"
88+ source = " 0.0.0.0/0"
89+ stateless = " true"
90+ icmp_options {
91+ code = " 4"
92+ type = " 3"
93+ }
94+ }
95+
96+ ingress_security_rules {
97+ protocol = " 1"
98+ source = " 10.0.0.0/16"
99+ stateless = " false"
100+ }
101+ }
102+
103+ resource "oci_core_internet_gateway" "test_ig" {
104+ compartment_id = var. compartment_ocid
105+ vcn_id = oci_core_vcn. test_vcn . id
106+ }
107+
108+ resource "oci_core_route_table" "test_route_table" {
109+ compartment_id = var. compartment_ocid
110+ vcn_id = oci_core_vcn. test_vcn . id
111+ route_rules {
112+ destination = " 0.0.0.0/0"
113+ network_entity_id = oci_core_internet_gateway. test_ig . id
114+ }
115+ }
116+
117+ data "oci_identity_availability_domains" "test_availability_domains" {
118+ compartment_id = var. tenancy_ocid
119+ }
120+
121+ resource "oci_identity_tag_namespace" "tag-namespace1" {
122+ # Required
123+ compartment_id = var. tenancy_ocid
124+ description = " example tag namespace"
125+ name = var. defined_tag_namespace_name != " " ? var. defined_tag_namespace_name : " example-tag-namespace-all"
126+
127+ is_retired = false
128+ }
129+
130+ resource "oci_identity_tag" "tag1" {
131+ # Required
132+ description = " example tag"
133+ name = " example-tag"
134+ tag_namespace_id = oci_identity_tag_namespace. tag-namespace1 . id
135+
136+ is_retired = false
137+ }
138+
139+ resource "oci_container_instances_container_instance" "test_container_instance" {
140+ # Required
141+ availability_domain = data. oci_identity_availability_domains . test_availability_domains . availability_domains . 2 . name
142+ compartment_id = var. compartment_ocid
143+ containers {
144+ # Required
145+ image_url = " busybox"
146+
147+ # Optional
148+ additional_capabilities = [
149+ " CAP_NET_ADMIN" ]
150+ arguments = [
151+ " -c" ,
152+ " sleep 24h" ]
153+ command = [
154+ " /bin/sh" ]
155+ defined_tags = map (" ${ oci_identity_tag_namespace . tag-namespace1 . name } .${ oci_identity_tag . tag1 . name } " , " value" )
156+ display_name = " displayName"
157+ environment_variables = {
158+ " environment" = " variable"
159+ }
160+ freeform_tags = {
161+ " tagName" = " tagValue"
162+ }
163+ health_checks {
164+ # Required
165+ health_check_type = " HTTP"
166+
167+ # Optional
168+ failure_action = " KILL"
169+ failure_threshold = " 10"
170+ headers {
171+
172+ # Optional
173+ name = " name"
174+ value = " value"
175+ }
176+ initial_delay_in_seconds = " 10"
177+ interval_in_seconds = " 10"
178+ name = " name"
179+ path = " path"
180+ port = " 10"
181+ success_threshold = " 1"
182+ timeout_in_seconds = " 10"
183+ }
184+ is_resource_principal_disabled = " false"
185+ resource_config {
186+
187+ # Optional
188+ memory_limit_in_gbs = " 1.0"
189+ vcpus_limit = " 1.0"
190+ }
191+ volume_mounts {
192+ # Required
193+ mount_path = " /mnt"
194+ volume_name = " volumeName"
195+
196+ # Optional
197+ is_read_only = " false"
198+ partition = " 10"
199+ sub_path = " /subPath"
200+ }
201+ working_directory = " /mnt"
202+ }
203+ shape = " CI.Standard.E4.Flex"
204+ shape_config {
205+ memory_in_gbs = " 8"
206+ ocpus = " 4"
207+ }
208+ vnics {
209+ # Required
210+ subnet_id = oci_core_subnet. test_subnet . id
211+
212+ # Optional
213+ defined_tags = map (" ${ oci_identity_tag_namespace . tag-namespace1 . name } .${ oci_identity_tag . tag1 . name } " , " value" )
214+ display_name = " displayName"
215+ freeform_tags = {
216+ " freeformTag" = " freeformTags"
217+ }
218+ hostname_label = " hostnamelabel"
219+ is_public_ip_assigned = " true"
220+ nsg_ids = []
221+ private_ip = " 10.0.0.7"
222+ skip_source_dest_check = " false"
223+ }
224+
225+ # Optional
226+ container_restart_policy = " ALWAYS"
227+ defined_tags = map (" ${ oci_identity_tag_namespace . tag-namespace1 . name } .${ oci_identity_tag . tag1 . name } " , " value" )
228+ display_name = " displayName"
229+ dns_config {
230+
231+ # Optional
232+ nameservers = [
233+ " 8.8.8.8" ]
234+ options = [
235+ " options" ]
236+ searches = [
237+ " search domain" ]
238+ }
239+ fault_domain = " fault-domain-1"
240+ freeform_tags = {
241+ " bar-key" = " foo-value"
242+ }
243+ graceful_shutdown_timeout_in_seconds = " 10"
244+ lifecycle {
245+ ignore_changes = [
246+ " defined_tags" ]
247+ }
248+ state = " ACTIVE"
249+ volumes {
250+ # Required
251+ name = " volumeName"
252+ volume_type = " EMPTYDIR"
253+
254+ # Optional
255+ backing_store = " EPHEMERAL_STORAGE"
256+ }
257+ }
0 commit comments