渡っCFN-INITを使用して私はそのようなように、インスタンスのリソースを持っている:AWS CloudFormation - 共有ユーザーデータスクリプトがEC2s
testservice:
Type: 'AWS::EC2::Instance'
Metadata:
AWS::CloudFormation::Init:
configSets:
serviceConfigSet:
- serviceConfig
serviceConfig:
packages:
yum:
salt-minion: []
commands:
hostnameConfig:
command: hostname test-service-1.0
services:
sysvinit:
salt-minion:
enabled: 'true'
ensureRunning: 'true'
Properties:
ImageId: !Ref BaseServiceAmi
KeyName: test_ssh_key
SubnetId: !Ref ServiceSubnetId
UserData:
'Fn::Base64':
'Fn::Sub': |
#!/bin/bash
yum update -y
yum install -y aws-cfn-bootstrap
/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource testservice --configsets serviceConfigSet --region ${AWS::Region}
しかし、私はパラメータにUserData
スクリプトを移動し、複数のインスタンス間でそれを再利用したいですリソース。これは簡単なはずですが、ユーザーデータスクリプト内で現在のリソースの名前を取得する方法は見つけられません(この部分に明示的に設定しました:--resource testservice
)。
私はそれを一般化することができるので、私はユーザーデータのスクリプトの内部から参照を介してリソース名を取得する方法はありますか?擬似パラメータリストには表示されません。