Skip to content

Instantly share code, notes, and snippets.

@midN
Last active Dec 30, 2018
Embed
What would you like to do?
VPN:
Type: AWS::SSM::Association
Properties:
AssociationName: "vpn_sync"
Name: 'AWS-RunShellScript'
ScheduleExpression: "cron(0 0 0/1 1/1 * ? *)"
Parameters:
commands:
- !Sub |
#!/bin/bash
reload=false
aws s3 sync s3://your_bucket/vpn/ipsec.conf /tmp/vpn/ipsec.conf
diff /etc/ipsec.conf /tmp/vpn/ipsec.conf
if [ $? -ne 0 ]
then
reload=true
fi
diff /etc/ipsec.secrets /tmp/vpn/ipsec.secrets
if [ $? -ne 0 ]
then
reload=true
fi
if [ "$reload" = true ]
then
mv /tmp/vpn/ipsec.conf /etc/ipsec.conf
mv /tmp/vpn/ipsec.secrets /etc/ipsec.secrets
ipsec reload
if [ $? -ne 0 ]
then
service strongswan restart
fi
fi
Targets:
- Key: tag:Name
Values: ['vpn']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment