// 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).
package main
import (
"context"
"fmt"
"github.com/oracle/oci-go-sdk/v65/common"
"github.com/oracle/oci-go-sdk/v65/core"
"github.com/oracle/oci-go-sdk/v65/example/helpers"
)
func ExampleLaunchInstance() {
// Create a default authentication provider that uses the DEFAULT
// profile in the configuration file.
// Refer to <see href="https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File>the public documentation</see> on how to prepare a configuration file.
client, err := core.NewComputeClientWithConfigurationProvider(common.DefaultConfigProvider())
helpers.FatalIfError(err)
// Create a request and dependent object(s).
req := core.LaunchInstanceRequest{OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
LaunchInstanceDetails: core.LaunchInstanceDetails{PlatformConfig: core.IntelIcelakeBmLaunchInstancePlatformConfig{ConfigMap: map[string]string{"EXAMPLE_KEY_iLxAB": "EXAMPLE_VALUE_0TU0U7liD9i5agYpWfFW"},
IsInputOutputMemoryManagementUnitEnabled: common.Bool(true),
IsMemoryEncryptionEnabled: common.Bool(true),
IsSymmetricMultiThreadingEnabled: common.Bool(false),
NumaNodesPerSocket: core.IntelIcelakeBmLaunchInstancePlatformConfigNumaNodesPerSocketNps2,
PercentageOfCoresEnabled: common.Int(32),
IsMeasuredBootEnabled: common.Bool(false),
IsSecureBootEnabled: common.Bool(false),
IsTrustedPlatformModuleEnabled: common.Bool(true)},
Shape: common.String("EXAMPLE-shape-Value"),
ClusterPlacementGroupId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-clusterPlacementGroupId-Value"),
CreateVnicDetails: &core.CreateVnicDetails{AssignIpv6Ip: common.Bool(false),
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_FFgpO": map[string]interface{}{"EXAMPLE_KEY_NN1up": "EXAMPLE--Value"}},
DisplayName: common.String("EXAMPLE-displayName-Value"),
SkipSourceDestCheck: common.Bool(false),
VlanId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-vlanId-Value"),
AssignPrivateDnsRecord: common.Bool(false),
SubnetId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value"),
HostnameLabel: common.String("EXAMPLE-hostnameLabel-Value"),
Ipv6AddressIpv6SubnetCidrPairDetails: []core.Ipv6AddressIpv6SubnetCidrPairDetails{core.Ipv6AddressIpv6SubnetCidrPairDetails{Ipv6Address: common.String("EXAMPLE-ipv6Address-Value"),
Ipv6SubnetCidr: common.String("EXAMPLE-ipv6SubnetCidr-Value")}},
NsgIds: []string{"EXAMPLE--Value"},
SecurityAttributes: map[string]map[string]interface{}{"EXAMPLE_KEY_La75N": map[string]interface{}{"EXAMPLE_KEY_K2AmG": "EXAMPLE--Value"}},
AssignPublicIp: common.Bool(false),
FreeformTags: map[string]string{"EXAMPLE_KEY_HkP8N": "EXAMPLE_VALUE_a06dxQsL1oKuvH20rWBv"},
PrivateIp: common.String("EXAMPLE-privateIp-Value"),
SubnetCidr: common.String("EXAMPLE-subnetCidr-Value")},
PlacementConstraintDetails: core.ComputeBareMetalHostPlacementConstraintDetails{ComputeBareMetalHostId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-computeBareMetalHostId-Value")},
SecurityAttributes: map[string]map[string]interface{}{"EXAMPLE_KEY_SFkoF": map[string]interface{}{"EXAMPLE_KEY_wNygU": "EXAMPLE--Value"}},
AvailabilityConfig: &core.LaunchInstanceAvailabilityConfigDetails{IsLiveMigrationPreferred: common.Bool(true),
RecoveryAction: core.LaunchInstanceAvailabilityConfigDetailsRecoveryActionRestoreInstance},
ComputeClusterId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-computeClusterId-Value"),
AgentConfig: &core.LaunchInstanceAgentConfigDetails{PluginsConfig: []core.InstanceAgentPluginConfigDetails{core.InstanceAgentPluginConfigDetails{DesiredState: core.InstanceAgentPluginConfigDetailsDesiredStateDisabled,
Name: common.String("EXAMPLE-name-Value")}},
AreAllPluginsDisabled: common.Bool(true),
IsManagementDisabled: common.Bool(false),
IsMonitoringDisabled: common.Bool(false)},
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
InstanceConfigurationId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-instanceConfigurationId-Value"),
ExtendedMetadata: map[string]interface{}{"EXAMPLE_KEY_J90sM": "EXAMPLE--Value"},
FaultDomain: common.String("EXAMPLE-faultDomain-Value"),
HostnameLabel: common.String("EXAMPLE-hostnameLabel-Value"),
LaunchOptions: &core.LaunchOptions{IsPvEncryptionInTransitEnabled: common.Bool(false),
NetworkType: core.LaunchOptionsNetworkTypeE1000,
RemoteDataVolumeType: core.LaunchOptionsRemoteDataVolumeTypeIde,
BootVolumeType: core.LaunchOptionsBootVolumeTypeIscsi,
Firmware: core.LaunchOptionsFirmwareBios,
IsConsistentVolumeNamingEnabled: common.Bool(true)},
Metadata: map[string]string{"EXAMPLE_KEY_B7p7o": "EXAMPLE_VALUE_Zz0lKlQXy9ZL40ODWgzT"},
PreemptibleInstanceConfig: &core.PreemptibleInstanceConfigDetails{PreemptionAction: core.TerminatePreemptionAction{PreserveBootVolume: common.Bool(true)}},
SubnetId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value"),
DedicatedVmHostId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-dedicatedVmHostId-Value"),
InstanceOptions: &core.InstanceOptions{AreLegacyImdsEndpointsDisabled: common.Bool(false)},
IsPvEncryptionInTransitEnabled: common.Bool(true),
ShapeConfig: &core.LaunchInstanceShapeConfigDetails{Nvmes: common.Int(4),
Ocpus: common.Float32(6537.163),
ResourceManagement: core.LaunchInstanceShapeConfigDetailsResourceManagementStatic,
Vcpus: common.Int(20),
BaselineOcpuUtilization: core.LaunchInstanceShapeConfigDetailsBaselineOcpuUtilization2,
MemoryInGBs: common.Float32(3006.1138)},
SourceDetails: core.InstanceSourceViaBootVolumeDetails{BootVolumeId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-bootVolumeId-Value")},
CapacityReservationId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value"),
ImageId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-imageId-Value"),
LaunchVolumeAttachments: []core.LaunchAttachVolumeDetails{core.LaunchAttachParavirtualizedVolumeDetails{VolumeId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-volumeId-Value"),
Device: common.String("EXAMPLE-device-Value"),
DisplayName: common.String("EXAMPLE-displayName-Value"),
IsPvEncryptionInTransitEnabled: common.Bool(false),
IsReadOnly: common.Bool(false),
IsShareable: common.Bool(false),
LaunchCreateVolumeDetails: core.LaunchCreateVolumeFromAttributes{SizeInGBs: common.Int64(450),
VpusPerGB: common.Int64(165),
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
DisplayName: common.String("EXAMPLE-displayName-Value"),
KmsKeyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value")}}},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_orota": map[string]interface{}{"EXAMPLE_KEY_lKHRn": "EXAMPLE--Value"}},
FreeformTags: map[string]string{"EXAMPLE_KEY_JtvEr": "EXAMPLE_VALUE_c4MqaX0pTUJwgyTVu73O"},
IsAIEnterpriseEnabled: common.Bool(false),
LicensingConfigs: []core.LaunchInstanceLicensingConfig{core.LaunchInstanceWindowsLicensingConfig{LicenseType: core.LaunchInstanceLicensingConfigLicenseTypeOciProvided}},
AvailabilityDomain: common.String("EXAMPLE-availabilityDomain-Value"),
DisplayName: common.String("EXAMPLE-displayName-Value"),
IpxeScript: common.String("EXAMPLE-ipxeScript-Value")}}
// Send the request using the service client
resp, err := client.LaunchInstance(context.Background(), req)
helpers.FatalIfError(err)
// Retrieve value from the response.
fmt.Println(resp)
}