Uppercase and lowercase substitution with Fn::Sub

好久不见. 提交于 2020-07-23 08:09:29

问题


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

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

So what I need is something like this:

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

回答1:


This can be done using Fn::Transform.

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

and

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



来源:https://stackoverflow.com/questions/58604704/uppercase-and-lowercase-substitution-with-fnsub

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!