nebari icon indicating copy to clipboard operation
nebari copied to clipboard

[BUG] - Project Names and Namespaces with Underscores Break in Certain Providers

Open kenafoster opened this issue 2 years ago â€Ē 1 comments

Describe the bug

Project names and namespaces with underscores break because they're not DNS compliant (or escaped). The first time this issue is encountered when deploying in AWS is trying to create S3 bucket because it used the pattern [project_name]-[namespace]-terraform-state. But if that were updated there would surely be others in later stages (most K8S resource names must be DNS compliant, and so _ are illegal).

Expected behavior

Project names and namespaces that are legal as defined by Nebari should be able to successfully create resources.

OS and architecture in which you are running Nebari

Ubuntu 22.04 amd64

How to Reproduce the problem?

nebari init aws -p test_project nebari deploy -c nebari-config.yaml

Command output

[terraform]: │ Error: validating S3 Bucket (test_project-dev-terraform-state) name: only lowercase alphanumeric characters and hyphens allowed in "test_project-dev-terraform-state"
[terraform]: │ 
[terraform]: │   with module.terraform-state.aws_s3_bucket.terraform-state,
[terraform]: │   on modules/terraform-state/main.tf line 1, in resource "aws_s3_bucket" "terraform-state":
[terraform]: │    1: resource "aws_s3_bucket" "terraform-state" {

Versions and dependencies used.

No response

Compute environment

None

Integrations

No response

Anything else?

No response

kenafoster avatar Sep 12 '23 19:09 kenafoster

We are using the terraform version From terraform version v3.28.0 terraform plan will fail if the bucket name has underscores for AWS. Link to bugfix in terrafrom ticket.

But upgrading the Terraform will not prevent nebari deploy from failing. I would recommend that we add validations in Nebari Wizard.

  1. Add validation in Wizard to check if the provider is AWS, then don't allow _s in the project name.

    • Pro: It's an easy fix.
    • Con: Naming conventions can differ for different cloud providers.
  2. Enforce validation for all providers.

    • Pro:
      • Even easier to add it to Wizard.
      • Consistent naming conventions across all providers.
      • Switching providers can become easier.
    • Con:
      • All the providers need to be tested.

pt247 avatar Dec 20 '23 12:12 pt247