# Cloud Providers

# Amazon Web Services

# AWS Provider HandBook

##### <span style="color: rgb(53, 152, 219);">Установка AWS CLI</span> 

- [<span style="color: rgb(22, 145, 121);">**AWS Install**</span>](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
- [**Credentials** Setup](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html#getting-started-quickstart-new-file)
- [**CLI Commands**](https://docs.aws.amazon.com/cli/latest/reference/#available-services)

##### <span style="color: rgb(53, 152, 219);">AWS Provider Guide</span>

- [**S3 Buckets** Commands](https://docs.aws.amazon.com/cli/latest/userguide/cli-services-s3-commands.html#using-s3-commands-managing-buckets-creating)
- [**<span class="">FUSE </span>**<span class="">Install</span>](https://yandex.cloud/ru/docs/storage/tools/#fuse)

# Change DNS [AWS CLI]

##### <span style="color: rgb(53, 152, 219);">Получение данных DNS записей </span>

**Получаем список всех DNS зон**

```ruby
aws route53 list-hosted-zones-by-name
```

**Получаем список всех DNS записей**

```ruby
aws route53 list-resource-record-sets \
  --hosted-zone-id ZCOKAAJ9UMS0T \
  | jq '.ResourceRecordSets[] | .Name'
```

**Получаем детали нужной DNS записи**

```bash
aws route53 list-resource-record-sets \
  --hosted-zone-id ZCOKAAJ9UMS0T \
  | jq '.ResourceRecordSets[] | select (.Name == "xeonmp22.devops.rebrain.srwx.net.")'
```

```json
{
  "Name": "xeonmp22.devops.rebrain.srwx.net.",
  "Type": "A",
  "TTL": 200,
  "ResourceRecords": [
    {
      "Value": "95.217.219.153"
    }
  ]
}
```

##### <span style="color: rgb(53, 152, 219);">Удаление DNS записи</span>

**Создаём JSON файл, используемый для удаления DNS записи**

```json
sudo tee delete.json << 'EOF'
{
  "Comment": "delete this record",
  "Changes": [
    {
      "Action": "DELETE",
      "ResourceRecordSet": {
        "Name": "xeonmp22.devops.rebrain.srwx.net.",
        "Type": "A",
        "TTL": 200,
        "ResourceRecords": [
          {
            "Value": "95.217.219.153"
          }
        ]
      }
    }
  ]
}
EOF
```

<p class="callout warning">В файлах все значения записей должны строго совпадать ("TTL": 200) и т.п.</p>

**Применение удаления DNS записи**

```ruby
aws --region us-east-2 route53 change-resource-record-sets \
  --hosted-zone-id ZCOKAAJ9UMS0T \
  --change-batch file://delete.json
```

##### <span style="color: rgb(53, 152, 219);">Изменение DNS записи</span>

**Создаём JSON файл, используемый для изменения DNS записи**

```json
sudo tee update.json << 'EOF'
{
  "Comment": "update this record",
  "Changes": [
    {
      "Action": "UPSERT",
      "ResourceRecordSet": {
        "Name": "xeonmp22.devops.rebrain.srwx.net.",
        "Type": "A",
        "TTL": 400,
        "ResourceRecords": [
          {
            "Value": "158.160.49.98"
          }
        ]
      }
    }
  ]
}
EOF
```

<p class="callout warning">В файлах все значения записей должны строго совпадать ("TTL": 400) и т.п.</p>

**Применение изменения в DNS записи**

```ruby
aws --region us-east-2 route53 change-resource-record-sets \
  --hosted-zone-id ZCOKAAJ9UMS0T \
  --change-batch file://update.json
```

# Yandex Cloud

# Yandex Cloud CLI

##### <span style="color: rgb(53, 152, 219);">Установка Yandex CLI </span>

**[Установка CLI](https://yandex.cloud/ru/docs/cli/operations/install-cli#non-interactive) в /opt/yc** (<span class="token operator">~</span><span class="token operator">/</span><span class="token punctuation">.</span>bashrc Неизменён)

```ruby
curl https://storage.yandexcloud.net/yandexcloud-yc/install.sh | \
    bash -s -- -i /opt/yc -n
```

**Добавление конфига в <span class="token operator">~</span><span class="token operator">/</span><span class="token punctuation">.</span>bashrc**

```ruby
echo -e "\n# Yandex Cloud CLI\n\
if [ -f '/opt/yc/path.bash.inc' ]; then source '/opt/yc/path.bash.inc'; fi\n\
if [ -f '/opt/yc/completion.bash.inc' ]; then source '/opt/yc/completion.bash.inc'; fi\n\
" >> ~/.bashrc

# Применение ~/.bashrc
. ~/.bashrc
```

[**Service Key Activation**](https://yandex.cloud/ru/docs/cli/operations/authentication/service-account#auth-as-sa)

```ruby
yc config set service-account-key ~/.ssh/yc.service.key
yc config set folder-id <>
```

##### <span style="color: rgb(53, 152, 219);">Управление Yandex Cloud</span>

<table border="1" id="bkmrk-%D0%9E%D0%9F%D0%98%D0%A1%D0%90%D0%9D%D0%98%D0%95-%D0%9A%D0%9E%D0%9C%D0%90%D0%9D%D0%94%D0%90-c%D0%BF%D0%B8" style="border-collapse: collapse; width: 100%; height: 240.563px;"><colgroup> <col style="width: 40%;"></col> <col style="width: 60%;"></col> </colgroup><tbody><tr style="height: 29.7969px;"><td style="height: 29.7969px;">**Описание**</td><td style="height: 29.7969px;">**Команда**</td></tr><tr style="height: 30.1094px;"><td style="height: 30.1094px;">Cписок ВМ</td><td style="height: 30.1094px;">`yc compute instance list`</td></tr><tr style="height: 30.1094px;"><td style="height: 30.1094px;">Полные данные о ВМ mon-do27</td><td style="height: 30.1094px;">`yc compute instance get --full mon-do27`</td></tr><tr style="height: 30.1094px;"><td style="height: 30.1094px;">Список сервисных аккаунтов</td><td style="height: 30.1094px;">`yc iam service-account --folder-id b1gtv3uhmd1feqdajugp list`</td></tr><tr style="height: 30.1094px;"><td style="height: 30.1094px;">Список профилей</td><td style="height: 30.1094px;">`yc config profile list`</td></tr><tr style="height: 30.1094px;"><td style="height: 30.1094px;">Указать облако в профиле</td><td style="height: 30.1094px;">`yc config set cloud-id b1gm6imb36aoic2km8d0`</td></tr><tr style="height: 30.1094px;"><td style="height: 30.1094px;">Указать каталог в профиле</td><td style="height: 30.1094px;">`yc config set folder-id b1gtv3uhmd1feqdajugp`</td></tr><tr style="height: 30.1094px;"><td style="height: 30.1094px;">Запустить ВМ</td><td style="height: 30.1094px;">`yc compute instance start mon-do27`</td></tr></tbody></table>

# YC Provider Handbook

- **[YC Operations Guide](https://yandex.cloud/ru/docs/compute/operations/)**
- [Create **compute\_instance**](https://github.com/zhidkovd/terraform-yandex-computer/blob/master/main.tf) +[**Official.Guide**](https://yandex.cloud/ru/docs/terraform/resources/compute_instance)
- [Add SSH Key](https://yandex.cloud/ru/docs/organization/operations/add-ssh) / [Service Key](https://yandex.cloud/ru/docs/terraform/tf-ref/overview#example-of-shared-credentials-usage)
- [Data Sources](https://yandex.cloud/ru/docs/tutorials/infrastructure-management/terraform-data-sources#prepare-plan)
- [Labels](https://yandex.cloud/ru/docs/resource-manager/operations/manage-labels)