问题
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