#-----------------------------------------------------------------------------------------------------------------------
#   Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
#
#  Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
#  with the License. A copy of the License is located at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
#  OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
#  and limitations under the License.
#-----------------------------------------------------------------------------------------------------------------------
## cdf-cdf-core-parent transformer

## include mappings
-   command: update
    path: Mappings.SourceCode
    value:
      General:
        S3Bucket: "%%BUCKET_NAME%%"
        KeyPrefix: "%%SOLUTION_NAME%%/%%VERSION%%"
        TemplateBucket: "%%TEMPLATE_BUCKET_NAME%%"

# Transform all CodeUri's
-   command: update
    path: Resources.DeploymentHelper.Properties.TemplateURL
    value: !Sub
      - "https://s3.amazonaws.com/${S3Bucket}/${KeyPrefix}/cfn-deployment-helper.template"
      - S3Bucket: !FindInMap ["SourceCode", "General", "TemplateBucket"]
        KeyPrefix: !FindInMap ["SourceCode", "General", "KeyPrefix"]

-   command: update
    path: Resources.DeploymentHelperVPC.Properties.TemplateURL
    value: !Sub
      - "https://s3.amazonaws.com/${S3Bucket}/${KeyPrefix}/cfn-deployment-helper-vpc.template"
      - S3Bucket: !FindInMap ["SourceCode", "General", "TemplateBucket"]
        KeyPrefix: !FindInMap ["SourceCode", "General", "KeyPrefix"]

-   command: update
    path: Resources.OpenSsl.Properties.TemplateURL
    value: !Sub
      - "https://s3.amazonaws.com/${S3Bucket}/${KeyPrefix}/cfn-openssl-layer.template"
      - S3Bucket: !FindInMap ["SourceCode", "General", "TemplateBucket"]
        KeyPrefix: !FindInMap ["SourceCode", "General", "KeyPrefix"]

-   command: update
    path: Resources.Networking.Properties.TemplateURL
    value: !Sub
      - "https://s3.amazonaws.com/${S3Bucket}/${KeyPrefix}/cfn-networking.template"
      - S3Bucket: !FindInMap ["SourceCode", "General", "TemplateBucket"]
        KeyPrefix: !FindInMap ["SourceCode", "General", "KeyPrefix"]


-   command: update
    path: Resources.EventBus.Properties.TemplateURL
    value: !Sub
      - "https://s3.amazonaws.com/${S3Bucket}/${KeyPrefix}/cfn-eventbus.template"
      - S3Bucket: !FindInMap ["SourceCode", "General", "TemplateBucket"]
        KeyPrefix: !FindInMap ["SourceCode", "General", "KeyPrefix"]