Skip to content

Commit

Permalink
Moving create vpn config to script
Browse files Browse the repository at this point in the history
  • Loading branch information
ben851 committed Sep 12, 2024
1 parent 48c14e3 commit 13b8c01
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 88 deletions.
14 changes: 1 addition & 13 deletions .github/workflows/helmfile_production_apply.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,7 @@ jobs:

- name: Retrieve VPN Config
run: |
git clone https://github.com/cds-snc/notification-terraform.git /var/tmp/notification-terraform
cd /var/tmp/notification-terraform/env/production/eks
export INFRASTRUCTURE_VERSION=$(cat ../../../.github/workflows/infrastructure_version.txt)
ENDPOINT_ID=$(terragrunt output --raw gha_vpn_id)
CERT=$(terragrunt output --raw gha_vpn_certificate)
KEY=$(terragrunt output --raw gha_vpn_key)
aws ec2 export-client-vpn-client-configuration --client-vpn-endpoint-id $ENDPOINT_ID --output text > /var/tmp/production.ovpn
echo "<cert>
$CERT
</cert>" >> /var/tmp/production.ovpn
echo "<key>
$KEY
</key>" >> /var/tmp/production.ovpn
scripts/createVPNConfig.sh production 2> /dev/null
- name: Connect to VPN
uses: "kota65535/github-openvpn-connect-action@cd2ed8a90cc7b060dc4e001143e811b5f7ea0af5" # v3.1.0
Expand Down
14 changes: 1 addition & 13 deletions .github/workflows/helmfile_production_plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,7 @@ jobs:

- name: Retrieve VPN Config
run: |
git clone https://github.com/cds-snc/notification-terraform.git /var/tmp/notification-terraform
cd /var/tmp/notification-terraform/env/production/eks
export INFRASTRUCTURE_VERSION=$(cat ../../../.github/workflows/infrastructure_version.txt)
ENDPOINT_ID=$(terragrunt output --raw gha_vpn_id)
CERT=$(terragrunt output --raw gha_vpn_certificate)
KEY=$(terragrunt output --raw gha_vpn_key)
aws ec2 export-client-vpn-client-configuration --client-vpn-endpoint-id $ENDPOINT_ID --output text > /var/tmp/production.ovpn
echo "<cert>
$CERT
</cert>" >> /var/tmp/production.ovpn
echo "<key>
$KEY
</key>" >> /var/tmp/production.ovpn
scripts/createVPNConfig.sh production 2> /dev/null
- name: Connect to VPN
uses: "kota65535/github-openvpn-connect-action@cd2ed8a90cc7b060dc4e001143e811b5f7ea0af5" # v3.1.0
Expand Down
13 changes: 1 addition & 12 deletions .github/workflows/helmfile_staging_apply.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,7 @@ jobs:

- name: Retrieve VPN Config
run: |
git clone https://github.com/cds-snc/notification-terraform.git /var/tmp/notification-terraform
cd /var/tmp/notification-terraform/env/staging/eks
ENDPOINT_ID=$(terragrunt output --raw gha_vpn_id)
CERT=$(terragrunt output --raw gha_vpn_certificate)
KEY=$(terragrunt output --raw gha_vpn_key)
aws ec2 export-client-vpn-client-configuration --client-vpn-endpoint-id $ENDPOINT_ID --output text > /var/tmp/staging.ovpn
echo "<cert>
$CERT
</cert>" >> /var/tmp/staging.ovpn
echo "<key>
$KEY
</key>" >> /var/tmp/staging.ovpn
scripts/createVPNConfig.sh staging 2> /dev/null
- name: Connect to VPN
uses: "kota65535/github-openvpn-connect-action@cd2ed8a90cc7b060dc4e001143e811b5f7ea0af5" # v3.1.0
Expand Down
13 changes: 1 addition & 12 deletions .github/workflows/helmfile_staging_apply_specific_app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,7 @@ jobs:

- name: Retrieve VPN Config
run: |
git clone https://github.com/cds-snc/notification-terraform.git /var/tmp/notification-terraform
cd /var/tmp/notification-terraform/env/staging/eks
ENDPOINT_ID=$(terragrunt output --raw gha_vpn_id)
CERT=$(terragrunt output --raw gha_vpn_certificate)
KEY=$(terragrunt output --raw gha_vpn_key)
aws ec2 export-client-vpn-client-configuration --client-vpn-endpoint-id $ENDPOINT_ID --output text > /var/tmp/staging.ovpn
echo "<cert>
$CERT
</cert>" >> /var/tmp/staging.ovpn
echo "<key>
$KEY
</key>" >> /var/tmp/staging.ovpn
scripts/createVPNConfig.sh staging 2> /dev/null
- name: Connect to VPN
uses: "kota65535/github-openvpn-connect-action@cd2ed8a90cc7b060dc4e001143e811b5f7ea0af5" # v3.1.0
Expand Down
13 changes: 1 addition & 12 deletions .github/workflows/helmfile_staging_plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,7 @@ jobs:

- name: Retrieve VPN Config
run: |
git clone https://github.com/cds-snc/notification-terraform.git /var/tmp/notification-terraform
cd /var/tmp/notification-terraform/env/staging/eks
ENDPOINT_ID=$(terragrunt output --raw gha_vpn_id)
CERT=$(terragrunt output --raw gha_vpn_certificate)
KEY=$(terragrunt output --raw gha_vpn_key)
aws ec2 export-client-vpn-client-configuration --client-vpn-endpoint-id $ENDPOINT_ID --output text > /var/tmp/staging.ovpn
echo "<cert>
$CERT
</cert>" >> /var/tmp/staging.ovpn
echo "<key>
$KEY
</key>" >> /var/tmp/staging.ovpn
scripts/createVPNConfig.sh staging 2> /dev/null
- name: Connect to VPN
uses: "kota65535/github-openvpn-connect-action@cd2ed8a90cc7b060dc4e001143e811b5f7ea0af5" # v3.1.0
Expand Down
14 changes: 1 addition & 13 deletions .github/workflows/merge_to_main_production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,7 @@ jobs:

- name: Retrieve VPN Config
run: |
git clone https://github.com/cds-snc/notification-terraform.git /var/tmp/notification-terraform
cd /var/tmp/notification-terraform/env/production/eks
export INFRASTRUCTURE_VERSION=$(cat ../../../.github/workflows/infrastructure_version.txt)
ENDPOINT_ID=$(terragrunt output --raw gha_vpn_id)
CERT=$(terragrunt output --raw gha_vpn_certificate)
KEY=$(terragrunt output --raw gha_vpn_key)
aws ec2 export-client-vpn-client-configuration --client-vpn-endpoint-id $ENDPOINT_ID --output text > /var/tmp/production.ovpn
echo "<cert>
$CERT
</cert>" >> /var/tmp/production.ovpn
echo "<key>
$KEY
</key>" >> /var/tmp/production.ovpn
scripts/createVPNConfig.sh production 2> /dev/null
- name: Connect to VPN
uses: "kota65535/github-openvpn-connect-action@cd2ed8a90cc7b060dc4e001143e811b5f7ea0af5" # v3.1.0
Expand Down
14 changes: 1 addition & 13 deletions .github/workflows/merge_to_main_staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,7 @@ jobs:

- name: Retrieve VPN Config
run: |
git clone https://github.com/cds-snc/notification-terraform.git /var/tmp/notification-terraform
cd /var/tmp/notification-terraform/env/staging/eks
ENDPOINT_ID=$(terragrunt output --raw gha_vpn_id)
CERT=$(terragrunt output --raw gha_vpn_certificate)
KEY=$(terragrunt output --raw gha_vpn_key)
aws ec2 export-client-vpn-client-configuration --client-vpn-endpoint-id $ENDPOINT_ID --output text > /var/tmp/staging.ovpn
echo "<cert>
$CERT
</cert>" >> /var/tmp/staging.ovpn
echo "<key>
$KEY
</key>" >> /var/tmp/staging.ovpn
scripts/createVPNConfig.sh staging 2> /dev/null
- name: Connect to VPN
uses: "kota65535/github-openvpn-connect-action@cd2ed8a90cc7b060dc4e001143e811b5f7ea0af5" # v3.1.0
with:
Expand Down
17 changes: 17 additions & 0 deletions scripts/createVPNConfig.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
# This script will create a VPN configuration file for the specified environment
# Usage: ./createVPNConfig.sh <environment>
# Example: ./createVPNConfig.sh staging
ENVIRONMENT=$1
git clone https://github.com/cds-snc/notification-terraform.git /var/tmp/notification-terraform
cd /var/tmp/notification-terraform/env/$ENVIRONMENT/eks
ENDPOINT_ID=$(terragrunt output --raw gha_vpn_id)
CERT=$(terragrunt output --raw gha_vpn_certificate)
KEY=$(terragrunt output --raw gha_vpn_key)
aws ec2 export-client-vpn-client-configuration --client-vpn-endpoint-id $ENDPOINT_ID --output text > /var/tmp/$ENVIRONMENT.ovpn
echo "<cert>
$CERT
</cert>" >> /var/tmp/$ENVIRONMENT.ovpn
echo "<key>
$KEY
</key>" >> /var/tmp/$ENVIRONMENT.ovpn

0 comments on commit 13b8c01

Please sign in to comment.