# 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::ComputeManagementClient.new(config: config)

# Send the request to service, some parameters are not required, see API doc for more info
launch_instance_configuration_response =
  core_client.launch_instance_configuration(
    'ocid1.test.oc1..<unique_ID>EXAMPLE-instanceConfigurationId-Value',
    OCI::Core::Models::ComputeInstanceDetails.new(
      instance_type: 'compute',
      block_volumes: [
        OCI::Core::Models::InstanceConfigurationBlockVolumeDetails.new(
          attach_details:
            OCI::Core::Models::InstanceConfigurationParavirtualizedAttachVolumeDetails
              .new(
              type: 'paravirtualized',
              display_name: 'EXAMPLE-displayName-Value',
              is_read_only: true,
              device: 'EXAMPLE-device-Value',
              is_shareable: false,
              is_pv_encryption_in_transit_enabled: true
            ),
          create_details:
            OCI::Core::Models::InstanceConfigurationCreateVolumeDetails.new(
              availability_domain: 'EXAMPLE-availabilityDomain-Value',
              backup_policy_id:
                'ocid1.test.oc1..<unique_ID>EXAMPLE-backupPolicyId-Value',
              compartment_id:
                'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
              is_auto_tune_enabled: false,
              block_volume_replicas: [
                OCI::Core::Models::InstanceConfigurationBlockVolumeReplicaDetails
                  .new(
                  availability_domain: 'EXAMPLE-availabilityDomain-Value',
                  display_name: 'EXAMPLE-displayName-Value'
                )
              ],
              defined_tags: {
                'EXAMPLE_KEY_HBmUd' => {
                  'EXAMPLE_KEY_RGRWx' => 'EXAMPLE--Value'
                }
              },
              display_name: 'EXAMPLE-displayName-Value',
              freeform_tags: {
                'EXAMPLE_KEY_y69h0' => 'EXAMPLE_VALUE_bpsanCWWmXskS4mKsQMS'
              },
              kms_key_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value',
              vpus_per_gb: 171,
              cluster_placement_group_id:
                'ocid1.test.oc1..<unique_ID>EXAMPLE-clusterPlacementGroupId-Value',
              size_in_gbs: 726,
              source_details:
                OCI::Core::Models::InstanceConfigurationVolumeSourceFromVolumeBackupDetails
                  .new(
                  type: 'volumeBackup',
                  id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value'
                ),
              autotune_policies: [
                OCI::Core::Models::InstanceConfigurationDetachedVolumeAutotunePolicy
                  .new(autotune_type: 'DETACHED_VOLUME')
              ]
            ),
          volume_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-volumeId-Value'
        )
      ],
      launch_details:
        OCI::Core::Models::InstanceConfigurationLaunchInstanceDetails.new(
          availability_domain: 'EXAMPLE-availabilityDomain-Value',
          capacity_reservation_id:
            'ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value',
          compartment_id:
            'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
          cluster_placement_group_id:
            'ocid1.test.oc1..<unique_ID>EXAMPLE-clusterPlacementGroupId-Value',
          create_vnic_details:
            OCI::Core::Models::InstanceConfigurationCreateVnicDetails.new(
              assign_ipv6_ip: true,
              assign_public_ip: false,
              assign_private_dns_record: false,
              defined_tags: {
                'EXAMPLE_KEY_ZQhi6' => {
                  'EXAMPLE_KEY_maZA8' => 'EXAMPLE--Value'
                }
              },
              display_name: 'EXAMPLE-displayName-Value',
              freeform_tags: {
                'EXAMPLE_KEY_kxQBB' => 'EXAMPLE_VALUE_fBJUiGXhNv6jLgrAju00'
              },
              ipv6_address_ipv6_subnet_cidr_pair_details: [
                OCI::Core::Models::InstanceConfigurationIpv6AddressIpv6SubnetCidrPairDetails
                  .new(
                  ipv6_subnet_cidr: 'EXAMPLE-ipv6SubnetCidr-Value',
                  ipv6_address: 'EXAMPLE-ipv6Address-Value'
                )
              ],
              hostname_label: 'EXAMPLE-hostnameLabel-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'
            ),
          defined_tags: {
            'EXAMPLE_KEY_cL9JH' => { 'EXAMPLE_KEY_rdOgm' => 'EXAMPLE--Value' }
          },
          display_name: 'EXAMPLE-displayName-Value',
          extended_metadata: { 'EXAMPLE_KEY_nrA5x' => 'EXAMPLE--Value' },
          freeform_tags: {
            'EXAMPLE_KEY_aldXX' => 'EXAMPLE_VALUE_Fq6O5MJ708EISDYT5CTf'
          },
          ipxe_script: 'EXAMPLE-ipxeScript-Value',
          metadata: {
            'EXAMPLE_KEY_2iar3' => 'EXAMPLE_VALUE_2DHm9DjxyTcIGCmTX1co'
          },
          shape: 'EXAMPLE-shape-Value',
          shape_config:
            OCI::Core::Models::InstanceConfigurationLaunchInstanceShapeConfigDetails
              .new(
              ocpus: 5899.1074,
              vcpus: 336,
              memory_in_gbs: 2494.827,
              baseline_ocpu_utilization: 'BASELINE_1_8',
              nvmes: 3
            ),
          platform_config:
            OCI::Core::Models::InstanceConfigurationAmdRomeBmGpuLaunchInstancePlatformConfig
              .new(
              type: 'AMD_ROME_BM_GPU',
              is_secure_boot_enabled: true,
              is_trusted_platform_module_enabled: true,
              is_measured_boot_enabled: true,
              is_memory_encryption_enabled: true,
              numa_nodes_per_socket: 'NPS0',
              is_symmetric_multi_threading_enabled: true,
              is_access_control_service_enabled: false,
              are_virtual_instructions_enabled: false,
              is_input_output_memory_management_unit_enabled: true,
              config_map: {
                'EXAMPLE_KEY_lDfsP' => 'EXAMPLE_VALUE_BDxASGwHmLMf9xPEDDX6'
              }
            ),
          source_details:
            OCI::Core::Models::InstanceConfigurationInstanceSourceViaImageDetails
              .new(
              source_type: 'image',
              boot_volume_size_in_gbs: 145,
              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: 12,
              instance_source_image_filter_details:
                OCI::Core::Models::InstanceConfigurationInstanceSourceImageFilterDetails
                  .new(
                  compartment_id:
                    'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
                  defined_tags_filter: {
                    'EXAMPLE_KEY_qhBIS' => {
                      'EXAMPLE_KEY_pyN1X' => 'EXAMPLE--Value'
                    }
                  },
                  operating_system: 'EXAMPLE-operatingSystem-Value',
                  operating_system_version:
                    'EXAMPLE-operatingSystemVersion-Value'
                )
            ),
          fault_domain: 'EXAMPLE-faultDomain-Value',
          dedicated_vm_host_id:
            'ocid1.test.oc1..<unique_ID>EXAMPLE-dedicatedVmHostId-Value',
          launch_mode: 'PARAVIRTUALIZED',
          launch_options:
            OCI::Core::Models::InstanceConfigurationLaunchOptions.new(
              boot_volume_type: 'IDE',
              firmware: 'BIOS',
              network_type: 'PARAVIRTUALIZED',
              remote_data_volume_type: 'PARAVIRTUALIZED',
              is_pv_encryption_in_transit_enabled: false,
              is_consistent_volume_naming_enabled: true
            ),
          agent_config:
            OCI::Core::Models::InstanceConfigurationLaunchInstanceAgentConfigDetails
              .new(
              is_monitoring_disabled: true,
              is_management_disabled: true,
              are_all_plugins_disabled: true,
              plugins_config: [
                OCI::Core::Models::InstanceAgentPluginConfigDetails.new(
                  name: 'EXAMPLE-name-Value', desired_state: 'ENABLED'
                )
              ]
            ),
          is_pv_encryption_in_transit_enabled: false,
          preferred_maintenance_action: 'REBOOT',
          instance_options:
            OCI::Core::Models::InstanceConfigurationInstanceOptions.new(
              are_legacy_imds_endpoints_disabled: false
            ),
          availability_config:
            OCI::Core::Models::InstanceConfigurationAvailabilityConfig.new(
              is_live_migration_preferred: true,
              recovery_action: 'RESTORE_INSTANCE'
            ),
          preemptible_instance_config:
            OCI::Core::Models::PreemptibleInstanceConfigDetails.new(
              preemption_action:
                OCI::Core::Models::TerminatePreemptionAction.new(
                  type: 'TERMINATE', preserve_boot_volume: false
                )
            )
        ),
      secondary_vnics: [
        OCI::Core::Models::InstanceConfigurationAttachVnicDetails.new(
          create_vnic_details:
            OCI::Core::Models::InstanceConfigurationCreateVnicDetails.new(
              assign_ipv6_ip: true,
              assign_public_ip: true,
              assign_private_dns_record: false,
              defined_tags: {
                'EXAMPLE_KEY_eDHz2' => {
                  'EXAMPLE_KEY_T2nQw' => 'EXAMPLE--Value'
                }
              },
              display_name: 'EXAMPLE-displayName-Value',
              freeform_tags: {
                'EXAMPLE_KEY_w7Iyi' => 'EXAMPLE_VALUE_HHtGNBW6Y5KQdluNzrz6'
              },
              ipv6_address_ipv6_subnet_cidr_pair_details: [
                OCI::Core::Models::InstanceConfigurationIpv6AddressIpv6SubnetCidrPairDetails
                  .new(
                  ipv6_subnet_cidr: 'EXAMPLE-ipv6SubnetCidr-Value',
                  ipv6_address: 'EXAMPLE-ipv6Address-Value'
                )
              ],
              hostname_label: 'EXAMPLE-hostnameLabel-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'
            ),
          display_name: 'EXAMPLE-displayName-Value',
          nic_index: 28
        )
      ]
    )
  )

# Get the data from response
puts "#{launch_instance_configuration_response.data}"

Was this article helpful?