0

私は、パラメータセクションの下にこれを持って、UserDataの中の参照パラメータ値

Parameters: 
    PlatformSelect: 
    Description: Cockpit platform Select. 
    Type: String 
    Default: qa-1 
    AllowedValues: [qa-1, qa-2, staging, production] 

は、私は私のUserDataの中で、この値を参照する必要があります。私はその間にマッピングを使用しています。

Mappings: 
    bootstrap: 
    ubuntu: 
     print: echo ${PlatformSelect} >>test.txt 

Resources: 
    EC2Instance: 
    Type: AWS::EC2::Instance 
    Properties: 
     InstanceType: !Ref ‘InstanceType’ 
     KeyName: !Ref ‘KeyName’ 
     Tags: 
     - Key: Name 
     Value: Test 
     UserData: 
     Fn::Base64: 
      Fn::Join: 
      - ‘’ 
      - - | 
       #!/bin/bash 
      - Fn::FindInMap: 
       - bootstrap 
       - ubuntu 
       - print 
      - |2+ 

これは機能しません。私がそれを参照する方法が最初の場所で間違っているかどうかわからない!!

「$ {AWS :: Parameters:PlatformSelect}」のようなものを使用する必要がありますか?

答えて

1

Mappingの間に理由がありますか?

あなたは簡単にFn::JoinRef

UserData: 
     Fn::Base64: 
      Fn::Join: 
      - '' 
      - - '#!/bin/bash\n' 
       - 'print: echo' 
       - !Ref 'PlatformSelect' 
       - '>>test.txt\n' 
+0

ない特定の理由の組み合わせについてどう – Vineeth

1

代わり

Resources: 
    EC2Instance: 
    Type: AWS::EC2::Instance 
    Properties: 
     InstanceType: !Ref InstanceType 
     KeyName: !Ref KeyName 
     Tags: 
     - Key: Name 
      Value: Test 
     UserData: 
     Fn::Base64: 
      !Sub | 
      #!/bin/bash 
      ${PlatformSelect} 
!Subを使用することができます!私は自分が持っていた既存のCFスクリプトで夢中になりました。 これは機能します!ありがとう(y)
+0

ありがとう@エスラム! – Vineeth

関連する問題