I would like to populate a value in cloudformation depending on input parameter. I want to assign Name as either test-svc.abc.com or svc.abc.com depending on whether environment name is prod or not. If the environnment name is prod then the value should be svc.abc.com otherwise it should always be {env-name}-svc.abc.com.
I have the following expression:
Name: !Join [ '-', [ !Ref EnvironmentName, !Ref 'HostedZoneName' ] ]
In the above expression, HostedZoneName will be passed as svc.abc.com and the value of EnvironmentName could be test, release or prod. So the conditions should be evaluated as:
Inputs: HostedZoneName -> svc.abc.com, EnvironmentName -> test
Output: test-svc.abc.com
Inputs: HostedZoneName -> svc.abc.com, EnvironmentName -> release
Output: release-svc.abc.com
Inputs: HostedZoneName -> svc.abc.com, EnvironmentName -> 1234567
Output: 1234567-svc.abc.com
Inputs: HostedZoneName -> svc.abc.com, EnvironmentName -> prod
Output: svc.abc.com
It's basically ternary operator.
Name = EnvironmentName.equals("prod") ? HostedZoneName : EnvironmentName + "-" + HostedZoneName
Struggling with if else condition in CloudFormation.
Aucun commentaire:
Enregistrer un commentaire