Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon s3 使用Terraform v0.12将aws_s3_bucket_策略添加到bucket列表中_Amazon S3_Terraform - Fatal编程技术网

Amazon s3 使用Terraform v0.12将aws_s3_bucket_策略添加到bucket列表中

Amazon s3 使用Terraform v0.12将aws_s3_bucket_策略添加到bucket列表中,amazon-s3,terraform,Amazon S3,Terraform,我想创建一个策略模板,并将其应用于存储桶列表,但在将当前存储桶的名称放入策略时遇到问题。Terraform返回错误 "Error: Error putting S3 policy: MalformedPolicy: Policy has invalid resource" 两次。计划运行良好,策略的输出看起来不错等等 variable "s3_bucket_list" { type = list(string) description = "List of

我想创建一个策略模板,并将其应用于存储桶列表,但在将当前存储桶的名称放入策略时遇到问题。Terraform返回错误

"Error: Error putting S3 policy: MalformedPolicy: Policy has invalid resource"
两次。计划运行良好,策略的输出看起来不错等等

variable "s3_bucket_list" 
  { 
    type        = list(string)
    description = "List of buckets to secure"
    default     = ["bucket1","bucket2"]   
   }
资源“aws\u s3\u bucket”“qpp安全bucket”{
计数=长度(变量s3\u桶\u列表)
bucket=var.s3\u bucket\u list[count.index]
}
资源“aws\U s3\U桶策略”“最小\U s3\U桶策略”{
计数=长度(变量s3\u桶\u列表)
bucket=var.s3\u bucket\u list[count.index]
策略=正确的策略是

resource "aws_s3_bucket_policy" "secure-bucket" {
  count  = length(var.s3_bucket_list)
  bucket = var.s3_bucket_list[count.index]

  policy = <<POLICY {   "Version": "2012-10-17",   "Statement": [
    {
      "Sid": "DenyUnencryptedCommunication",
      "Action": "s3:*",
      "Effect": "Deny",
      "Resource": [
         "arn:aws:s3:::${var.s3_bucket_list[count.index]}",
         "arn:aws:s3:::${var.s3_bucket_list[count.index]}/*"      
        ],
      "Condition": {
        "Bool": {
          "aws:SecureTransport": "false"
        }
      },
      "Principal": "*"
    }   ] } POLICY

}
resource“aws\u s3\u bucket\u策略”“安全bucket”{
计数=长度(变量s3\u桶\u列表)
bucket=var.s3\u bucket\u list[count.index]
政策=
resource "aws_s3_bucket_policy" "secure-bucket" {
  count  = length(var.s3_bucket_list)
  bucket = var.s3_bucket_list[count.index]

  policy = <<POLICY {   "Version": "2012-10-17",   "Statement": [
    {
      "Sid": "DenyUnencryptedCommunication",
      "Action": "s3:*",
      "Effect": "Deny",
      "Resource": [
         "arn:aws:s3:::${var.s3_bucket_list[count.index]}",
         "arn:aws:s3:::${var.s3_bucket_list[count.index]}/*"      
        ],
      "Condition": {
        "Bool": {
          "aws:SecureTransport": "false"
        }
      },
      "Principal": "*"
    }   ] } POLICY

}