## OpenVPN route updater tool
This tool has been introduced to get rid of proxy server and custom dns options in OpenVPN. It takes Route53 records and or just plain text hostnames, resolves them and add resulting ip address set to routes config for an OpenVPN group.

### Command line arguments

| argument      | type          | default                               | description                                                                               |
| ------------- |:-------------:| :------------------------------------ | ---------------------------------------                                                   |
| verbose       | boolean flag  | false                                 | Enable verbose logging                                                                    |
| dryrun        | boolean flag  | false                                 | Do not apply proposed changes                                                             |
| configName    | string        | "config.yaml"                         | Path to the file with the configuration                                                   |
| sacli         | string        | "/usr/local/openvpn_as/scripts/sacli" | Path to OpenVPN sacli                                                                     |
| cwLogGroup    | string        | ""                                    | CloudWatch group. If set to empty string, cloudwatch logging is disabled                  |
| cwAwsProfile  | string        | ""                                    | AWS Profile used to connect to CloudWatch. If empty, default one from config will be used |

### Config example
```yaml
# List of groups, each group contains the list of dns record which will be resolved and added as routes option in OpenVPN
groups:
  - groupName: "OpenVPN example" # Group name in OpenVPN
    # allowedRecordTypes only accepts "A" record types right now (possibly add other values later)
    allowedRecordTypes:
      - "A"
    # singleRecords - list DNS records (A only) to resolve.
    singleRecords:
      - "example.notourdomain.com"
    # List of route53 zones records from which will be also resolved
    zones:
      - zoneName: "our-dns.zone." # Zone name
        # Regex record filter. It allows you to select limited list of dns records from the zone.
        recordFilters:
          - ".*"
      - zoneName: "our-dns-second.zone."
        # Since zones can be managed by different aws accounts, each zone allows you to set custom awsProfile to work with it
        # If it is skipped, defaultAwsProfile (below) is used.
        awsProfile: "some-profile-2"
        recordFilters:
          - "^jenkins"
          - "^artifacts"
          - "^octopus"
# adminGroups - gathered settings from all previously mentioned groups will be applied to selected admin groups
adminGroups:
  - "Admin group"
# defaultAwsProfile is used for zones which haven't specified custom awsProfile settings
# it also used for CloudWatch profile if command line argument for cwLogGroup was set and cwAwsProfile was not
defaultAwsProfile: "gdb-delphi-dev"
```

### Systemd units examples for cron jobs
routeupdater.service
```
[Unit]
Description=Runs routeupdater to update OpenVPN groups settings
Wants=routeupdater.timer

[Service]
ExecStart=/home/openvpnas/routeupdater -cwLogGroup /openvpn-route-updater -cwAwsProfile gdb-infra-dev >/var/log/routeupdater/routeupdater.log 2>&1
WorkingDirectory=/home/openvpnas

[Install]
WantedBy=multi-user.target
```
routeupdater.timer
```
[Unit]
Description=Run routeupdater on hourly basis basis
Requires=routeupdater.service

[Timer]
OnCalendar=*:00
Persistent=true
Unit=routeupdater.service

[Install]
WantedBy=timers.target
```
