# 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: true,
assign_public_ip: true,
assign_private_dns_record: false,
defined_tags: {
'EXAMPLE_KEY_d7qSe' => { 'EXAMPLE_KEY_UwHFL' => 'EXAMPLE--Value' }
},
display_name: 'EXAMPLE-displayName-Value',
freeform_tags: {
'EXAMPLE_KEY_pltCT' => 'EXAMPLE_VALUE_8WY49bidM42zHrAznDAx'
},
hostname_label: 'EXAMPLE-hostnameLabel-Value',
ipv6_address_ipv6_subnet_cidr_pair_details: [
OCI::Core::Models::Ipv6AddressIpv6SubnetCidrPairDetails.new(
ipv6_subnet_cidr: 'EXAMPLE-ipv6SubnetCidr-Value',
ipv6_address: 'EXAMPLE-ipv6Address-Value'
)
],
nsg_ids: %w[EXAMPLE--Value],
private_ip: 'EXAMPLE-privateIp-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_XtJro' => { 'EXAMPLE_KEY_jibuR' => 'EXAMPLE--Value' }
},
display_name: 'EXAMPLE-displayName-Value',
extended_metadata: { 'EXAMPLE_KEY_u88Nz' => 'EXAMPLE--Value' },
fault_domain: 'EXAMPLE-faultDomain-Value',
cluster_placement_group_id:
'ocid1.test.oc1..<unique_ID>EXAMPLE-clusterPlacementGroupId-Value',
freeform_tags: {
'EXAMPLE_KEY_39FwN' => 'EXAMPLE_VALUE_s5Ght81OAB1JjaPHIn83'
},
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: 'ISCSI',
firmware: 'UEFI_64',
network_type: 'PARAVIRTUALIZED',
remote_data_volume_type: 'IDE',
is_pv_encryption_in_transit_enabled: true,
is_consistent_volume_naming_enabled: true
),
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: 'STOP_INSTANCE'
),
preemptible_instance_config:
OCI::Core::Models::PreemptibleInstanceConfigDetails.new(
preemption_action:
OCI::Core::Models::TerminatePreemptionAction.new(
type: 'TERMINATE', preserve_boot_volume: false
)
),
metadata: { 'EXAMPLE_KEY_JhWbU' => 'EXAMPLE_VALUE_q2CgMvKzKZHef6ax54Bx' },
agent_config:
OCI::Core::Models::LaunchInstanceAgentConfigDetails.new(
is_monitoring_disabled: true,
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: 1770.9791,
vcpus: 250,
memory_in_gbs: 3181.5088,
baseline_ocpu_utilization: 'BASELINE_1_1',
nvmes: 2
),
source_details:
OCI::Core::Models::InstanceSourceViaBootVolumeDetails.new(
source_type: 'bootVolume',
boot_volume_id:
'ocid1.test.oc1..<unique_ID>EXAMPLE-bootVolumeId-Value'
),
subnet_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value',
launch_volume_attachments: [
OCI::Core::Models::LaunchAttachIScsiVolumeDetails.new(
type: 'iscsi',
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: 120,
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: 725
),
use_chap: true,
encryption_in_transit_type: 'BM_ENCRYPTION_IN_TRANSIT',
is_agent_auto_iscsi_login_enabled: false
)
],
is_pv_encryption_in_transit_enabled: true,
platform_config:
OCI::Core::Models::AmdMilanBmLaunchInstancePlatformConfig.new(
type: 'AMD_MILAN_BM',
is_secure_boot_enabled: true,
is_trusted_platform_module_enabled: false,
is_measured_boot_enabled: false,
is_memory_encryption_enabled: true,
numa_nodes_per_socket: 'NPS4',
is_symmetric_multi_threading_enabled: false,
is_access_control_service_enabled: true,
are_virtual_instructions_enabled: true,
is_input_output_memory_management_unit_enabled: true,
percentage_of_cores_enabled: 93,
config_map: {
'EXAMPLE_KEY_KV0BF' => 'EXAMPLE_VALUE_A8Fl5rUazAEpzxHGusgV'
}
),
instance_configuration_id:
'ocid1.test.oc1..<unique_ID>EXAMPLE-instanceConfigurationId-Value'
)
)
# Get the data from response
puts "#{launch_instance_response.data}"