如何在 aws cloudformation yaml 模板中格式化数据类型 json 的参数?
How to format parameter of data type json in a aws cloudformation yaml template?
AWS Cloudformation AWS::SageMaker::Model ContainerDefinition 的 yaml 模板 documentation 指定“环境”的类型为 Json。我不知道如何在我的 yaml 模板中提交 json,它不会在 运行 使用以下命令部署后导致“CREATE_FAILED 内部故障”。
aws cloudformation deploy --stack-name test1 --template-file 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
我也尝试了以下格式,但仍然没有成功。
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"
运行 没有环境部署正常。
我已经尝试了 this answer. 中的所有方法
如何设置此环境参数的格式?
我的aws cli版本是“aws-cli/2.4.10 Python/3.8.8”
嗨,当你看到 json 格式时,请多想想 dict。
所以这样写:
Containers:
- ModelPackageName: arn:aws:sagemaker:us-east-1:123456789123:model-package/name/25
Environment:
SAGEMAKER_CONTAINER_LOG_LEVEL: 20
对于 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
AWS Cloudformation AWS::SageMaker::Model ContainerDefinition 的 yaml 模板 documentation 指定“环境”的类型为 Json。我不知道如何在我的 yaml 模板中提交 json,它不会在 运行 使用以下命令部署后导致“CREATE_FAILED 内部故障”。
aws cloudformation deploy --stack-name test1 --template-file 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
我也尝试了以下格式,但仍然没有成功。
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"
运行 没有环境部署正常。
我已经尝试了 this answer. 中的所有方法 如何设置此环境参数的格式?
我的aws cli版本是“aws-cli/2.4.10 Python/3.8.8”
嗨,当你看到 json 格式时,请多想想 dict。 所以这样写:
Containers:
- ModelPackageName: arn:aws:sagemaker:us-east-1:123456789123:model-package/name/25
Environment:
SAGEMAKER_CONTAINER_LOG_LEVEL: 20
对于 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