rgd*_*rgd 5 amazon-web-services aws-cloudformation
我有 cloudformation 模板,其中我有一个从上一步传递的参数,其值是这样的
"test1.example.org"
"example.org"
"org"
Run Code Online (Sandbox Code Playgroud)
现在我想基本上从该参数中删除 .org 部分并获取
test1.example
example
Run Code Online (Sandbox Code Playgroud)
也可以有很多子域,例如
test1.test2.test3.test4.example.org
Run Code Online (Sandbox Code Playgroud)
我只需要从最后删除 .org
geo*_*all 13
有了警告,您就可以实现您想要的 - 假设它.org只会出现在字符串的末尾。
这是一个完整的模板 (test.cfn.yaml),显示了此方法的工作原理:
AWSTemplateFormatVersion: 2010-09-09
Parameters:
Input:
Type: String
Resources:
DummyBucket:
Type: AWS::S3::Bucket
Outputs:
TheOutput:
Value: !Join [ '', !Split [ '.org', !Ref Input ] ]
Run Code Online (Sandbox Code Playgroud)
您可以通过运行以下命令使用 aws cli 进行测试:
aws cloudformation deploy --template-file test.cfn.yaml --stack-name test1 --parameter-overrides Input=apples.bananas.org
此堆栈的输出将包含apples.bananas.
在您的脚本中,您可以根据!Join [ '', !Split [ '.org', !Ref Input ] ]需要删除字符串,将Input替换为您需要更改的值。
请注意,DummyBucket堆栈中有一个,因为您需要至少有一个 cloudformation 资源来部署脚本。
| 归档时间: |
|
| 查看次数: |
7652 次 |
| 最近记录: |