---
title: "Attach a Compute instance to a Security Group"
method: PUT
path: "/security-group/{id}:attach"
tags: ["security-group"]
---

# Attach a Compute instance to a Security Group

`PUT /security-group/{id}:attach`

## Request

- Base URL: `https://api-ch-gva-2.exoscale.com/v2`
- URL: `https://api-ch-gva-2.exoscale.com/v2/security-group/{id}:attach`
- Auth: none declared
- TypeScript: <https://skmtc.dev/exoscale/apis/exoscale-api/docs/security-group/:id:attach/put.ts> (a function with typed inputs; its response is checked against the schema)

## Path parameters

- `id` string, uuid, required

## Request body

- object
  - `instance` Instance, required: Instance
    - `application-consistent-snapshot-enabled` boolean: Indicates if the instance will take application-consistent snapshots
    - `anti-affinity-groups` AntiAffinityGroupRef[]: Instance Anti-affinity Groups
      - `id` string, uuid: Anti-affinity group ID
    - `public-ip-assignment` 'inet4' | 'dual' | 'none'
    - `labels` Labels
    - `security-groups` SecurityGroupRef[]: Instance Security Groups
      - `id` string, uuid: Security group ID
    - `elastic-ips` ElasticIpRef[]: Instance Elastic IPs
      - `id` string, uuid: Elastic IP ID
    - `name` string: Instance name
    - `instance-type` InstanceType: Compute instance type
      - `id` string, uuid: Instance type ID
      - `size` 'large' | 'huge' | 'jumbo' | 'medium' | 'mega' | 'small' | 'extra-large' | 'titan48c' | 'titan' | 'micro' | 'colossus' | 'tiny': Instance type size
      - `family` 'gpu3' | 'gpua30' | 'gpu3080ti' | 'gpu2' | 'gpu' | 'memory' | 'gpua5000' | 'gpub300' | 'gpurtx6000pro' | 'storage' | 'standard' | 'colossus' | 'cpu': Instance type family
      - `cpus` integer: CPU count
      - `gpus` integer: GPU count
      - `authorized` boolean: Requires authorization or publicly available
      - `memory` integer: Available memory
      - `zones` ZoneName[]: Instance Type available zones
    - `private-networks` object[]: Instance Private Networks
      - `id` string, uuid: Private Network ID
      - `mac-address` string: Private Network MAC address
    - `template` Template: Instance template
      - `application-consistent-snapshot-enabled` boolean: Template with Qemu Guest Agent installed for application consistent snapshot
      - `maintainer` string: Template maintainer
      - `description` string: Template description
      - `ssh-key-enabled` boolean: Enable SSH key-based login
      - `family` string: Template family
      - `name` string: Template name
      - `default-user` string: Template default user
      - `size` integer: Template size
      - `password-enabled` boolean: Enable password-based login
      - `build` string: Template build
      - `checksum` string: Template MD5 checksum
      - `boot-mode` 'legacy' | 'uefi': Boot mode (default: legacy)
      - `id` string, uuid: Template ID
      - `zones` ZoneName[]: Zones availability
      - `url` string: Template source URL
      - `version` string: Template version
      - `created-at` string, date-time: Template creation date
      - `visibility` 'private' | 'public': Template visibility
    - `state` 'expunging' | 'starting' | 'destroying' | 'running' | 'stopping' | 'stopped' | 'migrating' | 'error' | 'destroyed'
    - `secureboot-enabled` boolean: Indicates if the instance has secure boot enabled
    - `ssh-key` SshKey: SSH key
      - `name` string: SSH key name
      - `fingerprint` string: SSH key fingerprint
    - `user-data` string: Instance Cloud-init user-data (base64 encoded)
    - `mac-address` string: Instance MAC address
    - `manager` Manager: Resource manager
      - `id` string, uuid: Manager ID
      - `type` 'sks-nodepool' | 'instance-pool': Manager type
    - `tpm-enabled` boolean: Indicates if the instance has tpm enabled
    - `deploy-target` DeployTargetRef: Deploy target reference
      - `id` string, uuid: Deploy target ID
    - `ipv6-address` string: Instance IPv6 address
    - `id` string, uuid: Instance ID
    - `snapshots` SnapshotRef[]: Instance Snapshots
      - `id` string, uuid: Snapshot ID
    - `disk-size` integer: Instance disk size in GiB
    - `disk-encrypted` boolean: Indicates if the root volume of the instance is encrypted
    - `ssh-keys` SshKey[]: Instance SSH Keys
      - `name` string: SSH key name
      - `fingerprint` string: SSH key fingerprint
    - `created-at` string, date-time: Instance creation date
    - `public-ip` string, ipv4: Instance public IPv4 address

## Response `200`

200

- Operation: Operation
  - `id` string, uuid: Operation ID
  - `reason` 'incorrect' | 'unknown' | 'unavailable' | 'forbidden' | 'busy' | 'fault' | 'partial' | 'not-found' | 'interrupted' | 'unsupported' | 'conflict': Operation failure reason
  - `reference` object: Related resource reference
    - `id` string, uuid: Reference ID
    - `link` string: Link to the referenced resource
    - `command` string: Command name
  - `message` string: Operation message
  - `state` 'failure' | 'pending' | 'success' | 'timeout': Operation status

---

[API](https://skmtc.dev/exoscale/apis/exoscale-api.md) - [All operations](https://skmtc.dev/exoscale/apis/exoscale-api/llms.txt) - [OpenAPI document](https://skmtc.dev/exoscale/apis/exoscale-api/revisions/63da6f74c845?raw)
