Install a Custom Application using Run Command

In this task, you will install a custom web application (Widget Manufacturing Dashboard) using the AWS Systems Manager Run Command without logging into the instance.

- If you don't have any idea about this article, first read this article

-In the left navigation pane, click Run Command.

-Click Run command

You will see a list of pre-configured documents for running common commands. You will run a pre-configured command.

-Click then:

  • Owner
  • Owned by me

A document will appear.

-Click the name of the document.

A new tab will open with the description of the document. Verify the description is Install Dashboard App

-Click the Content tab.

The contents will be displayed. It contains a script that:

  • Installs an Apache web server and PHP
  • Activates the web server
  • Installs the AWS SDK for PHP
  • Installs an application

By doing this instructions you will run this code in your instance 

{
  "schemaVersion": "2.2",
  "description": "Install Dashboard App",
  "mainSteps": [
    {
      "inputs": {
        "runCommand": [
          " #!/bin/sh",
          " # Install Apache Web Server and PHP",
          " yum install -y httpd",
          " amazon-linux-extras install -y php7.2",
          " # Turn on web server",
          " systemctl enable httpd.service",
          " systemctl start  httpd.service",
          " # Download and install the AWS SDK for PHP",
          " wget https://github.com/aws/aws-sdk-php/releases/download/3.62.3/aws.zip",
          " unzip aws -d /var/www/html",
          " # Download Application files",
          " #wget https://aws-tc-largeobjects.s3.amazonaws.com/CUR-TF-100-RESTRT-1/169-lab-%5BJAWS%5D-systems-manager/scripts/widget-app.zip",
          " wget https://aws-tc-largeobjects.s3.us-west-2.amazonaws.com/CUR-TF-100-RESTRT-1/169-lab-JAWS-systems-manager/s3/widget-app.zip",
          " unzip widget-app.zip -d /var/www/html/"
        ]
      },
      "name": "InstallDashboardApp",
      "action": "aws:runShellScript"
    }
  ]
}

 

These commands will install an application and all the support files required by the application.

-Close the current web browser tab to return to the Run a command tab.

-Select the document (click the circle, not the name).

-For Targets, select Choose instances manually

-Select Managed Instance.

The Managed Instance has the Systems Manager agent installed. The agent has registered the instance to the service, which allows it to be selected for the Run Command.

It is also possible to identify target instances by using Tags. This makes it easy to run a single command on a whole fleet of matching instances.

-Expand AWS command line interface command (at the bottom of the page).

This section displays the CLI command that will trigger the Run Command. You could copy this command and use it in future within a script rather than having to use the management console.

-Click Run

The progress of your command will be displayed. You will see an In Progress message in the Overall status column.

-Wait for the Overall status to change to Success. You can occasionally click refresh in the top right to update the status.

You will now validate that the custom application was installed.

-Open your Address

-Open a new web browser tab, paste the  ServerIP  address you just copied and press Enter.

The Widget Manufacturing Dashboard that you installed will now appear.

You have successfully run a Run Command via AWS Systems Manager that has installed a custom application onto your instance without needing to remotely access the instance via SSH.

- Use Parameter Store to Manage Application Settings

AWS Systems Manager Parameter Store provides secure, hierarchical storage for configuration data management and secrets management. You can store data such as passwords, database strings, and license codes as parameter values. You can store values as plain text or encrypted data. You can then reference values by using the unique name that you specified when you created the parameter.

In this task you will use AWS Systems Manager Parameter Store to store a parameter that will be used to activate a feature in an application.

-Keep the Dashboard tab open, but return to the Management Console tab.

-In the left navigation pane, under Application Management, click Parameter Store.

-Click Create parameter:

  • Name: /dashboard/show-beta-features
  • Description: Display beta features
  • Value: True

Click Create parameter

The parameter can be specified as a hierarchical path, such as: /dashboard/<option>

The application that is running on the EC2 instance will automatically check for the existence of this parameter. If it finds the parameter, then additional features will be displayed.

Return to the web browser tab displaying the application.

Refresh the web page.

You should now notice that three charts are displayed. This is because the application is checking the Parameter Store to determine whether the additional chart (which is still in beta) should be displayed. This is a common method that applications can be configured to display "dark features" that are installed but not yet activated.

you can Remove the parameter, then refresh the application. The third chart should disappear again!