forked from johnbrandborg/aws-clientvpn-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrenew.sh
executable file
·46 lines (35 loc) · 1.37 KB
/
renew.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
set -ex
source variables.cfg
./easy-rsa/easyrsa3/easyrsa renew server $SERVERNAME nopass
aws acm import-certificate \
--certificate=fileb://./pki/issued/$SERVERNAME.crt \
--private-key=fileb://./pki/private/$SERVERNAME.key \
--certificate-chain=fileb://./pki/ca.crt
aws ssm put-parameter \
--name="/clientvpn/$CLIENTNAME.crt" \
--description="Compressed Client Certificate for AWS Client VPN" \
--value=file://./pki/issued/$CLIENTNAME.crt \
--type="SecureString" \
--tier="Advanced" \
--overwrite > /dev/null
aws ssm put-parameter \
--name="/clientvpn/$CLIENTNAME.key" \
--description="Compressed Client Key for AWS Client VPN" \
--value=file://./pki/private/$CLIENTNAME.key \
--type="SecureString" \
--tier="Advanced" \
--overwrite > /dev/null
echo "New server certificate generated."
ENDPOINTID=$(aws ec2 describe-client-vpn-endpoints \
--output=text \
--filters="Name=tag:Name,Values=$SERVERNAME" \
--query='ClientVpnEndpoints[].ClientVpnEndpointId')
QUERY="'CertificateSummaryList[?DomainName==\`$SERVERNAME\`].CertificateArn'"
SERVERCERTARN=$(eval aws acm list-certificates \
--output=text \
--query=$QUERY)
aws ec2 modify-client-vpn-endpoint
--client-vpn-endpoint-id="$ENDPOINTID"
--server-certificate-arn="$SERVERCERTARN"
echo "Updated VPN to use new server certificate."