'How to format parameter of data type json in a aws cloudformation yaml template?

The yaml template documentation for the AWS Cloudformation AWS::SageMaker::Model ContainerDefinition specifies that "Environment" is of type Json. I can't work out how to submit json in my yaml template that does not cause a "CREATE_FAILED Internal Failure" after running a deploy with the below command.

aws cloudformation deploy --stack-name test1 --template-file test-template-export.yml

test-template-export.yml

Description: Example yaml

Resources:
  Model:
    Type: AWS::SageMaker::Model
    Properties:
      Containers:
      - ModelPackageName: arn:aws:sagemaker:us-east-1:123456789123:model-package/name/25
      - Environment: '{"SAGEMAKER_CONTAINER_LOG_LEVEL": "20"}'
      ExecutionRoleArn: arn:aws:iam::123456789123:role/service-role/AmazonSageMakerServiceCatalogProductsUseRole

I have also tried the below formats as well and still no luck.

Containers:
- ModelPackageName: arn:aws:sagemaker:us-east-1:123456789123:model-package/name/25
  Environment: '{"SAGEMAKER_CONTAINER_LOG_LEVEL": "20"}'

--

Containers:
- ModelPackageName: arn:aws:sagemaker:us-east-1:123456789123:model-package/name/25
- Environment: | 
         {
            "SAGEMAKER_CONTAINER_LOG_LEVEL": "20"
          }

--

Containers:
- ModelPackageName: arn:aws:sagemaker:us-east-1:123456789123:model-package/name/25
- Environment:
  - SAGEMAKER_CONTAINER_LOG_LEVEL: "20"

Running without Environment deploys fine.

I have tried everything in this answer. How do I format this Environment argument?

My version of aws cli is "aws-cli/2.4.10 Python/3.8.8"



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source