无法从地图中的查找中获取值
UserData: !Base64
'Fn::Join':
- |+
- - '#!/bin/bash'
- !Sub sudo -u $SPLUNK_USER $SPLUNK_BIN init shcluster-config
-mgmt_uri https://$LOCALIP:8089 -replication_port 8090 -replication_factor !FindInMap[SplunkConfig, shcluster-replication-factor, num]
-conf_deploy_fetch_url https://${SplunkSHCDeployer.PrivateIp}:8089 -shcluster_label SplunkSHC
-secret ${SplunkClusterSecret} -auth admin:${SplunkAdminPassword}
答案 0 :(得分:1)
使用Sub
而不是Join
会更好。
对于!FindInMap[SplunkConfig, shcluster-replication-factor, num]
,您需要将其指定为Sub
的参数。
您可能会遇到类似这样的事情:
UserData: !Base64
'Fn::Sub':
- |
Content-Type: multipart/mixed; boundary="==BOUNDARY=="
MIME-Version: 1.0
--==BOUNDARY==
Content-Type: text/x-shellscript; charset="us-ascii"
#!/bin/bash
sudo -u $SPLUNK_USER $SPLUNK_BIN init shcluster-config -mgmt_uri https://$LOCALIP:8089 -replication_port 8090 -replication_factor ${ReplicationFactor} -conf_deploy_fetch_url https://${SplunkSHCDeployer.PrivateIp}:8089 -shcluster_label SplunkSHC -secret ${SplunkClusterSecret} -auth admin:${SplunkAdminPassword}
--==BOUNDARY==--
- ReplicationFactor: !FindInMap[SplunkConfig, shcluster-replication-factor, num]
答案 1 :(得分:0)
UserData: !Base64
'Fn::Join':
- |+
- - '#!/bin/bash'
- !Join
- - export $a=
- !FindInMap[SplunkConfig, shcluster-replication-factor, num]
- !Sub sudo -u $SPLUNK_USER $SPLUNK_BIN init shcluster-config
-mgmt_uri https://$LOCALIP:8089 -replication_port 8090 -replication_factor $a
-conf_deploy_fetch_url https://${SplunkSHCDeployer.PrivateIp}:8089 -shcluster_label SplunkSHC
-secret ${SplunkClusterSecret} -auth admin:${SplunkAdminPassword}
对我有用。