Feature request: an org-formation conditional function
Feature Request
Org-formation has functions. I would like a conditional function, an !If function...
Why
Because I wan to conditionally set one property in my cloudformation resource..
cloudtrail-trail.yaml snippet:
Parameters:
EncryptTrail:
Type: String
AllowedValues: ["true", "false"]
Default: "false"
Conditions:
IsEncryptTrail: !Equals [EncryptTrail, "true"]
CloudTrail:
Type: AWS::CloudTrail::Trail
Properties:
S3BucketName: !Ref CloudTrailBucket
IsLogging: true
IncludeGlobalServiceEvents: true
IsMultiRegionTrail: true
EnableLogFileValidation: true
CloudWatchLogsLogGroupArn: !Ref CloudWatchLogsLogGroupArn
CloudWatchLogsRoleArn: !Ref CloudWatchLogsRoleArn
KMSKeyId: !If [IsEncryptTrail, !Ref Key, !Ref 'AWS::NoValue']
Example
_tasks.yaml snippet:
Cloudtrail:
Type: update-stacks
StackName: 'cloudtrail'
..
..
DefaultOrganizationBinding:
Account: '*'
Parameters:
EncryptTrail: !If [!Ref LogCentralAccount, !Ref CurrentAccount, "true", "false"]
Expected result: Deploy this cloudtrail stack to all accounts. When this stack is deployed to the LogCentralAccount account pass in "true" for EncryptTrail, otherwise pass in "false"
I think this would be a great addition. I would, however, prefer to keep the syntax compatible with CloudFormation see here.
this means that your 1st example would work, but your second example would require another function. something like Fn::Equals. so: !If [!Equals[ !Ref LogCentralAccount, !Ref CurrentAccount], "true", "false"]
does that make sense?