避免在目录Terraform中重复代码以归档文件
我在下面的文件中定义了lambda函数:
../lambda_functions
├── index_to_s3.py
├── from_s3.py
├── to_s3.py
├── to_fetch.py
├── sql_fetch.py
└── sql_def.py
我想将这些功能中的每个功能存档到自己的zip文件中,然后将每个功能作为单独的lambda上传。目前,我必须重复此代码
data "archive_file" "from_s3" {
type = "zip"
source_file = local.from_s3_source
output_path = local.from_s3_output
}
以使每个lambda能够执行此操作。是否有一种保持代码干燥的最佳方法?
I lambda functions defined in the files below:
../lambda_functions
├── index_to_s3.py
├── from_s3.py
├── to_s3.py
├── to_fetch.py
├── sql_fetch.py
└── sql_def.py
I want to archive each one of these functions into their own zip file and upload each as a separate lambda. Currently, I have to repeat this code
data "archive_file" "from_s3" {
type = "zip"
source_file = local.from_s3_source
output_path = local.from_s3_output
}
for each lambda to be able to do this. Is there an optimal way to keep the code dry?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以组合 for_each 和 fileset 为此:
You can combine for_each and fileset for this: