编写ACM的CFN模板:CommaDelimitedList与List<CommaDelimitedList>区别及输入疑问
CloudFormation中CommaDelimitedList与List的区别及ACM证书输入指南
核心差异
- CommaDelimitedList:就是单一层级的字符串数组,输入是单个逗号分隔的字符串,比如
"example.com,test.example.com,dev.example.com",会被CFN解析成["example.com", "test.example.com", "dev.example.com"]。 - List
:属于二维数组结构,每个元素本身又是一个CommaDelimitedList(也就是逗号分隔的字符串)。输入得是多个逗号分隔字符串组成的列表。
ACM证书SubjectAlternativeName(类型为List)的正确输入格式
针对ACM证书的这个字段,两种常见的正确输入方式:
1. 模板内直接配置
Resources: MyACMCert: Type: AWS::CertificateManager::Certificate Properties: DomainName: example.com SubjectAlternativeNames: - "test.example.com,staging.example.com" - "api.example.com,admin.example.com"
这里SubjectAlternativeNames是一个列表,每个元素是一组逗号分隔的域名,最终会被解析为:
[ ["test.example.com", "staging.example.com"], ["api.example.com", "admin.example.com"] ]
2. 参数化输入(控制台/CLI)
- 控制台输入:在参数输入框中,每行填写一组逗号分隔的域名,比如:
test.example.com,staging.example.com api.example.com,admin.example.com - CLI传递参数:
aws cloudformation create-stack --stack-name MyCertStack --template-body file://cert-template.yaml --parameters ParameterKey=SANs,ParameterValue="test.example.com,staging.example.com" ParameterKey=SANs,ParameterValue="api.example.com,admin.example.com"
附图输入适配性判断
如果你的附图输入是单个逗号分隔的字符串(比如 "test.example.com,dev.example.com"),那它只适合CommaDelimitedList类型,不能直接用在List<CommaDelimitedList>上——你需要把它放进一个列表里(比如写成 ["test.example.com,dev.example.com"]),或者拆分成多组逗号分隔的字符串。
如果附图输入是多个逗号分隔字符串组成的列表(比如每行一个分组,或者用方括号包裹的多个字符串元素),那它就符合List<CommaDelimitedList>的要求。
内容的提问来源于stack exchange,提问作者CA-CB-TellMe
相关产品推荐
相关产品推荐

