# This is an automatically generated code sample.
# To make this code sample work in your Oracle Cloud tenancy,
# please replace the values for any parameters whose current values do not fit
# your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
# boolean, number, and enum parameters with values not fitting your use case).
require 'oci'
# Create a default config using DEFAULT profile in default location
# Refer to https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File for more info
config = OCI::ConfigFileLoader.load_config
# Initialize service client with default config file
core_client = OCI::Core::ComputeClient.new(config: config)
# Send the request to service, some parameters are not required, see API doc for more info
launch_instance_response =
core_client.launch_instance(
OCI::Core::Models::LaunchInstanceDetails.new(
availability_domain: 'EXAMPLE-availabilityDomain-Value',
compartment_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
capacity_reservation_id:
'ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value',
create_vnic_details:
OCI::Core::Models::CreateVnicDetails.new(
assign_ipv6_ip: false,
assign_public_ip: true,
assign_private_dns_record: true,
defined_tags: {
'EXAMPLE_KEY_zbHHK' => { 'EXAMPLE_KEY_F75dw' => 'EXAMPLE--Value' }
},
display_name: 'EXAMPLE-displayName-Value',
freeform_tags: {
'EXAMPLE_KEY_cvMOj' => 'EXAMPLE_VALUE_LBtDodDO6eBZlTZ6IQRi'
},
security_attributes: {
'EXAMPLE_KEY_qVFmu' => { 'EXAMPLE_KEY_JgZ2P' => 'EXAMPLE--Value' }
},
hostname_label: 'EXAMPLE-hostnameLabel-Value',
ipv6_address_ipv6_subnet_cidr_pair_details: [
OCI::Core::Models::Ipv6AddressIpv6SubnetCidrPairDetails.new(
ipv6_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-ipv6Id-Value',
ipv6_subnet_cidr: 'EXAMPLE-ipv6SubnetCidr-Value',
ipv6_address: 'EXAMPLE-ipv6Address-Value'
)
],
subnet_cidr: 'EXAMPLE-subnetCidr-Value',
nsg_ids: %w[EXAMPLE--Value],
private_ip: 'EXAMPLE-privateIp-Value',
private_ip_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-privateIpId-Value',
skip_source_dest_check: true,
subnet_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value',
vlan_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-vlanId-Value'
),
dedicated_vm_host_id:
'ocid1.test.oc1..<unique_ID>EXAMPLE-dedicatedVmHostId-Value',
defined_tags: {
'EXAMPLE_KEY_dKB0H' => { 'EXAMPLE_KEY_40BY8' => 'EXAMPLE--Value' }
},
security_attributes: {
'EXAMPLE_KEY_TxR2i' => { 'EXAMPLE_KEY_CLj6k' => 'EXAMPLE--Value' }
},
display_name: 'EXAMPLE-displayName-Value',
extended_metadata: { 'EXAMPLE_KEY_a1Jv7' => 'EXAMPLE--Value' },
fault_domain: 'EXAMPLE-faultDomain-Value',
cluster_placement_group_id:
'ocid1.test.oc1..<unique_ID>EXAMPLE-clusterPlacementGroupId-Value',
freeform_tags: {
'EXAMPLE_KEY_IGMP6' => 'EXAMPLE_VALUE_Ue4dkBhj3V252WaGPumC'
},
compute_cluster_id:
'ocid1.test.oc1..<unique_ID>EXAMPLE-computeClusterId-Value',
hostname_label: 'EXAMPLE-hostnameLabel-Value',
image_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-imageId-Value',
ipxe_script: 'EXAMPLE-ipxeScript-Value',
launch_options:
OCI::Core::Models::LaunchOptions.new(
boot_volume_type: 'VFIO',
firmware: 'UEFI_64',
network_type: 'PARAVIRTUALIZED',
remote_data_volume_type: 'ISCSI',
is_pv_encryption_in_transit_enabled: false,
is_consistent_volume_naming_enabled: false
),
instance_options:
OCI::Core::Models::InstanceOptions.new(
are_legacy_imds_endpoints_disabled: false
),
availability_config:
OCI::Core::Models::LaunchInstanceAvailabilityConfigDetails.new(
is_live_migration_preferred: false,
recovery_action: 'RESTORE_INSTANCE'
),
preemptible_instance_config:
OCI::Core::Models::PreemptibleInstanceConfigDetails.new(
preemption_action:
OCI::Core::Models::TerminatePreemptionAction.new(
type: 'TERMINATE', preserve_boot_volume: true
)
),
metadata: { 'EXAMPLE_KEY_UKSWi' => 'EXAMPLE_VALUE_wFWwKRWTfdzl77cZEyW8' },
agent_config:
OCI::Core::Models::LaunchInstanceAgentConfigDetails.new(
is_monitoring_disabled: false,
is_management_disabled: true,
are_all_plugins_disabled: false,
plugins_config: [
OCI::Core::Models::InstanceAgentPluginConfigDetails.new(
name: 'EXAMPLE-name-Value', desired_state: 'DISABLED'
)
]
),
shape: 'EXAMPLE-shape-Value',
shape_config:
OCI::Core::Models::LaunchInstanceShapeConfigDetails.new(
ocpus: 9218.056,
vcpus: 364,
memory_in_gbs: 8367.832,
baseline_ocpu_utilization: 'BASELINE_1_8',
nvmes: 3,
resource_management: 'STATIC',
local_volume_size_in_gbs: 22_245
),
source_details:
OCI::Core::Models::InstanceSourceViaImageDetails.new(
source_type: 'image',
boot_volume_size_in_gbs: 858,
image_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-imageId-Value',
kms_key_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value',
boot_volume_vpus_per_gb: 395,
instance_source_image_filter_details:
OCI::Core::Models::InstanceSourceImageFilterDetails.new(
compartment_id:
'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
defined_tags_filter: {
'EXAMPLE_KEY_KyVqt' => {
'EXAMPLE_KEY_EM0Er' => 'EXAMPLE--Value'
}
},
operating_system: 'EXAMPLE-operatingSystem-Value',
operating_system_version: 'EXAMPLE-operatingSystemVersion-Value'
)
),
subnet_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value',
launch_volume_attachments: [
OCI::Core::Models::LaunchAttachParavirtualizedVolumeDetails.new(
type: 'paravirtualized',
device: 'EXAMPLE-device-Value',
display_name: 'EXAMPLE-displayName-Value',
is_read_only: false,
is_shareable: false,
volume_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-volumeId-Value',
launch_create_volume_details:
OCI::Core::Models::LaunchCreateVolumeFromAttributes.new(
volume_creation_type: 'ATTRIBUTES',
size_in_gbs: 927,
compartment_id:
'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
display_name: 'EXAMPLE-displayName-Value',
kms_key_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value',
vpus_per_gb: 831
),
is_pv_encryption_in_transit_enabled: true
)
],
is_pv_encryption_in_transit_enabled: true,
platform_config:
OCI::Core::Models::IntelIcelakeBmLaunchInstancePlatformConfig.new(
type: 'INTEL_ICELAKE_BM',
is_secure_boot_enabled: false,
is_trusted_platform_module_enabled: true,
is_measured_boot_enabled: false,
is_memory_encryption_enabled: true,
numa_nodes_per_socket: 'NPS1',
is_symmetric_multi_threading_enabled: false,
is_input_output_memory_management_unit_enabled: false,
percentage_of_cores_enabled: 27,
config_map: {
'EXAMPLE_KEY_aeVhI' => 'EXAMPLE_VALUE_CryyqYb3aTufGl2UjjQs'
}
),
placement_constraint_details:
OCI::Core::Models::HostGroupPlacementConstraintDetails.new(
type: 'HOST_GROUP',
compute_host_group_id:
'ocid1.test.oc1..<unique_ID>EXAMPLE-computeHostGroupId-Value'
),
is_ai_enterprise_enabled: true,
instance_configuration_id:
'ocid1.test.oc1..<unique_ID>EXAMPLE-instanceConfigurationId-Value',
licensing_configs: [
OCI::Core::Models::LaunchInstanceWindowsLicensingConfig.new(
type: 'WINDOWS', license_type: 'OCI_PROVIDED'
)
]
)
)
# Get the data from response
puts "#{launch_instance_response.data}"