Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate project name during "zero apply" #447

Open
aspcanada opened this issue Jan 19, 2022 · 2 comments
Open

Validate project name during "zero apply" #447

aspcanada opened this issue Jan 19, 2022 · 2 comments
Labels
bug Something isn't working good first issue Good first ticket, minimal dependencies

Comments

@aspcanada
Copy link

aspcanada commented Jan 19, 2022

I received several errors during zero apply. It appears that the project name that I chose (0play) should be validated to not accept names that start with a numeral. It appears that some AWS resources do not like names starting with a numeric.

Originally, I thought the issue was the domain that I registered (0play-stage.click).

Error: invalid value for replication_group_id (must begin with a letter)

│
│   with module.stage.module.cache[0].module.redis[0].aws_elasticache_replication_group.default[0],
│   on .terraform/modules/stage.cache.redis/main.tf line 83, in resource "aws_elasticache_replication_group" "default":
│   83:   replication_group_id          = var.replication_group_id == "" ? module.this.id : var.replication_group_id

Error: invalid value for domain_name (must start with a lowercase alphabet and be at least 3 and no more than 28 characters long. Valid characters are a-z (lowercase letters), 0-9, and - (hyphen).)

│   with module.stage.module.logging[0].module.elasticsearch.aws_elasticsearch_domain.default[0],
│   on .terraform/modules/stage.logging.elasticsearch/main.tf line 102, in resource "aws_elasticsearch_domain" "default":
│  102:   domain_name           = module.this.id

Error: first character of "name_prefix" must be a letter

│   with module.stage.module.db[0].module.rds_postgres[0].module.db_option_group.aws_db_option_group.this[0],
│   on .terraform/modules/stage.db.rds_postgres/modules/db_option_group/main.tf line 4, in resource "aws_db_option_group" "this":
│    4:   name_prefix              = var.name_prefix

Error: first character of parameter group "name_prefix" must be a letter

│   with module.stage.module.db[0].module.rds_postgres[0].module.db_parameter_group.aws_db_parameter_group.this[0],
│   on .terraform/modules/stage.db.rds_postgres/modules/db_parameter_group/main.tf line 36, in resource "aws_db_parameter_group" "this":
│   36:   name_prefix = var.name_prefix
│
╵
make[1]: *** [apply-env] Error 1
make: *** [make-apply] Error 2
2022/01/19 14:18:20 Module Apply failed: Module (zero-aws-eks-stack)
@bmonkman
Copy link
Contributor

Seems like this would be an issue with the project name rather than the domain name. This is a pain since the project name is used pretty extensively as an identifier in resource naming. A reasonable fix for now would be to add validation on the project name field to enforce starting it with a letter. In the long run it's probably a good idea to find the individual spots with these restrictions and make sure we are enforcing the right name format.

This would require a small tweak to the ValidateProjectName function in this project since the project name is the very first thing we prompt for, and not in the module parameter definitions.

@bmonkman bmonkman added bug Something isn't working good first issue Good first ticket, minimal dependencies labels Jan 25, 2022
@aspcanada aspcanada changed the title Invalid TLD domain "name" Validate project name during "zero apply" Jan 26, 2022
@aspcanada
Copy link
Author

Oh interesting... I didn't even think about the project name, I assumed it was an issue with my domain name choice. I'll update the summary and description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good first ticket, minimal dependencies
Projects
Status: Backlog
Development

No branches or pull requests

2 participants