gpt4 book ai didi

amazon-web-services - AWS cfn-hup 配置中的 post.add、post.update 与 post.delete

转载 作者:行者123 更新时间:2023-12-03 07:17:06 28 4
gpt4 key购买 nike

根据AWS Documentation对于 CloudFormation cfn-hup 帮助程序脚本,cfn-hup Hook 可以具有“要检测的以逗号分隔的条件列表”。这些条件/触发器可以是 post.addpost.update 和/或 post.delete。然而,没有描述这些触发器的实际含义。 AWS 文档中的每个示例都只使用 post.update,到目前为止,这个触发器对我来说已经足够好了,但我想了解这些其他触发器的实际用途。有人可以解释一下吗?

最佳答案

以下是来自 2019 年 cfn 脚本版本的 update_hooks.py 代码片段,可在 https://pypi.org/project/aws-cfn-bootstrap/ 找到。 :

 def _process_hook(self, hook, metadata):
try:
new_data = self._retrieve_path_data(hook.path)
except InFlightStatusError:
return

old_data = self._jsonConverter.deserialize(metadata.get(hook.name + "|" + hook.path, None))

if 'post.add' in hook.triggers and not old_data and new_data:
log.info("Previous state not found; action for %s will be run", hook.name)
elif 'post.remove' in hook.triggers and old_data and not new_data:
log.info('Path %s was removed; action for %s will be run', hook.path, hook.name)
elif 'post.update' in hook.triggers and old_data and new_data and old_data != new_data:
log.info("Data has changed from previous state; action for %s will be run", hook.name)
else:
log.debug("No change in path %s for hook %s", hook.path, hook.name)
metadata[hook.name + "|" + hook.path] = self._jsonConverter.serialize(new_data)
JsonFileManager.write(self.dir, 'metadata_db.json', metadata)
return

因此,触发器适用于钩子(Hook)规范中指定的元数据路径,它可以指示元数据 block 内的节点,而不仅仅是整个 block 。

  • post.add:路径节点以前不存在,现在存在
  • post.remove 路径节点以前确实存在,但现在不存在
  • post.update路径节点以前存在,现在仍然存在,但内容发生了变化

在之前的评论中,有人明智地推测了这一点,但这里的代码证明了这一点。

关于amazon-web-services - AWS cfn-hup 配置中的 post.add、post.update 与 post.delete,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43421566/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com