From 073f0e3a25855f09574d51a69def3d5f80e5c030 Mon Sep 17 00:00:00 2001 From: sj-williams Date: Tue, 23 Apr 2024 16:44:36 +0100 Subject: [PATCH 1/3] set repo vars resource creation dependency on environments list --- main.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.tf b/main.tf index 68065aa..5706884 100644 --- a/main.tf +++ b/main.tf @@ -294,7 +294,7 @@ resource "aws_iam_role_policy_attachment" "github_ecr" { # Actions resource "github_actions_secret" "ecr_role_to_assume" { - for_each = local.enable_github ? local.github_repos : [] + for_each = (length(var.github_environments) == 0 && local.enable_github) ? local.github_repos : [] repository = each.value secret_name = local.github_variable_names["ECR_ROLE_TO_ASSUME"] @@ -302,7 +302,7 @@ resource "github_actions_secret" "ecr_role_to_assume" { } resource "github_actions_variable" "ecr_region" { - for_each = local.enable_github ? local.github_repos : [] + for_each = (length(var.github_environments) == 0 && local.enable_github) ? local.github_repos : [] repository = each.value variable_name = local.github_variable_names["ECR_REGION"] @@ -310,7 +310,7 @@ resource "github_actions_variable" "ecr_region" { } resource "github_actions_variable" "ecr_repository" { - for_each = local.enable_github ? local.github_repos : [] + for_each = (length(var.github_environments) == 0 && local.enable_github) ? local.github_repos : [] repository = each.value variable_name = local.github_variable_names["ECR_REPOSITORY"] From 79ccaaf50ecd9cfd9e99fc0de82d30ec9d21987c Mon Sep 17 00:00:00 2001 From: sj-williams Date: Mon, 29 Apr 2024 16:51:29 +0100 Subject: [PATCH 2/3] readme update --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ca48723..d01d841 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ This Terraform module will create an [Amazon Elastic Container Registry](https://aws.amazon.com/ecr/) private repository for use on the Cloud Platform. -If you're using GitHub as your OIDC provider, this module will automatically create the required variables for authentication in your GitHub repository. +If you're using GitHub as your OIDC provider, this module will automatically create the required variables for authentication in your GitHub repository. By default these will be created as [repository secrets and variables](https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-a-repository). Optionally, you can configure the module to create the ECR secrets +and variables in your own defined [GitHub Environments](https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-an-environment). This pattern is useful if you +wish to define separate ECR repositories for different Cloud Platform environments within the same GitHub repository. If you're using CircleCI as your OIDC provider, this module will create a Kubernetes ConfigMap in your namespace with your authentication variables to use as environment variables in CircleCI. From b09aa1ea0ba27837dc74d7e10cca7b090ea81803 Mon Sep 17 00:00:00 2001 From: sj-williams Date: Tue, 30 Apr 2024 08:52:59 +0100 Subject: [PATCH 3/3] readme update --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index d01d841..daf9906 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,7 @@ This Terraform module will create an [Amazon Elastic Container Registry](https://aws.amazon.com/ecr/) private repository for use on the Cloud Platform. -If you're using GitHub as your OIDC provider, this module will automatically create the required variables for authentication in your GitHub repository. By default these will be created as [repository secrets and variables](https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-a-repository). Optionally, you can configure the module to create the ECR secrets -and variables in your own defined [GitHub Environments](https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-an-environment). This pattern is useful if you -wish to define separate ECR repositories for different Cloud Platform environments within the same GitHub repository. +If you're using GitHub as your OIDC provider, this module will automatically create the required variables for authentication in your GitHub repository. By default these will be created as [repository secrets and variables](https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-a-repository). Alternatively, you can configure the module to instead create the ECR secrets and variables in your own defined [GitHub Environments](https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-an-environment) with the `github_environments` field. This pattern is useful if you wish to define separate ECR repositories for different Cloud Platform environments within the same GitHub repository. If you're using CircleCI as your OIDC provider, this module will create a Kubernetes ConfigMap in your namespace with your authentication variables to use as environment variables in CircleCI.