Update Cloudformation template (#1490)
- Improve formatting and code organization.
This commit is contained in:
parent
5adab8c444
commit
230b628e28
@ -25,25 +25,25 @@
|
|||||||
"Mappings": {
|
"Mappings": {
|
||||||
"OS": {
|
"OS": {
|
||||||
"Ubuntu2004": {
|
"Ubuntu2004": {
|
||||||
"HelperInstallationCommands": "export DEBIAN_FRONTEND=noninteractive\napt-get -yq update\napt-get -yq install python3-pip zip awscli\npython3 -m pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz\n"
|
"HelperInstallationCommands": "export DEBIAN_FRONTEND=noninteractive\napt-get -yq update\napt-get -yq install python3-pip zip awscli\npython3 -m pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz"
|
||||||
},
|
},
|
||||||
"Ubuntu2204": {
|
"Ubuntu2204": {
|
||||||
"HelperInstallationCommands": "export DEBIAN_FRONTEND=noninteractive\napt-get -yq update\napt-get -yq install python3-pip zip awscli\npython3 -m pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz\n"
|
"HelperInstallationCommands": "export DEBIAN_FRONTEND=noninteractive\napt-get -yq update\napt-get -yq install python3-pip zip awscli\npython3 -m pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz"
|
||||||
},
|
},
|
||||||
"Debian10": {
|
"Debian10": {
|
||||||
"HelperInstallationCommands": "export DEBIAN_FRONTEND=noninteractive\napt-get -yq update\napt-get -yq install python3-pip zip\npython3 -m pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz\n"
|
"HelperInstallationCommands": "export DEBIAN_FRONTEND=noninteractive\napt-get -yq update\napt-get -yq install python3-pip zip\npython3 -m pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz"
|
||||||
},
|
},
|
||||||
"Debian11": {
|
"Debian11": {
|
||||||
"HelperInstallationCommands": "export DEBIAN_FRONTEND=noninteractive\napt-get -yq update\napt-get -yq install python3-pip zip\npython3 -m pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz\n"
|
"HelperInstallationCommands": "export DEBIAN_FRONTEND=noninteractive\napt-get -yq update\napt-get -yq install python3-pip zip\npython3 -m pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz"
|
||||||
},
|
},
|
||||||
"Debian12": {
|
"Debian12": {
|
||||||
"HelperInstallationCommands": "export DEBIAN_FRONTEND=noninteractive\nrm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED\napt-get -yq update\napt-get -yq install python3-pip zip\npython3 -m pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz\n"
|
"HelperInstallationCommands": "export DEBIAN_FRONTEND=noninteractive\nrm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED\napt-get -yq update\napt-get -yq install python3-pip zip\npython3 -m pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz"
|
||||||
},
|
},
|
||||||
"CentOS7": {
|
"CentOS7": {
|
||||||
"HelperInstallationCommands": "yum -y install python3 wget zip awscli\npython3 -m pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz\n"
|
"HelperInstallationCommands": "yum -y install python3 wget zip awscli\npython3 -m pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz"
|
||||||
},
|
},
|
||||||
"AmazonLinux2": {
|
"AmazonLinux2": {
|
||||||
"HelperInstallationCommands": "export PATH=\"$PATH:/opt/aws/bin\"\n"
|
"HelperInstallationCommands": "export PATH=\"$PATH:/opt/aws/bin\""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -201,21 +201,11 @@
|
|||||||
"UserData": {
|
"UserData": {
|
||||||
"Fn::Base64": {
|
"Fn::Base64": {
|
||||||
"Fn::Join": [
|
"Fn::Join": [
|
||||||
"",
|
"\n",
|
||||||
[
|
[
|
||||||
"#!/bin/bash -xe\n",
|
"#!/bin/bash -xe",
|
||||||
"trap 'cfn-signal -e 1 ",
|
{ "Fn::Sub": "trap 'cfn-signal -e 1 --resource VpnInstance --stack ${AWS::StackName} --region ${AWS::Region}' ERR" },
|
||||||
" --stack ",
|
"sleep 60",
|
||||||
{
|
|
||||||
"Ref": "AWS::StackName"
|
|
||||||
},
|
|
||||||
" --resource VpnInstance ",
|
|
||||||
" --region ",
|
|
||||||
{
|
|
||||||
"Ref": "AWS::Region"
|
|
||||||
},
|
|
||||||
"' ERR\n",
|
|
||||||
"sleep 60\n",
|
|
||||||
{
|
{
|
||||||
"Fn::FindInMap": [
|
"Fn::FindInMap": [
|
||||||
"OS",
|
"OS",
|
||||||
@ -225,46 +215,16 @@
|
|||||||
"HelperInstallationCommands"
|
"HelperInstallationCommands"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"export VPN_IPSEC_PSK='",
|
{ "Fn::Sub": "export VPN_IPSEC_PSK='${VpnIpsecPsk}'" },
|
||||||
{
|
{ "Fn::Sub": "export VPN_USER='${VpnUser}'" },
|
||||||
"Ref": "VpnIpsecPsk"
|
{ "Fn::Sub": "export VPN_PASSWORD='${VpnPassword}'" },
|
||||||
},
|
"wget -t 3 -T 30 -nv -O vpn.sh https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/vpnsetup.sh",
|
||||||
"'\n",
|
"sh vpn.sh",
|
||||||
"export VPN_USER='",
|
"mkdir /root/profiles",
|
||||||
{
|
"cp /root/vpnclient* /root/profiles",
|
||||||
"Ref": "VpnUser"
|
{ "Fn::Sub": "cd /root/ && zip -er --password '${VpnPassword}' profiles.zip ./profiles" },
|
||||||
},
|
{ "Fn::Sub": "aws s3 cp /root/profiles.zip s3://${Ikev2S3Bucket}/" },
|
||||||
"'\n",
|
{ "Fn::Sub": "cfn-signal -e 0 --stack ${AWS::StackName} --resource VpnInstance --region ${AWS::Region}" }
|
||||||
"export VPN_PASSWORD='",
|
|
||||||
{
|
|
||||||
"Ref": "VpnPassword"
|
|
||||||
},
|
|
||||||
"'\n",
|
|
||||||
"wget -t 3 -T 30 -nv -O vpn.sh https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/vpnsetup.sh\n",
|
|
||||||
"sh vpn.sh\n",
|
|
||||||
"mkdir /root/profiles\n",
|
|
||||||
"cp /root/vpnclient* /root/profiles\n",
|
|
||||||
"cd /root/ && zip -er --password '",
|
|
||||||
{
|
|
||||||
"Ref": "VpnPassword"
|
|
||||||
},
|
|
||||||
"' profiles.zip ./profiles\n",
|
|
||||||
"aws s3 cp /root/profiles.zip s3://",
|
|
||||||
{
|
|
||||||
"Ref": "Ikev2S3Bucket"
|
|
||||||
},
|
|
||||||
"/\n",
|
|
||||||
"cfn-signal -e 0 ",
|
|
||||||
" --stack ",
|
|
||||||
{
|
|
||||||
"Ref": "AWS::StackName"
|
|
||||||
},
|
|
||||||
" --resource VpnInstance ",
|
|
||||||
" --region ",
|
|
||||||
{
|
|
||||||
"Ref": "AWS::Region"
|
|
||||||
},
|
|
||||||
"\n"
|
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user