Launch an instance to get a running Linux machine you can log in to over SSH. You choose what it boots from, its size, its key pair and where it sits on the network.
Before you begin
- An organization that is approved and has a valid payment method, and a project to launch into. See Organizations and Add a payment method.
- The
originCLI, signed in. See CLI access. - A key pair in the project. See Create a key pair.
- Free quota for one more instance and its vCPUs, and for its root disk. See Limits.
Launch the instance
-
Choose an instance type whose
availableistrue:Terminal window origin compute list-instance-typesFor what the fields mean, see Instance types.
-
Choose an image. List the platform-provided images and your own:
Terminal window origin compute list-images --project-urn <project-urn>To launch the image currently designated for a family instead, use
--image-family <family-slug>in place of--image-urnin the next step. See Image families. -
Launch the instance:
Terminal window origin compute launch-instance \--project-urn <project-urn> \--image-urn <image-urn> \--instance-type gp1.core.2 \--key-pair-urn <key-pair-urn>With no
--subnet-urn, the instance goes into your project’s default subnet. That subnet is created on first use, in a VPC with an internet gateway, and the instance’s network interface gets a public address automatically. See Default VPC. -
Add the options you need. Each is optional:
Option Use it to --subnet-urn <subnet-urn>Place the instance in a subnet of your own VPC. --security-group-urn <security-group-urn>Attach security groups to the network interface. Repeat it for several groups. Omitted, the VPC’s default security group applies. See Security groups. --boot-volume-size-gib <size>Make the root disk bigger than the image. See Instance storage. --boot-volume-storage-class <class>Pick the root disk’s storage class. See Storage classes. --login-user <name>Override the image’s default user. See Guest environment. --volume-backendaccepts onlypvs, which is the default. Leave it out. -
Wait for the instance to reach
RUNNING. Runget-instanceuntilstatusstops changing:Terminal window origin compute get-instance --instance-urn <instance-urn>It passes through
INITIALIZINGandPENDINGfirst. If it ends upFAILED, read itsstatusReasonand see Status reasons. -
Find the instance’s addresses.
get-instancelists the instance’s network interfaces undernetworkInterfaceAttachments, each with itsipv4Address,ipv6Addressand, if it has one, its Floating IP asfloatingIpAddress:Terminal window origin compute get-instance --instance-urn <instance-urn>list-instancesshows the same for every instance in the project. See Network interfaces. -
Verify that you can log in, as the instance’s
loginUser, with the private key of the key pair:Terminal window ssh -i <private-key-file> <login-user>@<public-address>The VPC’s default security group allows SSH from anywhere. If you attached other security groups, one of them must allow inbound TCP port 22 from your address.
Using the API
The launchInstance mutation takes the same inputs. It also accepts imageFamily in place of imageUrn, which launches the image currently designated for that family. Set exactly one of the two. See Image families.
mutation { compute { launchInstance(input: { projectUrn: "<project-urn>" imageFamily: "<family-slug>" instanceType: "gp1.core.2" keyPairUrn: "<key-pair-urn>" bootVolume: { sizeInGib: 40 } }) { urn status loginUser } }}If the launch is refused
A refused launch creates nothing and costs nothing.
INSUFFICIENT_CAPACITY: no machine has room for this type right now. The message names the type and what was short. Retry later or launch a smaller type. SeeINSUFFICIENT_CAPACITY.PRODUCT_UNAVAILABLE: the instance type or storage class isn’t offered. Pick one whoseavailableistrue. SeePRODUCT_UNAVAILABLE.- Quota: the launch would take the organization or project past an instance, vCPU or storage limit. The error names the quota. See Limits.
- Root disk too small:
--boot-volume-size-gibis smaller than the image. The error names the smallest size that works.
For other problems, see Troubleshoot Compute.