Skip to content

Commit

Permalink
feat: Add possibility to specify Gitlab CI/CD variables suffix for de…
Browse files Browse the repository at this point in the history
…ploy user
  • Loading branch information
joli-sys committed Sep 27, 2024
1 parent 9e70369 commit 59ac08a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module "static-site" {

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.67.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 5.27 |

## Modules

Expand Down Expand Up @@ -128,6 +128,7 @@ module "static-site" {

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_aws_env_vars_suffix"></a> [aws\_env\_vars\_suffix](#input\_aws\_env\_vars\_suffix) | Append suffix for Gitlab CI/CD environment variables if needed | `string` | `""` | no |
| <a name="input_cloudfront_price_class"></a> [cloudfront\_price\_class](#input\_cloudfront\_price\_class) | CloudFront price class | `string` | `"PriceClass_100"` | no |
| <a name="input_default_ttl"></a> [default\_ttl](#input\_default\_ttl) | Default amount of time that you want objects to stay in a CloudFront cache | `number` | `3600` | no |
| <a name="input_domain_zone_id"></a> [domain\_zone\_id](#input\_domain\_zone\_id) | The ID of the hosted zone for domain | `string` | n/a | yes |
Expand Down
1 change: 1 addition & 0 deletions deploy.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module "gitlab" {
aws_access_key_id = aws_iam_access_key.deploy[0].id
aws_secret_access_key = aws_iam_access_key.deploy[0].secret
aws_default_region = data.aws_region.current.name
aws_env_vars_suffix = var.aws_env_vars_suffix
}

moved {
Expand Down
1 change: 1 addition & 0 deletions modules/gitlab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ No modules.
| <a name="input_aws_access_key_id"></a> [aws\_access\_key\_id](#input\_aws\_access\_key\_id) | n/a | `string` | n/a | yes |
| <a name="input_aws_cloudfront_distribution_id"></a> [aws\_cloudfront\_distribution\_id](#input\_aws\_cloudfront\_distribution\_id) | n/a | `string` | n/a | yes |
| <a name="input_aws_default_region"></a> [aws\_default\_region](#input\_aws\_default\_region) | n/a | `string` | n/a | yes |
| <a name="input_aws_env_vars_suffix"></a> [aws\_env\_vars\_suffix](#input\_aws\_env\_vars\_suffix) | n/a | `string` | `""` | no |
| <a name="input_aws_s3_bucket_name"></a> [aws\_s3\_bucket\_name](#input\_aws\_s3\_bucket\_name) | n/a | `string` | n/a | yes |
| <a name="input_aws_secret_access_key"></a> [aws\_secret\_access\_key](#input\_aws\_secret\_access\_key) | n/a | `string` | n/a | yes |
| <a name="input_gitlab_environment"></a> [gitlab\_environment](#input\_gitlab\_environment) | n/a | `string` | `"*"` | no |
Expand Down
10 changes: 5 additions & 5 deletions modules/gitlab/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ resource "gitlab_project_variable" "s3_bucket" {
masked = false
raw = true

key = "AWS_S3_BUCKET"
key = "AWS_S3_BUCKET${var.aws_env_vars_suffix}"
value = var.aws_s3_bucket_name

environment_scope = var.gitlab_environment
Expand All @@ -22,7 +22,7 @@ resource "gitlab_project_variable" "aws_default_region" {
masked = false
raw = true

key = "AWS_DEFAULT_REGION"
key = "AWS_DEFAULT_REGION${var.aws_env_vars_suffix}"
value = var.aws_default_region

environment_scope = var.gitlab_environment
Expand All @@ -35,7 +35,7 @@ resource "gitlab_project_variable" "cloudfront_distribution_id" {
masked = false
raw = true

key = "AWS_CF_DISTRIBUTION_ID"
key = "AWS_CF_DISTRIBUTION_ID${var.aws_env_vars_suffix}"
value = var.aws_cloudfront_distribution_id

environment_scope = var.gitlab_environment
Expand All @@ -48,7 +48,7 @@ resource "gitlab_project_variable" "site_aws_access_key_id" {
masked = false
raw = true

key = "AWS_ACCESS_KEY_ID"
key = "AWS_ACCESS_KEY_ID${var.aws_env_vars_suffix}"
value = var.aws_access_key_id

environment_scope = var.gitlab_environment
Expand All @@ -61,7 +61,7 @@ resource "gitlab_project_variable" "site_aws_secret_access_key" {
masked = true
raw = true

key = "AWS_SECRET_ACCESS_KEY"
key = "AWS_SECRET_ACCESS_KEY${var.aws_env_vars_suffix}"
value = var.aws_secret_access_key

environment_scope = var.gitlab_environment
Expand Down
5 changes: 5 additions & 0 deletions modules/gitlab/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ variable "aws_secret_access_key" {
variable "aws_default_region" {
type = string
}

variable "aws_env_vars_suffix" {
type = string
default = ""
}
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,9 @@ variable "max_ttl" {
type = number
default = 86400
}

variable "aws_env_vars_suffix" {
description = "Append suffix for Gitlab CI/CD environment variables if needed"
type = string
default = ""
}

0 comments on commit 59ac08a

Please sign in to comment.