

# Deploy the Amazon Kinesis Video Streams Edge Agent to AWS IoT Greengrass
<a name="gs-edge-gg"></a>

 

This section provides a comprehensive guide to use Amazon Kinesis Video Streams with AWS IoT Greengrass. By combining these services, you can efficiently stream video from edge devices to the cloud, enabling a wide range of applications in IoT, surveillance, and more.

You'll find detailed information on:
+ Setting up your development environment
+ Creating a Kinesis video stream
+ Creating and packaging a Lambda function
+ Configuring the Kinesis Video Streams core device
+ Deploying to the core device
+ Verifying your stream

Follow these steps to deploy the Amazon Kinesis Video Streams Edge Agent to AWS IoT Greengrass to record and upload media from IP cameras.

**Topics**
+ [Create an Ubuntu Amazon EC2 instance](gs-ubuntu.md)
+ [Set up the AWS IoT Greengrass V2 core device on the device](gs-setup-gg.md)
+ [Create the Amazon Kinesis Video Streams and AWS Secrets Manager resources for your IP camera RTSP URLs](gs-create-resources.md)
+ [Add permissions to the token exchange service (TES) role](gs-add-permissions.md)
+ [Install the AWS IoT Greengrass Secret Manager component on the device](gs-install-secrets-manager.md)
+ [Deploy the Amazon Kinesis Video Streams Edge Agent AWS IoT Greengrass component on the device](gs-deploy-edge.md)
+ [Install the AWS IoT Greengrass log manager component on the device](gs-publish-edge.md)

# Create an Ubuntu Amazon EC2 instance
<a name="gs-ubuntu"></a>

Do the following to create an Ubuntu Amazon EC2 instance.

**Create an Ubuntu Amazon EC2 instance**

1. Sign in to the AWS Management Console and open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

   Verify that the appropriate Region is selected.

1. Choose **Launch Instance**.

   Complete the following fields:
   + **Name** – Type a name for the instance.
   + **Application and OS Images (Amazon Machine Image)** – Select **Ubuntu**.
   + **Instance type** – Select **t2.large**.
   + **Key pair login** – Create your own key pair.
   + **Network settings** – Keep the default.
   + **Configure storage** – Increase the volume to 256 GiB.
   + **Advanced settings** – Keep the default.

1. Launch the instance and SSH into it.

   Do the following:

   1. Select **Instances** in the left navigation, then select the instance ID.

   1. Choose **Connect** in the top-right.

   1. Choose **SSH client** and follow the instructions on the screen.

   1. Open a terminal and navigate to the downloaded `.pem` file (likely in `~/Downloads`).

   1. The first time you follow these procedures, you will receive the message "The authenticity of host (…) can't be established." Type **yes**.

1. Install system libraries to build the Amazon Kinesis Video Streams Edge Agent onto the instance.

   ```
   wget -O- https://apt.corretto.aws/corretto.key | sudo apt-key add - 
   sudo add-apt-repository 'deb https://apt.corretto.aws stable main'
   
   sudo apt-get update
   
   sudo apt-get install -y gcc libssl-dev libcurl4-openssl-dev liblog4cplus-dev \
   libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
   gstreamer1.0-plugins-base-apps gstreamer1.0-plugins-bad \
   gstreamer1.0-plugins-good gstreamer1.0-tools \
   unzip java-11-amazon-corretto-jdk maven
   ```
**Important**  
If you see a screen telling you that some services need to be restarted, press Enter to select **Ok**.

   For more information, see [https://docs.aws.amazon.com//corretto/latest/corretto-11-ug/generic-linux-install.html](https://docs.aws.amazon.com//corretto/latest/corretto-11-ug/generic-linux-install.html).

# Set up the AWS IoT Greengrass V2 core device on the device
<a name="gs-setup-gg"></a>

Follow these procedures to install the AWS IoT Greengrass core nucleus software on the Amazon EC2 instance.

**Set up the AWS IoT Greengrass core device**

1. Sign in to the AWS Management Console, [https://console.aws.amazon.com/iot/](https://console.aws.amazon.com/iot/).

   Verify that the appropriate Region is selected.

1. In the left navigation, select **Greengrass devices**, **Core devices**.

1. Choose **Set up one core device**.

1. Complete the steps on the screen.
   + **Step 1: Register a Greengrass core device**. Type a name for the device.
   + **Step 2: Add to a thing group to apply a continuous deployment**. Select **No group**.
   + **Step 3: Install the Greengrass Core software**. Select **Linux**.
     + **Step 3.1: Install Java on the device**

       Java is installed as part of [Create an Ubuntu Amazon EC2 instance](gs-ubuntu.md). Return to that step if you don't have Java installed yet.
     + **Step 3.2: Copy AWS credentials onto the device**

       Open the `bash/zsh` option and paste the export commands in the Amazon EC2 instance.
     + **Step 3.3: Run the installer**

       1. Copy and run the **Download the installer** and **Run the installer** commands in the Ubuntu Amazon EC2 instance.
**Note**  
The **Run the installer** command will automatically update based on the name you chose in a previous step.

       1. Make note of the token exchange service (TES) role that is created. You need it later.
**Note**  
By default, the role created is called **GreengrassV2TokenExchangeRole**.

# Create the Amazon Kinesis Video Streams and AWS Secrets Manager resources for your IP camera RTSP URLs
<a name="gs-create-resources"></a>

Follow these procedures to create the streams and secrets needed in AWS Secrets Manager. Do this step first, because you need the ARNs of the created resources in the policies.

## Create Amazon Kinesis Video Streams
<a name="gs-create-kvs"></a>

Create Amazon Kinesis Video Streams using the AWS Management Console, AWS CLI, or API.

In the AWS Management Console, open the [Amazon Kinesis Video Streams console](https://console.aws.amazon.com/kinesisvideo/home/). Choose **Video streams** in the left navigation.

For more information, see [Create an Amazon Kinesis video stream](gs-createstream.md).

## Create secrets in AWS Secrets Manager
<a name="gs-create-secrets"></a>

In the AWS Management Console, open the [AWS Secrets Manager console](https://console.aws.amazon.com/secretsmanager/landing). Choose **Secrets** in the left navigation.

Verify that the appropriate Region is selected.

1. Choose **Store a new secret**.

   1. **Step 1: Choose secret type**
      + Select **Other type of secret**.
      + In the **Key/Value Pairs** section, add a key-value pair. 

        **Key**: `MediaURI`
**Note**  
The key must be `MediaURI`. This is case-sensitive. If you enter it incorrectly, the application doesn't work.

        **Value**: `Your MediaURI`.  
**Example**  

        **Example:** `rtsp://<YourCameraIPAddress>:<YourCameraRTSPPort>/YourCameraMediaURI`.

   1. **Step 2: Configure secret**. Give this secret a name. Name it whatever you want.

   1. **Step 3: Configure rotation - optional**. Choose **Next**.

   1. **Step 4: Review**. Choose **Store**.

1. If your secret does not display immediately, select the refresh button.

   Choose the name of your secret. Make note of the **Secret ARN**.

1. Repeat this process for each MediaURI that you want to stream from.

**Note**  
The AWS network blocks some public RTSP sources. You cannot access these from within the Amazon EC2 instance or if you are running unmanaged while connected to the VPN.  
Your camera RTSP URL should stream video in h.264 format. The fragment duration must not exceed the limit mentioned in [Producer SDK quotas](limits.md#producer-sdk-limits).  
Amazon Kinesis Video Streams Edge Agent only supports video.
Run `gst-discoverer-1.0 Your RtspUrl` to make sure that your camera is reachable from your device.

Save the ARNs for all of the streams and secrets that you created. You need these for the next step.

# Add permissions to the token exchange service (TES) role
<a name="gs-add-permissions"></a>

Grant the token exchange service (TES) role to the device that assumes permissions to look at the secrets. This is necessary for the AWS Secrets Manager AWS IoT Greengrass component to work correctly.

**Add permissions to the TES role**

1. Sign in to the AWS Management Console and open the IAM console at [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/).

1. Choose **Roles** in the left navigation and search for the TES role that you created earlier in the process.

1. In the **Add permissions** dropdown, select **Attach policies**.

1. Choose **Create policy**.

1. Scroll down and select **Edit**.

1. In the policy editor, choose **JSON** and edit the policy.

   Replace the policy with the following:
**Note**  
Replace `arn:aws:kinesisvideo:*:*:stream/streamName1/*` and `arn:aws:kinesisvideo:*:*:stream/streamName2/*` with the ARNs for the streams that you created in a previous step.

------
#### [ JSON ]

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Effect": "Allow",
               "Action": [
                   "kinesisvideo:ListStreams"
               ],
               "Resource": "*"
           },
           {
               "Effect": "Allow",
               "Action": [
                   "kinesisvideo:DescribeStream",
                   "kinesisvideo:PutMedia",
                   "kinesisvideo:TagStream",
                   "kinesisvideo:GetDataEndpoint"
               ],
               "Resource": [
                   "arn:aws:kinesisvideo:*:*:stream/streamName1/*",
                   "arn:aws:kinesisvideo:*:*:stream/streamName2/*"
               ]
           }
       ]
   }
   ```

------

1. On the **Add tags** page, choose **Next: Review**.

1. Name your policy, then choose **Create policy**.

   An example of a policy name is **KvsEdgeAccessPolicy**.

1. Close the tab and return to the tab where you were attaching a policy to the TES role.

   Choose the refresh button, then search for the newly created policy.

   Select the check box and choose **Attach policies**.

   On the next screen, you see a note that says **Policy was successfully attached to role.**

1. Create and attach another policy, this time for your secrets.

   Replace the policy with the following:
**Note**  
Replace `arn:aws:secretsmanager:*:*:secret:*` with the ARNs containing the MediaURI secrets that you created in [Create the Amazon Kinesis Video Streams and AWS Secrets Manager resources for your IP camera RTSP URLs](gs-create-resources.md).

------
#### [ JSON ]

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Effect": "Allow",
               "Action": "secretsmanager:GetSecretValue",
               "Resource": [
                   "arn:aws:secretsmanager:*:*:secret:*",
                   "arn:aws:secretsmanager:*:*:secret:*"
               ]
           }
       ]
   }
   ```

------

1. Create and attach another policy, this time for Amazon CloudWatch metrics. Replace the policy with the following:

------
#### [ JSON ]

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Effect": "Allow",
               "Action": [
                   "cloudwatch:PutMetricData"
               ],
               "Resource": [
                   "*"
               ]
           }
       ]
   }
   ```

------

# Install the AWS IoT Greengrass Secret Manager component on the device
<a name="gs-install-secrets-manager"></a>

The Amazon Kinesis Video Streams Edge Agent requires the AWS IoT Greengrass Secret Manager component to be installed on the device first.

**Install the Secret Manager component**

1. Sign in to the AWS Management Console and open the AWS IoT Core console at [https://console.aws.amazon.com/iot/](https://console.aws.amazon.com/iot/). Verify that the appropriate Region is selected.

1. In the left navigation, choose **Greengrass devices**, **Deployments**.

   Choose the deployment with the same target as the thing we created in [Set up the AWS IoT Greengrass V2 core device on the device](gs-setup-gg.md).

1. In the **Actions** dropdown in the top right corner, choose **Revise**.

   In the pop-up that appears, choose **Revise deployment**.

1. Complete the following sections:
   + **Step 1: Specify target**. Choose **Next**.
   + **Step 2: Select components**.
     + Verify that the **aws.greengrass.Cli** component is selected. Do not uninstall this component.
     + Toggle the **Show only selected components** switch and search for **aws.greengrass.SecretManager**.
     + Check the box next to **aws.greengrass.SecretManager**, then choose **Next**.
   + **Step 3: Configure components**. Configure the AWS IoT Greengrass Secret Manager component to download the secrets from within the AWS IoT Greengrass environment.

     Select the **aws.greengrass.SecretManager** component, then choose **Configure component**.

     In the screen that appears, update the AWS Secrets Manager ARNs in the **Configuration to merge** box.
**Note**  
Replace `arn:aws:secretsmanager:*:*:secret:*` with the ARNs of the secrets that you created in [Create the Amazon Kinesis Video Streams and AWS Secrets Manager resources for your IP camera RTSP URLs](gs-create-resources.md).

     ```
     {
      "cloudSecrets": [
           {
             "arn": "arn:aws:secretsmanager:*:*:secret:*"
           },
           {
             "arn": "arn:aws:secretsmanager:*:*:secret:*"
           }
         ]
     }
     ```
**Note**  
`cloudSecrets` is a list of objects with the key `arn`. For more information, see the [Secret manager configuration](https://docs.aws.amazon.com//greengrass/v2/developerguide/secret-manager-component.html#secret-manager-component-configuration) section in the AWS IoT Greengrass Version 2 Developer Guide. 

     When you're done, select **Confirm**, then choose **Next**.
   + **Step 4: Configure advanced settings**. Select **Next**.
   + **Step 5: Review**. Select **Deploy**.

1. Confirm that the AWS Secrets Manager component and permissions were installed correctly.

   On the Ubuntu Amazon EC2 instance, type `sudo /greengrass/v2/bin/greengrass-cli component details --name aws.greengrass.SecretManager` to verify that the component received the updated configuration.

1. Inspect the AWS IoT Greengrass core logs.

   Type `sudo less /greengrass/v2/logs/greengrass.log`.

   Review for deployment errors. 

   If there was an error, revise the deployment to remove the `aws.greengrass.SecretManager` component.

   Type `sudo service greengrass restart` to restart the AWS IoT Greengrass core service.

   If the deployment error was related to missing permissions, review the [Add permissions to the token exchange service (TES) role](gs-add-permissions.md) section to make sure that the TES role has the proper permissions. Then, repeat this section.

1. **Update the secrets on the AWS IoT Greengrass Secret Manager component**
**Important**  
The AWS IoT Greengrass Secret Manager component fetches and caches secrets only when the deployment is updated.

   In order to update the secrets on the AWS IoT Greengrass Secret Manager component, follow the preceding steps 1–6, with the following change.

   **Step 3: Configure components**. Configure the AWS IoT Greengrass Secret Manager component to download the secrets from within the AWS IoT Greengrass environment.

   Select the **aws.greengrass.SecretManager** component, then choose **Configure component**.

   In the screen that appears, paste `[""]` in the **Reset paths** box, and update the AWS Secrets Manager ARNs in the **Configuration to merge** box.

   For more information, see [Reset updates](https://docs.aws.amazon.com//greengrass/v2/developerguide/update-component-configurations.html#reset-configuration-update).

# Deploy the Amazon Kinesis Video Streams Edge Agent AWS IoT Greengrass component on the device
<a name="gs-deploy-edge"></a>

Do the following to deploy the Amazon Kinesis Video Streams Edge Agent AWS IoT Greengrass component on the device:

**Deploy the component**

1. Download the `tar` file using the provided link.

   If you completed the Amazon Kinesis Video Streams Edge Agent interest form, check your email for the download link. If you haven't completed the form, complete it [here](https://pages.awscloud.com/GLOBAL-launch-DL-KVS-Edge-2023-learn.html).

1. Verify the checksum.

1. Extract the binaries and jar in your device.

   Type: `tar -xvf kvs-edge-agent.tar.gz`.

   After extraction, your folder structure will look like the following:

   ```
   kvs-edge-agent/LICENSE
   kvs-edge-agent/THIRD-PARTY-LICENSES
   kvs-edge-agent/pom.xml
   kvs-edge-agent/KvsEdgeComponent
   kvs-edge-agent/KvsEdgeComponent/recipes
   kvs-edge-agent/KvsEdgeComponent/recipes/recipe.yaml
   kvs-edge-agent/KvsEdgeComponent/artifacts
   kvs-edge-agent/KvsEdgeComponent/artifacts/aws.kinesisvideo.KvsEdgeComponent
   kvs-edge-agent/KvsEdgeComponent/artifacts/aws.kinesisvideo.KvsEdgeComponent/EdgeAgentVersion
   kvs-edge-agent/KvsEdgeComponent/artifacts/aws.kinesisvideo.KvsEdgeComponent/EdgeAgentVersion/edge_log_config                   
   kvs-edge-agent/KvsEdgeComponent/artifacts/aws.kinesisvideo.KvsEdgeComponent/EdgeAgentVersion/kvs-edge-agent.jar
   kvs-edge-agent/KvsEdgeComponent/artifacts/aws.kinesisvideo.KvsEdgeComponent/EdgeAgentVersion/libgstkvssink.so
   kvs-edge-agent/KvsEdgeComponent/artifacts/aws.kinesisvideo.KvsEdgeComponent/EdgeAgentVersion/libIngestorPipelineJNI.so
   kvs-edge-agent/KvsEdgeComponent/artifacts/aws.kinesisvideo.KvsEdgeComponent/EdgeAgentVersion/lib
   kvs-edge-agent/KvsEdgeComponent/artifacts/aws.kinesisvideo.KvsEdgeComponent/EdgeAgentVersion/lib/libcproducer.so
   kvs-edge-agent/KvsEdgeComponent/artifacts/aws.kinesisvideo.KvsEdgeComponent/EdgeAgentVersion/lib/libKinesisVideoProducer.so
   ```
**Note**  
The release folder name should be set up in a way that reflects the latest binary release number. For example, a 1.0.0 release will have the folder name set as 1.0.0. 

1. Build the dependencies jar. 
**Note**  
The jar included with the kvs-edge-agent.tar.gz does not have the dependencies. Use the following steps to build those libraries.

   Navigate to the `kvs-edge-agent` folder that contains `pom.xml`. 

   Type `mvn clean package`.

   This will generate a jar file containing the dependencies the Amazon Kinesis Video Streams Edge Agent requires at `kvs-edge-agent/target/libs.jar`.

1. Place the libs.jar into the folder that contains the component’s artifacts.

   Type `mv ./target/libs.jar ./KvsEdgeComponent/artifacts/aws.kinesisvideo.KvsEdgeComponent/EdgeAgentVersion/`.

1. **Optional.** Configure properties. The Amazon Kinesis Video Streams Edge Agent accepts the following environment variables in AWS IoT Greengrass mode:    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/kinesisvideostreams/latest/dg/gs-deploy-edge.html)

   Open `kvs-edge-agent/KvsEdgeComponent/recipes/recipe.yaml` and modify the run script to add any of the preceding environment variables.
**Important**  
Make sure that the modified run script doesn't contain any **tab** characters. The AWS IoT Greengrass core software won't be able to read the recipe.

1. Deploy the Amazon Kinesis Video Streams Edge Agent AWS IoT Greengrass component. 

   Type:

   ```
   sudo /greengrass/v2/bin/greengrass-cli deployment create \
     --recipeDir <download location>/kvs-edge-agent/KvsEdgeComponent/recipes/ \
     --artifactDir <download location>/kvs-edge-agent/KvsEdgeComponent/artifacts/ \
     --merge "aws.kinesisvideo.KvsEdgeComponent=EdgeAgentVersion"
   ```

   For additional information, see the following sections in the *AWS IoT Greengrass Version 2 Developer Guide*:
   + [AWS IoT Greengrass CLI commands](https://docs.aws.amazon.com//greengrass/v2/developerguide/gg-cli-reference.html)
   + [Deploy AWS IoT Greengrass components to devices](https://docs.aws.amazon.com//greengrass/v2/developerguide/manage-deployments.html)

1. Send configurations to the application using the AWS CLI.

   1. Create a new file, `example-edge-configuration.json`. 

      Paste the following code into the file. This is a sample configuration that records daily from 9:00:00 AM to 4:59:59 PM (according to the system time on your AWS IoT device). It also uploads the recorded media daily from 7:00:00 PM to 9:59:59 PM.

      For more information, see [StartEdgeConfigurationUpdate](API_StartEdgeConfigurationUpdate.md).

      ```
      {
          "StreamARN": "arn:aws:kinesisvideo:your-region:your-account-id:stream/your-stream/0123456789012",
          "EdgeConfig": {
              "HubDeviceArn": "arn:aws:iot:your-region:your-account-id:thing/kvs-edge-agent-demo",
              "RecorderConfig": {
                  "MediaSourceConfig": {
                      "MediaUriSecretArn": "arn:aws:secretsmanager:your-region:your-account-id:secret:your-secret-dRbHJQ",
                      "MediaUriType": "RTSP_URI"
                  },
                  "ScheduleConfig": {
                      "ScheduleExpression": "0 0 9,10,11,12,13,14,15,16 ? * * *",
                      "DurationInSeconds": 3599
                  }
              },
              "UploaderConfig": {
                  "ScheduleConfig": {
                      "ScheduleExpression": "0 0 19,20,21 ? * * *",
                      "DurationInSeconds": 3599
                  }
              },
              "DeletionConfig": {
                  "EdgeRetentionInHours": 15,
                  "LocalSizeConfig": {
                    "MaxLocalMediaSizeInMB": 2800,
                    "StrategyOnFullSize": "DELETE_OLDEST_MEDIA"
                  },
                  "DeleteAfterUpload": true
              }
          }
      }
      ```

   1. Type the following in the AWS CLI to send the file to the Amazon Kinesis Video Streams Edge Agent:

      ```
      aws kinesisvideo start-edge-configuration-update --cli-input-json "file://example-edge-configuration.json"
      ```

1. Repeat the previous step for each stream for the Amazon Kinesis Video Streams Edge Agent.

# Install the AWS IoT Greengrass log manager component on the device
<a name="gs-publish-edge"></a>

**Note**  
Be aware of the [CloudWatch quotas](https://docs.aws.amazon.com//AmazonCloudWatch/latest/logs/cloudwatch_limits_cwl.html).

Follow these procedures to configure the Amazon Kinesis Video Streams Edge Agent logs to automatically upload to CloudWatch using the AWS IoT Greengrass log manager component. This is an optional step.

**Install the AWS IoT Greengrass log manager component**

1. Confirm that the AWS IoT Greengrass device role has the [appropriate permissions](https://docs.aws.amazon.com//greengrass/v2/developerguide/log-manager-component.html#log-manager-component-requirements).

   1. Sign in to the AWS Management Console and open the IAM console at [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/).

   1. Click **Roles** in the left navigation.

   1. Choose the name of the TES role created in [Set up the AWS IoT Greengrass V2 core device on the device](gs-setup-gg.md). Use the search bar if necessary.

   1. Select the `GreengrassV2TokenExchangeRoleAccess` policy.

   1. Select the JSON tab and verify that the policy looks like the following:

------
#### [ JSON ]

****  

      ```
      {
          "Version":"2012-10-17",		 	 	 
          "Statement": [
              {
                  "Effect": "Allow",
                  "Action": [
                      "logs:CreateLogGroup",
                      "logs:CreateLogStream",
                      "logs:PutLogEvents",
                      "logs:DescribeLogStreams",
                      "s3:GetBucketLocation"
                  ],
                  "Resource": "*"
              }
          ]
      }
      ```

------

   1. If the `GreengrassV2TokenExchangeRoleAccess` policy doesn't exist, or if some required permissions are missing, create a new IAM policy with these permissions and attach it to the TES role created in [Set up the AWS IoT Greengrass V2 core device on the device](gs-setup-gg.md).

1. Sign in to the AWS Management Console and open the AWS IoT Core console at [https://console.aws.amazon.com/iot/](https://console.aws.amazon.com/iot/). Verify that the appropriate Region is selected.

1. In the left navigation, choose **Greengrass devices**, **Deployments**.

   Choose the deployment with the same target as the thing you created in [Set up the AWS IoT Greengrass V2 core device on the device](gs-setup-gg.md).

1. In the top right corner, select **Actions**, then choose **Revise**.

   In the pop-up that appears, choose **Revise deployment**.

1. Complete the following sections:

   1. **Step 1: Specify target.** Choose **Next**.

   1. **Step 2: Select components.**

      1. Verify that the **aws.greengrass.Cli** component and **aws.greengrass.SecretManager** components are still selected.
**Important**  
Don't uninstall these components.

      1. Toggle the **Show only selected components** switch and search for **aws.greengrass.LogManager**.

      1. Select the box next to **aws.greengrass.LogManager**, then choose **Next**.

   1. **Step 3: Configure components.** Configure the AWS IoT Greengrass log manager component to upload the logs generated by the Amazon Kinesis Video Streams Edge Agent.

      Select the **aws.greengrass.LogManager** component, then choose **Configure component**.

      In the screen that appears, paste the following log manager configuration in the **Configuration to merge** box.

      ```
      {
          "logsUploaderConfiguration": {
              "componentLogsConfigurationMap": {
                  "aws.kinesisvideo.KvsEdgeComponent/java_kvs.log": {
                      "diskSpaceLimit": "100",
                      "diskSpaceLimitUnit": "MB",
                      "logFileDirectoryPath": "/greengrass/v2/work/aws.kinesisvideo.KvsEdgeComponent/log",
                      "logFileRegex": "java_kvs.log\\w*"
                  },
                  "aws.kinesisvideo.KvsEdgeComponent/cpp_kvs_edge.log": {
                      "diskSpaceLimit": "100",
                      "diskSpaceLimitUnit": "MB",
                      "logFileDirectoryPath": "/greengrass/v2/work/aws.kinesisvideo.KvsEdgeComponent/log",
                      "logFileRegex": "cpp_kvs_edge.log\\w*"
                  },
                  "aws.kinesisvideo.KvsEdgeComponent/cpp_kvssink.log": {
                      "diskSpaceLimit": "100",
                      "diskSpaceLimitUnit": "MB",
                      "logFileDirectoryPath": "/greengrass/v2/work/aws.kinesisvideo.KvsEdgeComponent/log",
                      "logFileRegex": "cpp_kvssink.log\\w*"
                  },
                  "aws.kinesisvideo.KvsEdgeComponent/cpp_kvs_streams.log": {
                      "diskSpaceLimit": "100",
                      "diskSpaceLimitUnit": "MB",
                      "logFileDirectoryPath": "/greengrass/v2/work/aws.kinesisvideo.KvsEdgeComponent/log",
                      "logFileRegex": "cpp_kvs_streams.log\\w*"
                  }
              }
          },
          "periodicUploadIntervalSec": "1"
      }
      ```
**Important**  
The `logFileDirectoryPath` in the preceding configuration assumes that the default logging output location is used.
**Note**  
For more information about each of the parameters for the log manager configuration, see the [Log manager](https://docs.aws.amazon.com//greengrass/v2/developerguide/log-manager-component.html#log-manager-component-configuration) section of the AWS IoT Greengrass Version 2 Developer Guide.

      Once you finish, select **Confirm**, then choose **Next**.

   1. **Step 4: Configure advanced settings.** Select **Next**.

   1. **Step 5: Review.** Select **Deploy**.

1. Confirm that the AWS log manager component and permissions were installed correctly.

1. On the Ubuntu Amazon EC2 instance, type `sudo /greengrass/v2/bin/greengrass-cli component details --name aws.greengrass.LogManager` to verify the component received the updated configuration.

1. Inspect the AWS IoT Greengrass core logs.

   Type `sudo less /greengrass/v2/logs/greengrass.log`.

   Review for deployment errors.

   If there was an error, revise the deployment to remove the `aws.greengrass.LogManager` component.

   Type `sudo service greengrass restart` to restart the AWS IoT Greengrass core service.

   If the deployment error was related to missing permissions, review [Add permissions to the token exchange service (TES) role](gs-add-permissions.md) to make sure that the TES role has proper permissions. Then, repeat this section.