更新时间:2023-11-11 22:21:58
我认为您的做法正确。我将对传递3个私有替代变量的方式进行一些修改,例如(在模板中经常使用):
I think you're on the right path. I would just modify a bit the way you pass the 3 "private" substitute variables, for something like this (which I use quite often in my templates):
UserData:
Fn::Base64:
Fn::Sub:
- |
CONF="/etc/zookeeper/conf.dist/zoo.cfg"
cp $CONF /etc/zookeeper/conf.dist/zoo.cfg.bak-$(date +%s)
echo "# Zookeeper configuration for Talentreef" > "$CONF"
cat <<EOT >> "$CONF"
maxClientCnxns=50
tickTime=2000
initLimit=10
syncLimit=5
EOT
echo "server.1=${Private1}:2888:3888" >> $CONF
echo "server.2=${Private2}:2888:3888" >> $CONF
echo "server.3=${Private3}:2888:3888" >> $CONF
service zookeeper-server init --myid=$NODE_ID
chkconfig zookeeper-server on
- Private1: !GetAtt EC2NI2E8ES.PrimaryPrivateIpAddress
Private2: !GetAtt EC2NI2PFST.PrimaryPrivateIpAddress
Private3: !GetAtt EC2NI54B66.PrimaryPrivateIpAddress
因此没有括号 {}
并且没有逗号,
So no brackets {}
and no commas ,