Reputation: 31
This is the detailed error I get after terraform apply
│ Error: Error validating S3 bucket name: only lowercase alphanumeric characters and hyphens allowed in "$var.bucket"
│
│ with module.s3.aws_s3_bucket.b,
│ on modules/s3/main.tf line 1, in resource "aws_s3_bucket" "b":
│ 1: resource "aws_s3_bucket" "b" {
This is main.tf
resource "aws_s3_bucket" "b" {
bucket = "$var.bucket"
tags = {
Name = "$var.tag"
Environment = "$var.environment"
}
}
This variables.tf
variable "bucket" {
description = "The Dev Environment"
}
variable "tag" {
description = "Tagging the bucket"
}
variable "environment" {
description = "Environment of the bucket"
}
This is module's main.tf
module "s3" {
source = "./modules/s3"
environment = var.environment
bucket = var.bucket
tag = var.tag
}
I tried fixing the error however I don't understand the error because everything seems perfect.
Upvotes: 1
Views: 1696
Reputation: 238967
Instead of
bucket = "$var.bucket"
it should be
bucket = var.bucket
also the devault value for the bucket is wrong and does not satisfy s3 naming requirements. Try with:
variable "bucket" {
description = "the-dev-environment-434331"
}
Upvotes: 1