从Terraform上传AWS S3中的多个文件 [英] Uploading Multiple files in AWS S3 from terraform
本文介绍了从Terraform上传AWS S3中的多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从本地设备中的特定文件夹将多个文件上传到AWS S3.我遇到以下错误.在此处输入图片描述
I want to upload multiple files to AWS S3 from a specific folder in my local device. I am running into the following error. enter image description here
这是我的Terraform代码.
Here is my terraform code.
resource "aws_s3_bucket" "testbucket" {
bucket = "test-terraform-pawan-1"
acl = "private"
tags = {
Name = "test-terraform"
Environment = "test"
}
}
resource "aws_s3_bucket_object" "uploadfile" {
bucket = "test-terraform-pawan-1"
key = "index.html"
source = "/home/pawan/Documents/Projects/"
}
我不知道我哪里错了.我该如何解决这个问题?
I don't know where I am wrong. How can I solve this problem?
推荐答案
您正在尝试上载目录,而Terraform希望在源字段中输入一个文件.尚不支持将文件夹上载到S3存储桶.
You are trying to upload a directory, whereas Terraform expects a single file in the source field. It is not yet supported to upload a folder to an S3 bucket.
但是,您可以按照建议此处使用null_resource设置程序调用awscli命令..
However, you can invoke awscli commands using null_resource provisioner, as suggested here.
resource "null_resource" "remove_and_upload_to_s3" {
provisioner "local-exec" {
command = "aws s3 sync ${path.module}/s3Contents s3://${aws_s3_bucket.site.id}"
}
}
这篇关于从Terraform上传AWS S3中的多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文