File tree Expand file tree Collapse file tree 5 files changed +19
-8
lines changed Expand file tree Collapse file tree 5 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ module "static-site" {
102102| ------| --------| ---------|
103103| <a name =" module_certificate " ></a > [ certificate] ( #module\_ certificate ) | terraform-aws-modules/acm/aws | 5.1.1 |
104104| <a name =" module_gitlab " ></a > [ gitlab] ( #module\_ gitlab ) | ./modules/gitlab | n/a |
105- | <a name =" module_s3_bucket " ></a > [ s3\_ bucket] ( #module\_ s3\_ bucket ) | terraform-aws-modules/s3-bucket/aws | 4.6.1 |
105+ | <a name =" module_s3_bucket " ></a > [ s3\_ bucket] ( #module\_ s3\_ bucket ) | terraform-aws-modules/s3-bucket/aws | 4.7.0 |
106106
107107## Resources
108108
Original file line number Diff line number Diff line change @@ -36,7 +36,6 @@ data "aws_iam_policy_document" "assume_role" {
3636resource "aws_iam_role" "deploy" {
3737 count = var. enable_deploy_role ? 1 : 0
3838 assume_role_policy = data. aws_iam_policy_document . assume_role [0 ]. json
39- description = format (" Role used by the GitLab project %s" , " GITLAB_PROJECT_PLACEHOLDER" )
4039 name = " zvirt-${ local . main_domain_sanitized } -deploy"
4140 tags = var. tags
4241}
@@ -99,11 +98,13 @@ module "gitlab" {
9998 gitlab_project_ids = local. gitlab_project_ids
10099 gitlab_environment = var. gitlab_environment
101100
101+ enable_deploy_role = var. enable_deploy_role
102+ enable_deploy_user = var. enable_deploy_user
102103 aws_s3_bucket_name = module. s3_bucket . s3_bucket_id
103104 aws_cloudfront_distribution_id = aws_cloudfront_distribution. this . id
104- aws_role_arn = aws_iam_role. deploy [0 ]. arn
105- aws_access_key_id = aws_iam_access_key. deploy [0 ]. id
106- aws_secret_access_key = aws_iam_access_key. deploy [0 ]. secret
105+ aws_role_arn = var . enable_deploy_role ? aws_iam_role. deploy [0 ]. arn : null
106+ aws_access_key_id = var . enable_deploy_user ? aws_iam_access_key. deploy [0 ]. id : null
107+ aws_secret_access_key = var . enable_deploy_user ? aws_iam_access_key. deploy [0 ]. secret : null
107108 aws_default_region = data. aws_region . current . name
108109 aws_env_vars_suffix = var. aws_env_vars_suffix
109110}
Original file line number Diff line number Diff line change @@ -85,6 +85,8 @@ No modules.
8585| <a name =" input_aws_role_arn " ></a > [ aws\_ role\_ arn] ( #input\_ aws\_ role\_ arn ) | n/a | ` string ` | n/a | yes |
8686| <a name =" input_aws_s3_bucket_name " ></a > [ aws\_ s3\_ bucket\_ name] ( #input\_ aws\_ s3\_ bucket\_ name ) | n/a | ` string ` | n/a | yes |
8787| <a name =" input_aws_secret_access_key " ></a > [ aws\_ secret\_ access\_ key] ( #input\_ aws\_ secret\_ access\_ key ) | n/a | ` string ` | n/a | yes |
88+ | <a name =" input_enable_deploy_role " ></a > [ enable\_ deploy\_ role] ( #input\_ enable\_ deploy\_ role ) | n/a | ` bool ` | n/a | yes |
89+ | <a name =" input_enable_deploy_user " ></a > [ enable\_ deploy\_ user] ( #input\_ enable\_ deploy\_ user ) | n/a | ` bool ` | n/a | yes |
8890| <a name =" input_gitlab_environment " ></a > [ gitlab\_ environment] ( #input\_ gitlab\_ environment ) | n/a | ` string ` | ` "*" ` | no |
8991| <a name =" input_gitlab_project_ids " ></a > [ gitlab\_ project\_ ids] ( #input\_ gitlab\_ project\_ ids ) | n/a | ` list(string) ` | n/a | yes |
9092
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ resource "gitlab_project_variable" "cloudfront_distribution_id" {
4949}
5050
5151resource "gitlab_project_variable" "site_aws_role_arn" {
52- for_each = data. gitlab_project . this
52+ for_each = var . enable_deploy_role ? data. gitlab_project . this : {}
5353
5454 project = each. value . id
5555
@@ -64,7 +64,7 @@ resource "gitlab_project_variable" "site_aws_role_arn" {
6464}
6565
6666resource "gitlab_project_variable" "site_aws_access_key_id" {
67- for_each = data. gitlab_project . this
67+ for_each = var . enable_deploy_user ? data. gitlab_project . this : {}
6868
6969 project = each. value . id
7070
@@ -79,7 +79,7 @@ resource "gitlab_project_variable" "site_aws_access_key_id" {
7979}
8080
8181resource "gitlab_project_variable" "site_aws_secret_access_key" {
82- for_each = data. gitlab_project . this
82+ for_each = var . enable_deploy_user ? data. gitlab_project . this : {}
8383
8484 project = each. value . id
8585
Original file line number Diff line number Diff line change @@ -23,6 +23,14 @@ variable "aws_access_key_id" {
2323 type = string
2424}
2525
26+ variable "enable_deploy_role" {
27+ type = bool
28+ }
29+
30+ variable "enable_deploy_user" {
31+ type = bool
32+ }
33+
2634variable "aws_secret_access_key" {
2735 type = string
2836 sensitive = true
You can’t perform that action at this time.
0 commit comments