resource "aws_s3_bucket" "infra_bucket" {
  bucket        = "a13labs.infra.eu"
  force_destroy = true
}

resource "aws_s3_bucket_public_access_block" "infra_bucket" {
  bucket = aws_s3_bucket.infra_bucket.id

  block_public_acls       = true
  ignore_public_acls      = true
  block_public_policy     = true
  restrict_public_buckets = true
}

resource "aws_s3_bucket_versioning" "infra_bucket" {
  bucket = aws_s3_bucket.infra_bucket.id

  versioning_configuration {
    status = "Enabled"
  }
}

resource "aws_s3_bucket_lifecycle_configuration" "infra_bucket" {
  bucket = aws_s3_bucket.infra_bucket.id

  rule {
    id     = "clenaup"
    status = "Enabled"
    filter {
      prefix = "/"
    }
    expiration {
      days = 30
    }
  }
}

import {
  id = "a13labs.infra.eu"
  to = aws_s3_bucket.infra_bucket
}

import {
  id = "a13labs.infra.eu"
  to = aws_s3_bucket_public_access_block.infra_bucket
}

import {
  id = "a13labs.infra.eu"
  to = aws_s3_bucket_versioning.infra_bucket
}
