- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在编写一个 JSON 格式的云形成模板。该模板具有一个类型为 FSx 文件系统 ID 的 CommaDelimitedList 的参数和一个 Lambda 函数资源,该资源引用 FSx 文件系统 ID 的参数并检查其状态。我正在模板中内联编写此 Lambda 函数。
我收到以下错误:
Template error: every Fn::Join object requires two parameters, (1) a string delimiter and (2) a list of strings to be joined or a function that returns a list of strings (such as Fn::GetAZs) to be joined.
这是我的模板:
{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters": {
"FSIds": {
"Type": "CommaDelimitedList",
"Description": "Enter the file system IDs separated by commas"
}
},
"Resources": {
"FSxStatusLambdaFunction": {
"Type": "AWS::Lambda::Function",
"Properties": {
"FunctionName": "test-FSx",
"Architectures": [ "x86_64" ],
"Description": "Lambda function that checks FSx file systems status and sends notification",
"Handler": "index.handler",
"Code": {
"ZipFile": {
"Fn::Join": [
"\n",
[
"import boto3",
"fsx = boto3.client('fsx')",
"#Publish message to SNS topic",
"def publish_message(FS_ID , status):",
" sns = boto3.client('sns')",
" topic = \"arn:aws:sns:us-east-1:123456789:FSx-Notification\"",
" msg = \"{FS_ID} is in {status} state\".format(FS_ID=FS_ID , status=status)",
" response = sns.publish(",
" TopicArn = topic,",
" Message = msg",
" )",
"#Lambda handler function",
"def lambda_handler(event, context):",
" res = fsx.describe_file_systems(",
" FileSystemIds = ",
{
"Ref": "FSIds"
},
" )",
" for i in range(len(res[\"FileSystems\"])):",
" FS_ID = res[\"FileSystems\"][i][\"FileSystemId\"]",
" status = res[\"FileSystems\"][i][\"Lifecycle\"]",
" if status == \"MISCONFIGURED\" or status == \"FAILED\":",
" publish_message(FS_ID , status)",
]
]
}
},
"Role": "arn:aws:iam::123456789:role/FSx-LambdaRole",
"Runtime": "python3.9",
"Timeout": "60",
"Tags": [
{
"Key": "Owner",
"Value": "God"
}
]
}
}
}
}
在创建堆栈时,我将参数的输入指定为:fs-123,fs-456
请帮忙!!
最佳答案
该错误是由参数的 CommaDelimitedList
类型间接引起的。它导致 FSIds
成为列表/数组而不是字符串,这意味着 Fn::Join
字符串列表中的此项不是字符串:
{
"Ref": "FSIds"
},
如果您将参数类型更改为String
,它将为您创建堆栈。
或者,您可以保留 CommaDelimitedList
并将上面的内容更改为:
{
"Fn::Join": [ ",", { "Ref": "FSIds" } ]
},
其中任何一个至少都会让您克服当前遇到的错误。
更新:
正如您所指出的,FileSystemIds
实际上需要是一个列表,因此您有几个选项:
{
"Fn::Join": [
"",
[
" FileSystemIds = [\"",
{
"Fn::Join": [
"\", \"",
{
"Ref": "FSIds"
}
]
},
"\""
]
]
},
str.split()
完成一些工作,例如像这样(请注意,这两者都假设 FSIds
仍然是 CommaDelimitedList
): {
"Fn::Join": [
"",
[
" FileSystemIds = str.split(\"",
{ "Fn::Join": [ ",", { "Ref": "FSIds" } ] },
"\", \",\")"
]
},
},
关于amazon-web-services - 内联 Lambda CFT "Fn::Join"错误 - JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73251898/
我读到this description了解如何将 Cloud Formation Template (CFT) 导入到您的 CDK 代码中。 这很有趣,但似乎没有办法在 CDK 代码中使用 CFT 创
我有一个 CloudFormation 模板 yml 文件,它为 ElasticBeanstalk 应用程序传递 OptionSettings。我可以对值进行硬编码,并且可以从参数传递值。但是,我无法
如何将 Cloudformation 模板限制为特定帐户。我可以限制或让 Cloudformation 使用硬编码的帐号验证 AWS 帐号吗?有什么办法吗? 最佳答案 您可以创建一个 CloudFor
我已经从云前创建了以下 CFT,我对 CFT 非常陌生,但出现了以下错误 [/Resources/Description] resource definition is malformed 我尝试并
我在 AWS 中几乎没有使用 Terraform 启动的资源,其中一些是使用 AWS 控制台手动创建的。一些资源是使用 Cloudformation 模板启动的。 我知道 Cloudformation
崩溃容错 (CFT) 是一种弹性级别,如果组件发生故障,系统仍然可以正确达成共识。而拜占庭容错 (BFT) 表示,即使存在恶意行为者,订购者也可以完成其工作。以下是我的问题 CFT 对单个企业更有用。
我只想发送 Cloudformation 创建的 S3 存储桶的名称。如果我选择 SNS 通知,它将发送有关完整 CFT 堆栈创建事件的通知。我们可以自定义通知以将 S3 存储桶名称发送给用户吗在 A
尝试创建允许相同账户角色和跨账户角色的存储桶策略。 这里CicdDeploymentRoleArn是跨账户角色arns的列表。 Parameters: CicdDeploymentRoleArn:
尝试为 RDS 创建一个可以处理这两种情况的 CFT创建新的 RDS Aurora MySQL 集群并使用现有数据库集群快照创建 RDS 集群 这是我尝试过的, 我已经提供了模板的以下条件部分 "Us
想知道 CFT API 或来自 Cloudtrail 的日志是否可以在创建资源之前或同时提供任何中间 CFT。当我指的是中间 CFT 时,我们知道 CFT 可以是动态的,其形式是参数/条件/映射/函数
我在模板中使用以下行 "ec2instance" : { "Type" : "AWS::EC2::Instance", "Properties" : { "InstanceT
我想要一个云形成模板来列出特定区域的所有 lambda 函数。我不需要使用列表函数编写 lambda 代码并在我的 CFT 中调用它。 我尝试将 CLI 命令合并到 CFT 中,但没有成功 最佳答案
我正在尝试创建一个 CFT,其中包含1. 具有托管策略的 3 个不同角色2. INline策略应该添加到CFT中创建的三个角色中。 但我无法这样做,因为这会引发错误,说明必须定义至少一个资源。 请帮助
我正在使用 CFT 创建一项 IAM 策略,该策略仅允许单独访问一个 S3 存储桶(该存储桶也是在同一 CFT 本身中创建的)。这是CFT的问题所在的部分 { "AWSTemplate
我可以检查谁在 AWS 中创建了 CFT 堆栈吗?有没有办法在不使用云跟踪的情况下检查谁创建了堆栈? 最佳答案 创建堆栈时添加标签或一些输出。 如果您不想这样做,那么 Cloud Trail 是唯一的
我还是 AWS 服务的新手。 我想使用 CloudFormation 模板 (CFT) 在现有 S3 存储桶上添加 Lambda 触发器。这可能吗? 以下 CFT 正在尝试创建新的 S3 存储桶并在其
在CloudFormation模板中,我们可以从DNS名称中获取HostedZoneId吗?一种方法是我们检查资源并查找 HostedZoneId 并将其插入。我们还可以使用 GetAtt 或任何其他
我很难弄清楚在应用新的更改集模板时如何使用当前堆栈中的值。正如您可以想象的那样,堆栈的许多当前配置参数将需要重新应用一组新的参数。但是,我确实找不到有关如何执行此操作的明确文档。 到目前为止,我正在研
您好,我最近为我的 lambda 和 sqs(都在同一账户/区域)制作了一个 CFT,但我注意到当我进入 aws 控制台时,它在“输入端”和“我的 lambda 的输出端”。这是故意的吗?或者我只是错
我正在尝试设置一个 SNS 系统,以便在构建失败时发送电子邮件。目前,我只是将其设置为在达到几个不同阶段时发送通知以进行测试。 我已经按照 AWS 的教程学习了很多次,所以我已经记住了整个过程,但是当
我是一名优秀的程序员,十分优秀!