我把这个放在参数部分,
Parameters:
PlatformSelect:
Description: Cockpit platform Select.
Type: String
Default: qa-1
AllowedValues: [qa-1, qa-2, staging, production]我需要在我的UserData中引用这个值。我在两者之间使用Mappings。
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}”之类的内容?
发布于 2017-06-27 16:40:35
你在两者之间使用Mapping有什么原因吗?
您可以很容易地使用!Sub。
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}发布于 2017-06-27 17:00:14
Fn::Join和Ref的组合怎么样?
UserData:
Fn::Base64:
Fn::Join:
- ''
- - '#!/bin/bash\n'
- 'print: echo'
- !Ref 'PlatformSelect'
- '>>test.txt\n'https://stackoverflow.com/questions/44775534
复制相似问题