Getting started with Compute
Launch an instance that only you can reach over SSH, log in, and delete everything again, in about ten minutes.
Replace web-01 with a name of your own, 203.0.113.4 with your own public address, and the ids with the ones each step answers.
Prerequisites
- Permission for
ec2:RunInstances,ec2:CreateSecurityGroup,ec2:DescribeInstances,ec2:TerminateInstancesandec2:DeleteSecurityGroup, and for the CLI's separate rule stepec2:AuthorizeSecurityGroupIngress; the managed policyEc2FullAccessgrants them all. - In the console, also
ec2:DescribeSecurityGroupsto open Security groups in Clean up (without it the page says "Access denied") and the group's page (without it the page is not found);Ec2FullAccessgrants it too. - A key pair. The console can make one while you launch; for the CLI and API, create or import one first (see Manage key pairs).
You pay for every started hour the instance runs, until you terminate it in Clean up.
Step 1: Let only your address in
You do this in step 2: with no security group added, the form offers Allow SSH from
address only, which creates the group ssh-from-my-ip (SSH, port 22, from your IPv4 address)
when you choose Create instance.
dcloud ec2 security-groups create --name ssh-only --description "SSH from my address"
dcloud ec2 security-groups authorize-ingress sg-uuid --protocol tcp --from-port 22 --to-port 22 --cidr-ipv4 203.0.113.4/32POST /ec2/api/security-groups
{
"name": "ssh-only",
"rules": [
{ "direction": "inbound", "protocol": "tcp", "fromPort": 22, "toPort": 22, "cidrIpv4": "203.0.113.4" }
]
}A single address is stored as /32.
Step 2: Launch the instance
- Open Compute, then choose Create instance.
- Under Basics, for Name, enter web-01. Keep Region
de1. - Under Size, keep the preselected Instance type (the cheapest shared type in stock), or choose another one that is in stock.
- Under Image, keep the preselected Boot image (Ubuntu 24.04).
- Under Network, in the banner Every port of this machine will be open to the internet., choose Allow SSH from address only.
- Under Security, for Login key pair, choose your key pair, or create one from the picker.
- Choose Create instance.
The instance page opens with the state Pending, then Running.
dcloud ec2 instances run --region-id de1 --server-type performance-2 \
--image-id 114690387 --name web-01 \
--ssh-key-pair-id key-pair-uuid --security-group-ids sg-uuid
dcloud ec2 instances wait i-3f9a2c07wait returns once the instance is running.
POST /ec2/api/instances
{
"serverType": "performance-2",
"imageId": 114690387,
"regionId": "de1",
"name": "web-01",
"sshKeyPairId": "3f0c2a8e-0000-4000-8000-000000000001",
"securityGroupIds": ["3f0c2a8e-0000-4000-8000-000000000002"]
}The answer is 201 with the instance in state pending. Image ids come from
GET /ec2/api/catalog/images.
Step 3: Log in
The instance's Overview shows the SSH command under Connect once the instance has a public address:
ssh -i ~/.ssh/my-key root@192.0.2.10The default user on the platform images is root; point -i at the private half of your key
pair. To log in from the browser instead, open the instance's Connect tab.
Clean up
- On the instance page, choose the Danger zone tab, then Terminate instance.
- Enter the instance name and choose Terminate. The state turns Terminated once the machine is deleted.
- Open Security groups, open
ssh-from-my-ip, choose the Danger zone tab, then Delete security group. - Enter the group's name and choose Delete security group. While the instance is not yet terminated, deleting is refused: the group is still attached.
dcloud ec2 instances terminate i-3f9a2c07
dcloud ec2 instances wait i-3f9a2c07 --state terminated
dcloud ec2 security-groups delete sg-uuidDELETE /ec2/api/instances/i-3f9a2c07Then, once the instance is terminated, DELETE /ec2/api/security-groups/{id}.
Next steps
- Launch an instance: every launch option.
- Create and attach a volume
- Use an elastic IP