Skip to content

Commit a348e2d

Browse files
authored
Merge pull request #15 from cookielab/aws_env_suffix
feat: Add possibility to specify Gitlab CI/CD variables suffix for deploy user
2 parents 9e70369 + 59ac08a commit a348e2d

File tree

6 files changed

+20
-6
lines changed

6 files changed

+20
-6
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ module "static-site" {
9292

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

9797
## Modules
9898

@@ -128,6 +128,7 @@ module "static-site" {
128128

129129
| Name | Description | Type | Default | Required |
130130
|------|-------------|------|---------|:--------:|
131+
| <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 |
131132
| <a name="input_cloudfront_price_class"></a> [cloudfront\_price\_class](#input\_cloudfront\_price\_class) | CloudFront price class | `string` | `"PriceClass_100"` | no |
132133
| <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 |
133134
| <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 |

deploy.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ module "gitlab" {
5454
aws_access_key_id = aws_iam_access_key.deploy[0].id
5555
aws_secret_access_key = aws_iam_access_key.deploy[0].secret
5656
aws_default_region = data.aws_region.current.name
57+
aws_env_vars_suffix = var.aws_env_vars_suffix
5758
}
5859

5960
moved {

modules/gitlab/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ No modules.
8080
| <a name="input_aws_access_key_id"></a> [aws\_access\_key\_id](#input\_aws\_access\_key\_id) | n/a | `string` | n/a | yes |
8181
| <a name="input_aws_cloudfront_distribution_id"></a> [aws\_cloudfront\_distribution\_id](#input\_aws\_cloudfront\_distribution\_id) | n/a | `string` | n/a | yes |
8282
| <a name="input_aws_default_region"></a> [aws\_default\_region](#input\_aws\_default\_region) | n/a | `string` | n/a | yes |
83+
| <a name="input_aws_env_vars_suffix"></a> [aws\_env\_vars\_suffix](#input\_aws\_env\_vars\_suffix) | n/a | `string` | `""` | no |
8384
| <a name="input_aws_s3_bucket_name"></a> [aws\_s3\_bucket\_name](#input\_aws\_s3\_bucket\_name) | n/a | `string` | n/a | yes |
8485
| <a name="input_aws_secret_access_key"></a> [aws\_secret\_access\_key](#input\_aws\_secret\_access\_key) | n/a | `string` | n/a | yes |
8586
| <a name="input_gitlab_environment"></a> [gitlab\_environment](#input\_gitlab\_environment) | n/a | `string` | `"*"` | no |

modules/gitlab/main.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ resource "gitlab_project_variable" "s3_bucket" {
99
masked = false
1010
raw = true
1111

12-
key = "AWS_S3_BUCKET"
12+
key = "AWS_S3_BUCKET${var.aws_env_vars_suffix}"
1313
value = var.aws_s3_bucket_name
1414

1515
environment_scope = var.gitlab_environment
@@ -22,7 +22,7 @@ resource "gitlab_project_variable" "aws_default_region" {
2222
masked = false
2323
raw = true
2424

25-
key = "AWS_DEFAULT_REGION"
25+
key = "AWS_DEFAULT_REGION${var.aws_env_vars_suffix}"
2626
value = var.aws_default_region
2727

2828
environment_scope = var.gitlab_environment
@@ -35,7 +35,7 @@ resource "gitlab_project_variable" "cloudfront_distribution_id" {
3535
masked = false
3636
raw = true
3737

38-
key = "AWS_CF_DISTRIBUTION_ID"
38+
key = "AWS_CF_DISTRIBUTION_ID${var.aws_env_vars_suffix}"
3939
value = var.aws_cloudfront_distribution_id
4040

4141
environment_scope = var.gitlab_environment
@@ -48,7 +48,7 @@ resource "gitlab_project_variable" "site_aws_access_key_id" {
4848
masked = false
4949
raw = true
5050

51-
key = "AWS_ACCESS_KEY_ID"
51+
key = "AWS_ACCESS_KEY_ID${var.aws_env_vars_suffix}"
5252
value = var.aws_access_key_id
5353

5454
environment_scope = var.gitlab_environment
@@ -61,7 +61,7 @@ resource "gitlab_project_variable" "site_aws_secret_access_key" {
6161
masked = true
6262
raw = true
6363

64-
key = "AWS_SECRET_ACCESS_KEY"
64+
key = "AWS_SECRET_ACCESS_KEY${var.aws_env_vars_suffix}"
6565
value = var.aws_secret_access_key
6666

6767
environment_scope = var.gitlab_environment

modules/gitlab/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ variable "aws_secret_access_key" {
2727
variable "aws_default_region" {
2828
type = string
2929
}
30+
31+
variable "aws_env_vars_suffix" {
32+
type = string
33+
default = ""
34+
}

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,9 @@ variable "max_ttl" {
131131
type = number
132132
default = 86400
133133
}
134+
135+
variable "aws_env_vars_suffix" {
136+
description = "Append suffix for Gitlab CI/CD environment variables if needed"
137+
type = string
138+
default = ""
139+
}

0 commit comments

Comments
 (0)