用Fn :: Sub进行大写和小写替换 [英] Uppercase and lowercase substitution with Fn::Sub

查看:93
本文介绍了用Fn :: Sub进行大写和小写替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个参数化的S3路径(每个环境不同),看起来像下面的示例:

I have a parameterized S3 path (different per environment) that looks something like this example:

Environment:
- Name: 'Environment'
  Value: !Ref Environment
- Name: SERVICE_LOGIN_KEYSTORE
  Value: !Sub s3://${Environment}-productsuite-cert/productsuite-pipelinename-${Environment}.jks

问题是实际路径的第一个${Environment}小写,第二个大写,例如:

The issue is that the actual path has the first ${Environment} in lowercase while the second in uppercase, e.g:

s3://qa-productsuite-cert/productsuite-pipelinename-QA.jks
s3://pr-productsuite-cert/productsuite-pipelinename-PR.jks

所以我需要的是这样的

!Sub s3://${Environment:Uppercase}-productsuite-cert/productsuite-pipelinename-${Environment:Lowecase}.jks

推荐答案

这可以使用Fn :: Transform完成.

This can be done using Fn::Transform.

请参阅: https://github.com/awslabs/aws-cloudformation-templates/blob/master/aws/services/CloudFormation/MacrosExamples/StringFunctions/string_example.yaml

https://docs.aws .amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-transform.html

这篇关于用Fn :: Sub进行大写和小写替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆