Skip to content

fix(aws): add validation for prefix in gitlab_ref_arch_aws

Andrew Newdigate requested to merge add-validation-for-prefix into master

What does this MR do?

While deploying a new GET environment, I used an underscore character in the prefix.

Half-way through the provisioning process, it failed with:


│ Error: Error validating S3 bucket name: only lowercase alphanumeric characters and hyphens allowed in "test_mr_318-registry"

│   with module.test_arch.aws_s3_bucket.gitlab_object_storage_buckets["registry"],
│   on ../get/terraform/modules/gitlab_ref_arch_aws/storage.tf line 1, in resource "aws_s3_bucket" "gitlab_object_storage_buckets":
│    1: resource "aws_s3_bucket" "gitlab_object_storage_buckets" {



│ Error: Error validating S3 bucket name: only lowercase alphanumeric characters and hyphens allowed in "test_mr_318-dependency-proxy"

│   with module.test_arch.aws_s3_bucket.gitlab_object_storage_buckets["dependency-proxy"],
│   on ../get/terraform/modules/gitlab_ref_arch_aws/storage.tf line 1, in resource "aws_s3_bucket" "gitlab_object_storage_buckets":
│    1: resource "aws_s3_bucket" "gitlab_object_storage_buckets" {



│ Error: Error validating S3 bucket name: only lowercase alphanumeric characters and hyphens allowed in "test_mr_318-lfs"

│   with module.test_arch.aws_s3_bucket.gitlab_object_storage_buckets["lfs"],
│   on ../get/terraform/modules/gitlab_ref_arch_aws/storage.tf line 1, in resource "aws_s3_bucket" "gitlab_object_storage_buckets":
│    1: resource "aws_s3_bucket" "gitlab_object_storage_buckets" {



│ Error: Error validating S3 bucket name: only lowercase alphanumeric characters and hyphens allowed in "test_mr_318-packages"

│   with module.test_arch.aws_s3_bucket.gitlab_object_storage_buckets["packages"],
│   on ../get/terraform/modules/gitlab_ref_arch_aws/storage.tf line 1, in resource "aws_s3_bucket" "gitlab_object_storage_buckets":
│    1: resource "aws_s3_bucket" "gitlab_object_storage_buckets" {



│ Error: Error validating S3 bucket name: only lowercase alphanumeric characters and hyphens allowed in "test_mr_318-terraform-state"

│   with module.test_arch.aws_s3_bucket.gitlab_object_storage_buckets["terraform-state"],
│   on ../get/terraform/modules/gitlab_ref_arch_aws/storage.tf line 1, in resource "aws_s3_bucket" "gitlab_object_storage_buckets":
│    1: resource "aws_s3_bucket" "gitlab_object_storage_buckets" {



│ Error: Error validating S3 bucket name: only lowercase alphanumeric characters and hyphens allowed in "test_mr_318-backups"

│   with module.test_arch.aws_s3_bucket.gitlab_object_storage_buckets["backups"],
│   on ../get/terraform/modules/gitlab_ref_arch_aws/storage.tf line 1, in resource "aws_s3_bucket" "gitlab_object_storage_buckets":
│    1: resource "aws_s3_bucket" "gitlab_object_storage_buckets" {



│ Error: Error validating S3 bucket name: only lowercase alphanumeric characters and hyphens allowed in "test_mr_318-mr-diffs"

│   with module.test_arch.aws_s3_bucket.gitlab_object_storage_buckets["mr-diffs"],
│   on ../get/terraform/modules/gitlab_ref_arch_aws/storage.tf line 1, in resource "aws_s3_bucket" "gitlab_object_storage_buckets":
│    1: resource "aws_s3_bucket" "gitlab_object_storage_buckets" {



│ Error: Error validating S3 bucket name: only lowercase alphanumeric characters and hyphens allowed in "test_mr_318-artifacts"

│   with module.test_arch.aws_s3_bucket.gitlab_object_storage_buckets["artifacts"],
│   on ../get/terraform/modules/gitlab_ref_arch_aws/storage.tf line 1, in resource "aws_s3_bucket" "gitlab_object_storage_buckets":
│    1: resource "aws_s3_bucket" "gitlab_object_storage_buckets" {



│ Error: Error validating S3 bucket name: only lowercase alphanumeric characters and hyphens allowed in "test_mr_318-uploads"

│   with module.test_arch.aws_s3_bucket.gitlab_object_storage_buckets["uploads"],
│   on ../get/terraform/modules/gitlab_ref_arch_aws/storage.tf line 1, in resource "aws_s3_bucket" "gitlab_object_storage_buckets":
│    1: resource "aws_s3_bucket" "gitlab_object_storage_buckets" {


Error: exit status 1

This MR adds validation to ensure that this case is caught before Terraform starts provisioning the account.

Note: I have specifically avoided the - character as using this in the prefix could caused complications further one with IAM permissions and wildcards.

Related issues

Author's checklist

When ready for review, the Author applies the workflowready for review label:

  • Merge request:
    • Corresponding Issue raised and reviewed by the GET maintainers team.
    • Merge Request Title and Description are up to date, accurate, and descriptive
    • MR targeting the appropriate branch
    • MR has a green pipeline
  • Code:
    • Check the area changed works as expected. Consider testing it in different environment sizes (1k,3k,10k,etc.).
    • Documentation created/updated in the same MR.
    • If this MR adds an optional configuration - check that all permutations continue to work.
    • For Terraform changes: setup a previous version environment, then run a terraform plan with your new changes and ensure nothing will be destroyed. If anything will be destroyed and this can't be avoided please add a comment to the current MR.
  • Create any follow-up issue(s) to support the new feature across other supported cloud providers or advanced configurations. Create 1 issue for each provider/configuration. Contact the Quality Enablement team if unsure.
Edited by Andrew Newdigate

Merge request reports