templates/quickstart-bitbucket-dc.template.yaml [1013:1066]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                  - !Sub ["ATL_AWS_ENABLE_CLOUDWATCH=${EnableCW}", EnableCW: !If [EnableCloudWatch, true, false]]
                  - !Sub ["ATL_AWS_ENABLE_CLOUDWATCH_LOGS=${EnableCWLogs}", EnableCWLogs: !If [EnableCloudWatchLogs, true, false]]

            /opt/atlassian/bin/clone_deployment_repo:
              content: !Sub |
                #!/bin/bash
                key_location=/root/.ssh/deployment_repo_key
                key_name="${DeploymentAutomationKeyName}"
                ssm_pin=/${AWS::StackName}/pinned-ansible-sha

                yum install -y git awscli jq

                if [[ ! -z "$key_name" ]]; then
                    # Ensure awscli is up to date
                    key_val=$(aws --region=${AWS::Region} ssm get-parameters --names "$key_name" --with-decryption | jq --raw-output '.Parameters[0].Value')
                    echo -e "$key_val" > $key_location
                    chmod 600 $key_location
                    export GIT_SSH_COMMAND="ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -i $key_location"
                else
                    export GIT_SSH_COMMAND="ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no"
                fi

                ### Ansible repo pinning ###
                pinned_commit_id=$(aws --region=${AWS::Region} ssm get-parameters --names "$ssm_pin" | jq --raw-output '.Parameters[0].Value')

                git clone "${DeploymentAutomationRepository}" -b "${DeploymentAutomationBranch}" /opt/atlassian/dc-deployments-automation/
                cd /opt/atlassian/dc-deployments-automation/

                if [[ "$pinned_commit_id" == "latest" || -z "$pinned_commit_id" ]]; then
                  head_id=$(git rev-parse HEAD)
                  echo "SSM param [$ssm_pin] has been set to 'latest' - Using the HEAD SHA [$head_id] to build cluster [${AWS::StackName}]"
                  echo "Updating SSM param [$ssm_pin] with current HEAD SHA: [$head_id]"
                  aws --region=${AWS::Region} ssm put-parameter --name "$ssm_pin" --value "$head_id" --overwrite --type String
                else
                  echo "Ansible repo has been pinned, checking out commit: [$pinned_commit_id]"
                  git checkout -b "pinned-ansible-sha-$pinned_commit_id" "$pinned_commit_id"
                fi
              mode: "000750"
              owner: root
              group: root

          commands:
            070_create_atl_dir:
              test: "test ! -d /opt/atlassian/"
              command: mkdir -p /opt/atlassian
              ignoreErrors: false
            071_install_packages:
              command: yum install -y git python-virtualenv
              ignoreErrors: true
            072_clone_atl_scripts:
              test: "test ! -d /opt/atlassian/dc-deployments-automation/"
              command: /opt/atlassian/bin/clone_deployment_repo
              ignoreErrors: true
            080_run_atl_init_node:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



templates/quickstart-bitbucket-dc.template.yaml [1438:1491]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                  - !Sub ["ATL_AWS_ENABLE_CLOUDWATCH=${EnableCW}", EnableCW: !If [EnableCloudWatch, true, false]]
                  - !Sub ["ATL_AWS_ENABLE_CLOUDWATCH_LOGS=${EnableCWLogs}", EnableCWLogs: !If [EnableCloudWatchLogs, true, false]]

            /opt/atlassian/bin/clone_deployment_repo:
              content: !Sub |
                #!/bin/bash
                key_location=/root/.ssh/deployment_repo_key
                key_name="${DeploymentAutomationKeyName}"
                ssm_pin=/${AWS::StackName}/pinned-ansible-sha

                yum install -y git awscli jq

                if [[ ! -z "$key_name" ]]; then
                    # Ensure awscli is up to date
                    key_val=$(aws --region=${AWS::Region} ssm get-parameters --names "$key_name" --with-decryption | jq --raw-output '.Parameters[0].Value')
                    echo -e "$key_val" > $key_location
                    chmod 600 $key_location
                    export GIT_SSH_COMMAND="ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -i $key_location"
                else
                    export GIT_SSH_COMMAND="ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no"
                fi

                ### Ansible repo pinning ###
                pinned_commit_id=$(aws --region=${AWS::Region} ssm get-parameters --names "$ssm_pin" | jq --raw-output '.Parameters[0].Value')

                git clone "${DeploymentAutomationRepository}" -b "${DeploymentAutomationBranch}" /opt/atlassian/dc-deployments-automation/
                cd /opt/atlassian/dc-deployments-automation/

                if [[ "$pinned_commit_id" == "latest" || -z "$pinned_commit_id" ]]; then
                  head_id=$(git rev-parse HEAD)
                  echo "SSM param [$ssm_pin] has been set to 'latest' - Using the HEAD SHA [$head_id] to build cluster [${AWS::StackName}]"
                  echo "Updating SSM param [$ssm_pin] with current HEAD SHA: [$head_id]"
                  aws --region=${AWS::Region} ssm put-parameter --name "$ssm_pin" --value "$head_id" --overwrite --type String
                else
                  echo "Ansible repo has been pinned, checking out commit: [$pinned_commit_id]"
                  git checkout -b "pinned-ansible-sha-$pinned_commit_id" "$pinned_commit_id"
                fi
              mode: "000750"
              owner: root
              group: root

          commands:
            070_create_atl_dir:
              test: "test ! -d /opt/atlassian/"
              command: mkdir -p /opt/atlassian
              ignoreErrors: false
            071_install_packages:
              command: yum install -y git python-virtualenv
              ignoreErrors: true
            072_clone_atl_scripts:
              test: "test ! -d /opt/atlassian/dc-deployments-automation/"
              command: /opt/atlassian/bin/clone_deployment_repo
              ignoreErrors: true
            080_run_atl_init_node:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



