|
| 1 | +--- |
| 2 | +page_title: "Using Scaleway SSH Bastion" |
| 3 | +--- |
| 4 | + |
| 5 | +# How to use pass to depecated resource cockpit to new infra <- change ici le titre pour que se soit plus claire |
| 6 | + |
| 7 | +-> voici l'explication : ducoup je fais un guide pour pouvoir supprimer la resource cockpit des terraforms et utiliser la nouvelle resource source, explique moi cela bien en anglais |
| 8 | +-> **Note:** |
| 9 | +Cockpit plans scheduled for deprecation on January 1st 2025. |
| 10 | +The retention period previously set for your logs and metrics will remain the same after that date. |
| 11 | +You will be able to edit the retention period for your metrics, logs, and traces for free during Beta. |
| 12 | + |
| 13 | + |
| 14 | +## Prerequisites |
| 15 | + |
| 16 | +d'abord il faut s'assurer d'avoir la dernier version du provider |
| 17 | +-> **Note:** Before upgrading to `v2+`, it is recommended to upgrade to the most recent `1.X` version of the provider (`v1.17.2`) and ensure that your environment successfully runs [`terraform plan`](https://www.terraform.io/docs/commands/plan.html) without unexpected change or deprecation notice. |
| 18 | + |
| 19 | +It is recommended to use [version constraints when configuring Terraform providers](https://www.terraform.io/language/providers/configuration#version-provider-versions). |
| 20 | +If you are following these recommendations, update the version constraints in your Terraform configuration and run [`terraform init`](https://www.terraform.io/docs/commands/init.html) to download the new version. |
| 21 | + |
| 22 | +Update to latest `1.X` version: |
| 23 | + |
| 24 | +```hcl |
| 25 | +terraform { |
| 26 | + required_providers { |
| 27 | + scaleway = { |
| 28 | + source = "scaleway/scaleway" |
| 29 | + version = "~> 1.17" |
| 30 | + } |
| 31 | + } |
| 32 | +} |
| 33 | +
|
| 34 | +provider "scaleway" { |
| 35 | + # ... |
| 36 | +} |
| 37 | +``` |
| 38 | + |
| 39 | +Update to latest 2.X version: |
| 40 | + |
| 41 | +## Set up your Public Gateway |
| 42 | + |
| 43 | +Public Gateways sit at the border of Private Networks and allow you to enable the bastion. |
| 44 | +You can also choose your port of preference on `bastion_port` option. The default port is `61000` |
| 45 | + |
| 46 | +You can check the types of gateways currently supported via our CLI. |
| 47 | + |
| 48 | +```shell |
| 49 | +scw vpc-gw gateway-type list |
| 50 | +``` |
| 51 | + |
| 52 | +Example: |
| 53 | + |
| 54 | +```hcl |
| 55 | +resource scaleway_vpc_public_gateway "pgw" { |
| 56 | + type = "VPC-GW-S" |
| 57 | + bastion_enabled = true |
| 58 | + ip_id = scaleway_vpc_public_gateway_ip.pgw_ip.id |
| 59 | +} |
| 60 | +``` |
| 61 | + |
| 62 | +## Configure your DHCP on your subnet |
| 63 | + |
| 64 | +The [DHCP](https://fr.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol) server sets the IPv4 address dynamically, |
| 65 | +which is required to communicate over the private network. |
| 66 | + |
| 67 | +The `dns_local_name` is the [TLD](https://en.wikipedia.org/wiki/Top-level_domain), the value by default is `priv`. |
| 68 | +This is used to resolve your Instance on a Private Network. |
| 69 | + |
| 70 | +In order to resolve the Instances using your Bastion you should set the `dns_local_name` with `scaleway_vpc_private_network.pn.name`. |
| 71 | + |
| 72 | +Please check our API [documentation](https://www.scaleway.com/en/developers/api/public-gateway/#path-dhcp-create-a-dhcp-configuration) for more details. |
| 73 | + |
| 74 | +```hcl |
| 75 | +resource scaleway_vpc_public_gateway_dhcp "dhcp" { |
| 76 | + subnet = "192.168.1.0/24" |
| 77 | + dns_local_name = scaleway_vpc_private_network.pn.name |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | +## Attach your VPC Gateway Network to a Private Network |
| 82 | + |
| 83 | +To enable DHCP on this Private Network you must set `enable_dhcp` and `dhcp_id`. |
| 84 | +Do not set the `address` attribute. |
| 85 | + |
| 86 | +```hcl |
| 87 | +resource scaleway_vpc_gateway_network "gn" { |
| 88 | + gateway_id = scaleway_vpc_public_gateway.pgw.id |
| 89 | + private_network_id = scaleway_vpc_private_network.pn.id |
| 90 | + dhcp_id = scaleway_vpc_public_gateway_dhcp.dhcp.id |
| 91 | + enable_dhcp = true |
| 92 | +} |
| 93 | +``` |
| 94 | + |
| 95 | +## Config my Bastion config |
| 96 | + |
| 97 | +You should add your config on your local config file e.g: `~/.ssh/config` |
| 98 | + |
| 99 | +``` |
| 100 | +Host *.myprivatenetwork |
| 101 | +ProxyJump bastion@<your-public-ip>:<bastion_port> |
| 102 | +``` |
| 103 | + |
| 104 | +Then try to connect to it: |
| 105 | + |
| 106 | +```shell |
| 107 | +ssh root@<vm-name>.myprivatenetwork |
| 108 | +``` |
| 109 | + |
| 110 | +For further information using our console please check [our dedicated documentation](https://www.scaleway.com/en/docs/network/vpc/how-to/use-ssh-bastion/). |
0 commit comments