简体   繁体   English

使用 Terraform 创建 S3 存储桶后出错

[英]Error after Creating S3 bucket with Terraform

I created an s3 bucket in terraform.我在 terraform 中创建了一个 s3 存储桶。 However after creating this bucket, I am getting the error: error getting S3 Bucket Object Lock configuration: AccessDenied: Access Denied但是在创建此存储桶后,我收到错误消息:错误获取 S3 存储桶 Object 锁定配置:AccessDenied: Access Denied

I am using AWS academy so I do not have many permissions, however, there is a role in AWS academy that allows the user to do stuff with s3.我使用的是 AWS 学院,所以我没有太多权限,但是,AWS 学院中有一个角色允许用户使用 s3 做事。 Is there a way to attach this IAM role to the S3 bucket so access it via Terraform?有没有办法将此 IAM 角色附加到 S3 存储桶,以便通过 Terraform 访问它?

I would like to upload images to this bucket, however I can no longer deploy code due to Terraform trying to access the Object Lock Configuration which it does not have access to.我想将图像上传到此存储桶,但是由于 Terraform 试图访问它无法访问的 Object 锁定配置,我无法再部署代码。 Is there a way to tell terraform to not try to not try to get this information?有没有办法告诉 terraform 不要尝试不要尝试获取此信息?

Here is my code这是我的代码

resource "aws_s3_bucket" "b" {
  bucket = "my-tf-test-bucket"
  acl    = "private"

  tags = {
    Name        = "My bucket"
    Environment = "Dev"
  }
}

Image of Console控制台图片

So it seems that you have enable object lock to your bucket which prevents you to write or delete any files in your s3 bucket.因此,您似乎已对您的存储桶启用 object 锁定,这会阻止您写入或删除 s3 存储桶中的任何文件。

One way is to disable it from the console and refresh the state of terraform.一种方法是从控制台禁用它并刷新 terraform 的 state。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM