Problem with declaring S3 bucket

Hello All,

I want to host a static website using an S3 bucket. I have written the following code:

module "s3" {
  source = "terraform-aws-modules/s3-bucket/aws"
  version = "1.19.0"

  bucket = "s3bucketcopeland"
  acl    = "public-read"

  versioning = {
    enabled = true
  }

  website = {
    index_document = "index.html"
    error_document = "error.html"
  }

  tags = {
    Environment = "dev"
    Terraform   = "true"
  }
}

resource "aws_s3_bucket_website_configuration" "s3bucketcopeland"{
  bucket = aws_s3_bucket.s3bucketcopeland.id
  
  index_document = "index.html"
  error_document = "error.html"
}

Yet, I receive the following error:

 A managed resource "aws_s3_bucket" "s3bucketcopeland" has not been declared in the root module.

I thought that I was declaring the bucket with the module entry. What am I getting wrong?

In order for this to be valid:

you would need to have a block elsewhere in the same directory of your configuration like:

resource "aws_s3_bucket" "s3bucketcopeland" {
  ...
}

But you don’t, you have:

module "s3" {

Therefore:

I made some slight modifications:

module "s3-bucket" {
  source  = "terraform-aws-modules/s3-bucket/aws"
  version = "3.7.0"
}

resource "aws_s3_bucket_acl" "s3bucketcopeland"{
  bucket = aws_s3_bucket.s3bucketcopeland.id
  acl    = "public-read"
}

resource "aws_s3_bucket_website_configuration" "s3bucketcopeland"{
  bucket = aws_s3_bucket.s3bucketcopeland.id
  
  index_document = "index.html"
  error_document = "error.html"
}

but I am still receiving the same errors.