我想从本地设备中的特定文件夹将多个文件上传到AWS S3。我遇到以下错误。
enter image description here

这是我的Terraform代码。

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/"

}

我不知道我哪里错了。我怎么解决这个问题?

最佳答案

您正在尝试上载目录,而Terraform在源字段中需要一个文件。尚不支持将文件夹上载到S3存储桶。

但是,您可以使用null_resource提供程序调用awscli命令,如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}"
  }
}

关于amazon-s3 - 从Terraform上传AWS S3中的多个文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57456167/

10-11 06:30
查看更多