# Security in Compute

Who may do what (IAM), what is audited, how volumes are encrypted, and how instances are exposed to the network.

## IAM actions

Every operation is checked against your IAM policies. A resource name looks like
`rn:ews:de1:<org>:ec2:instance/<instance id>`; the resource types are `instance`, `volume`, `vpc`,
`subnet`, `security-group`, `key-pair`, `image`, `elastic-ip`, `snapshot-policy`, `nat-gateway` and
`snapshot`.

(The table of IAM actions is generated on the web page.)
- **Start, stop and reboot** are three actions: `ec2:StartInstances`, `ec2:StopInstances` (stop
  and shutdown) and `ec2:RebootInstances`. Renaming, resizing and changing security groups are all
  `ec2:ModifyInstanceAttribute`.
- **Security group rules** are checked by direction: `ec2:AuthorizeSecurityGroupIngress` /
  `…Egress` to add, `ec2:RevokeSecurityGroupIngress` / `…Egress` to remove, read from the stored
  rule.
- **Launching** with extra volumes also needs `ec2:CreateVolume` and `ec2:AttachVolume`; with an
  instance role, `iam:PassRole` on it; with a public hostname, `dns:ChangeRecords` on the zone.
- **Snapshotting an attached volume** also needs `ec2:StopInstances` on its instance.
- **Choosing a KMS key** for a volume needs `kms:Encrypt` on that key.
- `ec2:GetInstanceUserData` is a sensitive read: not in the read-only presets, and recorded in the
  audit log whether allowed or refused.
- The instance type catalog, image catalog and region list (`/ec2/api/catalog/…`) need a signed-in
  caller and no action.
- Key pairs in the console use the KMS SSH key pair actions (`kms:GenerateSshKeyPair`,
  `kms:ImportSshKeyPair`, `kms:DeleteSshKeyPair`). The list needs `kms:ListSshKeyPairs` or
  `ec2:DescribeKeyPairs`.

## Audit

Every write is recorded in the audit log with its outcome, as is every read of user data. A machine
receiving its role's credentials is recorded as `iam:AssumeRoleForInstance`, and every identity
token as `ec2:GetInstanceIdentityToken`.

## Encryption

- **Volumes** are encrypted with LUKS2 by default, each with its own key, wrapped by the platform key
  or by one of your KMS keys. The key is released only to the instance the volume is attached to,
  from its own address. Deleting the volume deletes the key. See
  [Use encrypted volumes](encrypted-volumes.md).
- **Volume snapshots** of an encrypted volume are copied as ciphertext and keep their own copy of
  the key.
- **Root disks** are not encrypted.

## Network exposure

- With no security group attached, every port of an instance is open to the internet. The launch
  wizard proposes a new group that lets in SSH from your address only, and warns **Every port of
  this machine will be open to the internet.** when you choose none. Through the API, CLI or
  Terraform, an instance launched without `securityGroupIds` has no group.
- Security groups filter the public side; traffic inside a private network is not filtered.
- An instance launched without a public IPv4 has a public IPv6 address and no inbound IPv4.
- No root password is set on a machine; logins use keys.
- Deutsche Cloud Connect is on unless you launch with `connect: false`: the machine keeps one outbound
  SSH connection to Deutsche Cloud, through which the console terminal logs in and keys are added,
  with no inbound port open. See [What runs on your machines](what-runs-on-your-machines.md).

## Related

- [Networks and addresses](networks-and-addresses.md)
- [What runs on your machines](what-runs-on-your-machines.md)
