static/Reliability/Disaster_Recovery/Code/PilotLightDR.yaml [325:515]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                  - |+

                  - export JSON_STRING=
                  - $(echo '{"host":"'"$HOSTNAME"'","region":"'"$AWS_DEFAULT_REGION"'"}')
                  - |+

                  - >
                    aws s3 cp s3://ee-assets-prod-us-east-1/modules/630039b9022d4b46bb6cbad2e3899733/v1/UniShopUI/
                    /home/ec2-user/UniShopUI/ --no-sign-request --recursive                                                    

                  - |
                    echo $JSON_STRING | sudo tee /home/ec2-user/UniShopUI/config.json                          

                  - >
                    aws s3 cp /home/ec2-user/UniShopUI/
                    s3://$UI_RANDOM_NAME/ --recursive --grants 
                    read=uri=http://acs.amazonaws.com/groups/global/AllUsers         
                    
                  - >
                    sudo aws s3 cp s3://ee-assets-prod-us-east-1/modules/630039b9022d4b46bb6cbad2e3899733/v1/UniShopAppV1-0.0.1-SNAPSHOT.jar /home/ec2-user/ --no-sign-request  

                  - >
                    sudo aws s3 cp s3://ee-assets-prod-us-east-1/modules/630039b9022d4b46bb6cbad2e3899733/v1/create_tables.sql /home/ec2-user/ --no-sign-request    
 
        create-tables:
          commands:
            1-create-tables:
              command: !Join
                - ''
                - - 'sudo mysql -u UniShopAppV1User -h '
                  - !If [CreatePrimaryDB, !GetAtt RDSClusterPrimary.Endpoint.Address, !GetAtt RDSClusterSecondary.ReadEndpoint.Address]
                  - |2
                     -P 3306 -pUniShopAppV1Password < /home/ec2-user/create_tables.sql
        create-service-files:
          files:
            /etc/systemd/system/unishop.service:
              encoding: plain
              content: !Join
                - ''
                - - |
                    [Unit]
                  - |
                    Description=Restart UniShop
                  - |
                    Wants=network.target
                  - >
                    After=syslog.target network-online.target
                    amazon-cloudwatch-agent.target
                  - |+

                  - |
                    [Service]
                  - |
                    Type=simple
                  - |
                    ExecStart=/home/ec2-user/unishopinit.sh
                  - |
                    Restart=on-failure
                  - |
                    RestartSec=60
                  - |
                    KillMode=process
                  - |+

                  - |
                    [Install]
                  - |
                    WantedBy=multi-user.target
              mode: '000644'
              group: root
              user: root
            /home/ec2-user/unishopinit.sh:
              encoding: plain
              content: !Join
                - ''
                - - |
                    #!/bin/bash
                  - |
                    source /home/ec2-user/unishopcfg.sh
                  - |
                    source /home/ec2-user/unishoprun.sh
              mode: '000555'
              group: ec2-user
              user: ec2-user
            /home/ec2-user/unishopcfg.sh:
              encoding: plain
              content: !Join
                - ''
                - - |
                    #!/bin/bash
                  - export Database=
                  - !If [CreatePrimaryDB, !GetAtt RDSClusterPrimary.Endpoint.Address, !GetAtt RDSClusterSecondary.ReadEndpoint.Address]
                  - |+

                  - export DB_ENDPOINT=
                  - !If [CreatePrimaryDB, !GetAtt RDSClusterPrimary.Endpoint.Address, !GetAtt RDSClusterSecondary.ReadEndpoint.Address]
                  - |+

                  - export AWS_DEFAULT_REGION=
                  - !Ref 'AWS::Region'
                  - |+

                  - export UI_RANDOM_NAME=
                  - !Ref UIBucket
                  - |+

              mode: '000555'
              group: ec2-user
              user: ec2-user
            /home/ec2-user/unishoprun.sh:
              encoding: plain
              content: !Join
                - ''
                - - |
                    #!/bin/bash
                  - java -jar
                  - ' '
                  - !If [EnableWriteFwd, '-Dspring.profiles.active=warm ','']
                  - >
                    /home/ec2-user/UniShopAppV1-0.0.1-SNAPSHOT.jar
                    &>
                    /home/ec2-user/app.log
                    &
              mode: '000555'
              group: ec2-user
              user: ec2-user
            /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json:
              content: !Join
                - ''
                - - |
                    {
                  - |2
                        "logs": {
                  - |2
                            "logs_collected": {
                  - |2
                                "files": {
                  - |2
                                    "collect_list": [
                  - |2
                                        {
                  - |2
                                            "file_path": "/home/ec2-user/app.log",
                  - !Join
                    - ''
                    - - '                        "log_group_name":'
                      - '"'
                      - !Ref InstanceLogGroup
                      - |
                        ",
                  - !Join
                    - ''
                    - - '                        "log_stream_name":'
                      - '"'
                      - !Ref InstanceLogGroup
                      - |
                        -app",
                  - |2
                                            "timezone": "Local"
                  - |2
                                        }
                  - |2
                                    ]
                  - |2
                                }
                  - |2
                            }
                  - |2
                        }
                  - '}'
              mode: '000444'
              group: ec2-user
              user: ec2-user
        start-service:
          commands:
            0-start-service:
              command: !Join
                - ''
                - - |
                    sudo systemctl daemon-reload
                  - |
                    sudo systemctl enable unishop
                  - |
                    sudo systemctl start unishop
                  - >
                    sudo amazon-cloudwatch-agent-ctl -a fetch-config -s -m ec2
                    -c
                    file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json
    Properties:
      InstanceType: t3.small
      ImageId: !Ref LatestAmiId
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



static/Reliability/Disaster_Recovery/Code/WarmStandbyDR.yaml [351:540]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                  - |+

                  - export JSON_STRING=
                  - $(echo '{"host":"'"$HOSTNAME"'","region":"'"$AWS_DEFAULT_REGION"'"}')
                  - |+

                  - >
                    aws s3 cp s3://ee-assets-prod-us-east-1/modules/630039b9022d4b46bb6cbad2e3899733/v1/UniShopUI/
                    /home/ec2-user/UniShopUI/ --no-sign-request --recursive                                                    

                  - |
                    echo $JSON_STRING | sudo tee /home/ec2-user/UniShopUI/config.json                          

                  - >
                    aws s3 cp /home/ec2-user/UniShopUI/
                    s3://$UI_RANDOM_NAME/ --recursive --grants 
                    read=uri=http://acs.amazonaws.com/groups/global/AllUsers         
                    
                  - >
                    sudo aws s3 cp s3://ee-assets-prod-us-east-1/modules/630039b9022d4b46bb6cbad2e3899733/v1/UniShopAppV1-0.0.1-SNAPSHOT.jar /home/ec2-user/ --no-sign-request  

                  - >
                    sudo aws s3 cp s3://ee-assets-prod-us-east-1/modules/630039b9022d4b46bb6cbad2e3899733/v1/create_tables.sql /home/ec2-user/ --no-sign-request    
        create-tables:
          commands:
            1-create-tables:
              command: !Join
                - ''
                - - 'sudo mysql -u UniShopAppV1User -h '
                  - !If [CreatePrimaryDB, !GetAtt RDSClusterPrimary.Endpoint.Address, !GetAtt RDSClusterSecondary.ReadEndpoint.Address]
                  - |2
                     -P 3306 -pUniShopAppV1Password < /home/ec2-user/create_tables.sql
        create-service-files:
          files:
            /etc/systemd/system/unishop.service:
              encoding: plain
              content: !Join
                - ''
                - - |
                    [Unit]
                  - |
                    Description=Restart UniShop
                  - |
                    Wants=network.target
                  - >
                    After=syslog.target network-online.target
                    amazon-cloudwatch-agent.target
                  - |+

                  - |
                    [Service]
                  - |
                    Type=simple
                  - |
                    ExecStart=/home/ec2-user/unishopinit.sh
                  - |
                    Restart=on-failure
                  - |
                    RestartSec=60
                  - |
                    KillMode=process
                  - |+

                  - |
                    [Install]
                  - |
                    WantedBy=multi-user.target
              mode: '000644'
              group: root
              user: root
            /home/ec2-user/unishopinit.sh:
              encoding: plain
              content: !Join
                - ''
                - - |
                    #!/bin/bash
                  - |
                    source /home/ec2-user/unishopcfg.sh
                  - |
                    source /home/ec2-user/unishoprun.sh
              mode: '000555'
              group: ec2-user
              user: ec2-user
            /home/ec2-user/unishopcfg.sh:
              encoding: plain
              content: !Join
                - ''
                - - |
                    #!/bin/bash
                  - export Database=
                  - !If [CreatePrimaryDB, !GetAtt RDSClusterPrimary.Endpoint.Address, !GetAtt RDSClusterSecondary.ReadEndpoint.Address]
                  - |+

                  - export DB_ENDPOINT=
                  - !If [CreatePrimaryDB, !GetAtt RDSClusterPrimary.Endpoint.Address, !GetAtt RDSClusterSecondary.ReadEndpoint.Address]
                  - |+

                  - export AWS_DEFAULT_REGION=
                  - !Ref 'AWS::Region'
                  - |+

                  - export UI_RANDOM_NAME=
                  - !Ref UIBucket
                  - |+

              mode: '000555'
              group: ec2-user
              user: ec2-user
            /home/ec2-user/unishoprun.sh:
              encoding: plain
              content: !Join
                - ''
                - - |
                    #!/bin/bash
                  - java -jar
                  - ' '
                  - !If [EnableWriteFwd, '-Dspring.profiles.active=warm ','']
                  - >
                    /home/ec2-user/UniShopAppV1-0.0.1-SNAPSHOT.jar
                    &>
                    /home/ec2-user/app.log
                    &
              mode: '000555'
              group: ec2-user
              user: ec2-user
            /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json:
              content: !Join
                - ''
                - - |
                    {
                  - |2
                        "logs": {
                  - |2
                            "logs_collected": {
                  - |2
                                "files": {
                  - |2
                                    "collect_list": [
                  - |2
                                        {
                  - |2
                                            "file_path": "/home/ec2-user/app.log",
                  - !Join
                    - ''
                    - - '                        "log_group_name":'
                      - '"'
                      - !Ref InstanceLogGroup
                      - |
                        ",
                  - !Join
                    - ''
                    - - '                        "log_stream_name":'
                      - '"'
                      - !Ref InstanceLogGroup
                      - |
                        -app",
                  - |2
                                            "timezone": "Local"
                  - |2
                                        }
                  - |2
                                    ]
                  - |2
                                }
                  - |2
                            }
                  - |2
                        }
                  - '}'
              mode: '000444'
              group: ec2-user
              user: ec2-user
        start-service:
          commands:
            0-start-service:
              command: !Join
                - ''
                - - |
                    sudo systemctl daemon-reload
                  - |
                    sudo systemctl enable unishop
                  - |
                    sudo systemctl start unishop
                  - >
                    sudo amazon-cloudwatch-agent-ctl -a fetch-config -s -m ec2
                    -c
                    file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json
    Properties:
      InstanceType: t3.small
      ImageId: !Ref LatestAmiId
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



