# Enoslib ScalewayInstances plugin

## Installation

Some functionnalities (enabling IPv6) requires the user to have the scaleway cli installed, see: [section](#recommendations).

Deployed on PyPI:

```bash
pip install enos_scalewayinstances
```

Checkout [example](./docs/examples/deploy_expose_port.py)

## Rationale

This ScalewayInstances provider is quite opiniated, it deploys scaleway instances according to two different 'architectures', which are different ways to organize your instances:

### "private_network" architecture

It is configured to deploy a number of configured nodes defined by the user in the configuration and then put all those instances in a private network with a public gateway.

Unless you request public IPs with the `dynamic_ip_required` parameter, your instances will not be available to outside providers or users. If you want to expose certain services, you can forward ports from your instances to the public gateway (see the [example](./docs/examples/deploy_expose_port.py))

### "standalone" architecture

This will just deploy instances with public addresses and no private network/gateway setup. 

You can setup firework with the `open_firewall` function.

## Zone non-support

Support for setting zone and regions of your instances is not available in this provider for the moment, zones and regions will default to the defaults of your configuration.

## Recommendations 

Install the scaleway CLI as it is a good tool to check your running instances or parse information

https://www.scaleway.com/fr/cli/

### Useful commands 

#### Check running instances 
```bash
scw instance server list 
# With specifying zone 
scw instance server list zone="fr-par-1"
```

#### Terminate a running instances 
```bash
scw instance server terminate <INSTANCE_ID>
```

#### List existing public gateways
```bash
scw vpc-gw gateway list
```

#### Delete existing public gateway
```bash
scw vpc-gw gateway delete <NETWORK_ID>
```

#### List existing private networks
```bash
scw vpc private-network list
```

#### Delete existing private network
```bash
scw vpc private-network delete <NETWORK_ID>
```

#### List available commercial types
```bash
scw instance server-type list 
```

#### List available OS images
```bash
scw marketplace image list
```

#### SSH to a machine in a private network 

Since the public gateway deployed on the private network has [bation](https://www.scaleway.com/en/docs/public-gateways/how-to/use-ssh-bastion/) activated, the command to connect to a instance behind the bastion looks like this: 

```bash
ssh -J bastion@<gateway_IP_address>:61000 root@<instance_IP_address>
```

Where `<instance_IP_address>` is either the instance's public IP address or its private alias in the form of : `<instance_name>.<private_network_name>.internal`.

## Future improvements

- [ ] Improve IPv6 handling
- [ ] Improve volume handling, e.g. add options to set volume size 
- [ ] Improve zone / region support
