Vin*_*eth 2 amazon-ec2 amazon-web-services aws-cloudformation
我在参数部分有这个,
Parameters:
PlatformSelect:
Description: Cockpit platform Select.
Type: String
Default: qa-1
AllowedValues: [qa-1, qa-2, staging, production]
Run Code Online (Sandbox Code Playgroud)
我需要在我的 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+
Run Code Online (Sandbox Code Playgroud)
这是行不通的。不确定我引用它的方式是错误的!!
我应该在它之前使用诸如 '${AWS::Parameters:PlatformSelect}' 之类的东西吗?
Mai*_*KaY 10
你有什么理由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}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8666 次 |
| 最近记录: |