How to configure deployment defined in yaml to write Greengrass & component logs to CloudWatch logs?

0

Hello,

I have a deployment defined in yaml that I am trying to extend to write Greengrass & component logs to CloudWatch logs. I can't seem to get the syntax right. I have:

targetArn: <MY_TARGET_ARN>
deploymentName: <MY_DEPLOYMENT_NAME>
components: 
  aws.greengrass.Nucleus:
    componentVersion: '2.12.6'
  aws.greengrass.TokenExchangeService:
    componentVersion: '2.0.3'
  aws.greengrass.DockerApplicationManager: 
    componentVersion: '2.0.11'
    runWith:
      posixUser: 'root'
  <MY_COMPONENT_NAME>: 
    componentVersion: '0.1.0'
    runWith:
      posixUser: 'root'
  aws.greengrass.LogManager:
    componentVersion: '2.3.0'
    configurationUpdate:
      merge: 
        logsUploaderConfiguration:
          systemLogsConfiguration:
            uploadToCloudWatch: true
          componentLogsConfigurationMap:
            - <MY_COMPONENT_NAME>

When I try to update my deployment with the AWS CLI V2 command:

aws greengrassv2 create-deployment --cli-input-yaml file://<MY_DEPLOYMENT_ABSOLUTE_FILE_PATH>/deployment.yml

I get the error:

Parameter validation failed:
Invalid type for parameter components.aws.greengrass.LogManager.configurationUpdate.merge, value: {'logsUploaderConfiguration': {'systemLogsConfiguration': {'uploadToCloudWatch': True}, 'componentLogsConfigurationMap': ['<MY_COMPONENT_NAME>']}}, type: <class 'dict'>, valid types: <class 'str'>

What am I doing wrong?

2 Answers
2
Accepted Answer

As per documentation:

Merge updates (merge) – (Optional) A JSON document that defines the configuration values to merge onto the target device. You must serialize the JSON document as a string. For more information, see Merge updates.

You need to convert the merge section to be a JSON string. Like the following:

targetArn: <MY_TARGET_ARN>
deploymentName: <MY_DEPLOYMENT_NAME>
components: 
  aws.greengrass.Nucleus:
    componentVersion: '2.12.6'
  aws.greengrass.TokenExchangeService:
    componentVersion: '2.0.3'
  aws.greengrass.DockerApplicationManager: 
    componentVersion: '2.0.11'
    runWith:
      posixUser: 'root'
  <MY_COMPONENT_NAME>: 
    componentVersion: '0.1.0'
    runWith:
      posixUser: 'root'
  aws.greengrass.LogManager:
    componentVersion: '2.3.0'
    configurationUpdate:
      merge: |
        {
          "logsUploaderConfiguration": {
            "systemLogsConfiguration": {
              "uploadToCloudWatch": true
            },
            "componentLogsConfigurationMap": [
              "<MY_COMPONENT_NAME>"
            ]
          }
        }
profile pictureAWS
EXPERT
answered 9 months ago
profile picture
EXPERT
reviewed 9 months ago
0

Yaniv,

Thank you for the pointing that out in the docs and the help, that did the trick.

answered 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions