Amazon web services 如何在CloudFormation模板中使用SSM StringList中的值?
假设我在SSM参数库中有一个参数。该参数以StringList作为值并描述服务,例如(bucket\u name、request\u url)Amazon web services 如何在CloudFormation模板中使用SSM StringList中的值?,amazon-web-services,amazon-cloudformation,aws-ssm,aws-parameter-store,Amazon Web Services,Amazon Cloudformation,Aws Ssm,Aws Parameter Store,假设我在SSM参数库中有一个参数。该参数以StringList作为值并描述服务,例如(bucket\u name、request\u url) “serviceA”=“bucket\u name\u A,https://www.request.com/A“ 现在,在CloudFormation中,我想从这个stringlist中定义我的bucket的名称 "S3FTSE100Intraday1min": { "Type": &quo
“serviceA”=“bucket\u name\u A,https://www.request.com/A“
现在,在CloudFormation中,我想从这个stringlist中定义我的bucket的名称
"S3FTSE100Intraday1min": {
"Type": "AWS::S3::Bucket",
"Properties": {
"BucketName": {
"Fn::GetAtt": [
"My_SSM_ParameterStore_Logical_ID",
"Value"
]
},
...
但显然,这将返回完整的字符串列表,而不仅仅是bucket\u name\u A
如何访问stringlist中要在CloudFormation模板中使用的参数之一?在起草此问题时,我开始研究Fn::方法 (来源:) 我有个主意: 字符串列表是:
“bucket\u name\u A,https://www.request.com/A“
- 使用bucket\u name\u A检索stringlist值,https://www.request.com/A“
- 使用
=>Fn::split
[“bucket\u name\u a”https://www.request.com/A“]
- 用
=>“bucket\u name\u A”选择第一个值Fn::select
SSM参数存储
:
"SSMTestBucketName": {
"Type": "AWS::SSM::Parameter",
"Properties": {
"Name": "StringList_Test_Bucket_Name",
"Type": "StringList",
"Value": "test-ssm-stringlist-bucket, https://www.requesturl.com"
}
}
S3存储桶
:
"S3TestBucket": {
"Type": "AWS::S3::Bucket",
"Properties": {
"BucketName": {
"Fn::Select": [
"0",
{
"Fn::Split": [
",",
{
"Fn::GetAtt": [
"SSMTestBucketName",
"Value"
]
}
]
}
]
},
"BucketEncryption": {
"ServerSideEncryptionConfiguration": [
{
"ServerSideEncryptionByDefault": {
"SSEAlgorithm": "AES256"
}
}
]
},
"PublicAccessBlockConfiguration": {
"BlockPublicAcls": true,
"BlockPublicPolicy": true,
"IgnorePublicAcls": true,
"RestrictPublicBuckets": true
},
"LifecycleConfiguration": {
"Rules": [
{
"Status": "Enabled",
"Transitions": [
{
"TransitionInDays": "30",
"StorageClass": "STANDARD_IA"
}
]
}
]
}
}
}