简体   繁体   English

如何在 aws cloudformation yaml 模板中格式化数据类型 json 的参数?

[英]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. AWS Cloudformation AWS::SageMaker::Model ContainerDefinition 的 yaml 模板文档指定“环境”的类型为 ZEED8D85B888A6C015834240885EE633。 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.在使用以下命令运行部署后,我无法弄清楚如何在我的 yaml 模板中提交 json,该模板不会导致“CREATE_FAILED 内部故障”。

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

test-template-export.yml测试模板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?如何格式化此 Environment 参数?

My version of aws cli is "aws-cli/2.4.10 Python/3.8.8"我的 aws cli 版本是“aws-cli/2.4.10 Python/3.8.8”

Hi when you see json format think more dict.嗨,当您看到 json 格式时,请考虑更多 dict。 So write it like this:所以这样写:

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

For IAM Policies the PolicyDocument is json type and this is how AWS do it in their exempel:对于 IAM 策略,PolicyDocument 是 json 类型,这就是 AWS 在其示例中的做法:

Type: 'AWS::IAM::Policy'
Properties:
  PolicyName: CFNUsers
  PolicyDocument:
    Version: "2012-10-17"
    Statement:
      - Effect: Allow
        Action:
          - 'cloudformation:Describe*'
          - 'cloudformation:List*'
          - 'cloudformation:Get*'
        Resource: '*'
  Groups:
    - !Ref CFNUserGroup

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS Cloudformation-如何在 json/yaml 模板中处理字符串大写或小写 - AWS Cloudformation- How to do string Uppercase or lowercase in json/yaml template 如何将 AWS Cloudformation 的 YAML 连接格式写入 Terraform 格式? - How can I write a YAML Join Format of AWS Cloudformation to Terraform format? AWS Cloudformation JSON模板到C#对象 - AWS Cloudformation JSON template to c# object AWS CloudFormation 用户数据 \; 和新行(JSON) - AWS CloudFormation User Data \; and new lines (JSON) 如何在 cloudformation 的参考参数中使用 AWS principal - How to use AWS principal in reference parameter in cloudformation 我可以在 AWS Cloudformation json 模板的“参数”中使用“Fn::Join”吗 - Can I use "Fn::Join" in "Parameters" of AWS Cloudformation json template AWS CloudFormation模板(JSON)创建EC2-意外错误 - AWS CloudFormation Template (JSON) to Create EC2 - Unexpected Error AWS Cloudformation json模板中的“参数”内应是什么,以及“资源”内应是什么? - What should be inside “Parameters” and what in “Resoures” in AWS Cloudformation json template? 如何格式化 json 参数 object 以便它在模板中正确调用? - how do you format a json parameter object such that it calls correctly in a template? AWS CloudFormation:“参数[subnetIds]无效” - AWS CloudFormation: “Parameter [subnetIds] is invalid”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM