Skip to content

Commit 73aa2ff

Browse files
Adding a configuration for aws oidc github action variables and secrets (#50)
* adding a configuration to setup github variables and secrets for aws oidc * terraform-docs: automated action --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent b2ba054 commit 73aa2ff

3 files changed

Lines changed: 57 additions & 1 deletion

File tree

modules/github-foundations/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
| [github_actions_organization_variable.container_name](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_organization_variable) | resource |
3030
| [github_actions_organization_variable.custom_oidc_organization_variable](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_organization_variable) | resource |
3131
| [github_actions_organization_variable.key_vault_id](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_organization_variable) | resource |
32+
| [github_actions_organization_variable.region](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_organization_variable) | resource |
3233
| [github_actions_organization_variable.resource_group_name](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_organization_variable) | resource |
34+
| [github_actions_organization_variable.s3_bucket](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_organization_variable) | resource |
3335
| [github_actions_organization_variable.storage_account_name](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_organization_variable) | resource |
3436
| [github_actions_organization_variable.subscription_id](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_organization_variable) | resource |
3537
| [github_actions_organization_variable.tf_state_bucket_location](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_organization_variable) | resource |
@@ -38,7 +40,9 @@
3840
| [github_actions_secret.bootstrap_managed_identity_client_id](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_secret) | resource |
3941
| [github_actions_secret.organization_managed_identity_client_id](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_secret) | resource |
4042
| [github_actions_secret.organization_workload_identity_sa](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_secret) | resource |
43+
| [github_actions_secret.organizations_iam_role](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_secret) | resource |
4144
| [github_actions_secret.repository_secret](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_secret) | resource |
45+
| [github_actions_variable.dynamodb_table_name](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_variable) | resource |
4246
| [github_actions_variable.gcp_secret_manager_project_id](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_variable) | resource |
4347
| [github_actions_variable.repository_variable](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_variable) | resource |
4448
| [github_issue_labels.drift_labels](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/issue_labels) | resource |
@@ -57,7 +61,7 @@
5761
| <a name="input_account_type"></a> [account\_type](#input\_account\_type) | The type of GitHub account being used. Should be one of either `Personal`, `Organization`, or `Enterprise`. | `string` | n/a | yes |
5862
| <a name="input_bootstrap_repository_name"></a> [bootstrap\_repository\_name](#input\_bootstrap\_repository\_name) | The name of the bootstrap repository. | `string` | `"bootstrap"` | no |
5963
| <a name="input_foundation_devs_team_name"></a> [foundation\_devs\_team\_name](#input\_foundation\_devs\_team\_name) | The name of the foundation developers team. | `string` | `"foundation-devs"` | no |
60-
| <a name="input_oidc_configuration"></a> [oidc\_configuration](#input\_oidc\_configuration) | n/a | <pre>object({<br> gcp = optional(object({<br> workload_identity_provider_name_secret_name = optional(string)<br> workload_identity_provider_name = string<br><br> organization_workload_identity_sa_secret_name = optional(string)<br> organization_workload_identity_sa = string<br><br> gcp_secret_manager_project_id_variable_name = optional(string)<br> gcp_secret_manager_project_id = string<br><br> gcp_tf_state_bucket_project_id_variable_name = optional(string)<br> gcp_tf_state_bucket_project_id = string<br><br> bucket_name_variable_name = optional(string)<br> bucket_name = string<br><br> bucket_location_variable_name = optional(string)<br> bucket_location = string<br> }))<br> azure = optional(object({<br> bootstrap_client_id_variable_name = optional(string)<br> bootstrap_client_id = string<br><br> organization_client_id_variable_name = optional(string)<br> organization_client_id = string<br><br> tenant_id_variable_name = optional(string)<br> tenant_id = string<br><br> subscription_id_variable_name = optional(string)<br> subscription_id = string<br><br> resource_group_name_variable_name = optional(string)<br> resource_group_name = string<br><br> storage_account_name_variable_name = optional(string)<br> storage_account_name = string<br><br> container_name_variable_name = optional(string)<br> container_name = string<br><br> key_vault_id_variable_name = optional(string)<br> key_vault_id = string<br> }))<br> custom = optional(object({<br> organization_secrets = map(string)<br> organization_variables = map(string)<br> repository_secrets = map(map(string))<br> repository_variables = map(map(string))<br> }))<br> })</pre> | n/a | yes |
64+
| <a name="input_oidc_configuration"></a> [oidc\_configuration](#input\_oidc\_configuration) | n/a | <pre>object({<br> gcp = optional(object({<br> workload_identity_provider_name_secret_name = optional(string)<br> workload_identity_provider_name = string<br><br> organization_workload_identity_sa_secret_name = optional(string)<br> organization_workload_identity_sa = string<br><br> gcp_secret_manager_project_id_variable_name = optional(string)<br> gcp_secret_manager_project_id = string<br><br> gcp_tf_state_bucket_project_id_variable_name = optional(string)<br> gcp_tf_state_bucket_project_id = string<br><br> bucket_name_variable_name = optional(string)<br> bucket_name = string<br><br> bucket_location_variable_name = optional(string)<br> bucket_location = string<br> }))<br> azure = optional(object({<br> bootstrap_client_id_variable_name = optional(string)<br> bootstrap_client_id = string<br><br> organization_client_id_variable_name = optional(string)<br> organization_client_id = string<br><br> tenant_id_variable_name = optional(string)<br> tenant_id = string<br><br> subscription_id_variable_name = optional(string)<br> subscription_id = string<br><br> resource_group_name_variable_name = optional(string)<br> resource_group_name = string<br><br> storage_account_name_variable_name = optional(string)<br> storage_account_name = string<br><br> container_name_variable_name = optional(string)<br> container_name = string<br><br> key_vault_id_variable_name = optional(string)<br> key_vault_id = string<br> }))<br> aws = optional(object({<br> s3_bucket_variable_name = optional(string)<br> s3_bucket = string<br><br> region_variable_name = optional(string)<br> region = string<br><br> organizations_role_variable_name = optional(string)<br> organizations_role = string<br><br> dynamodb_table_variable_name = optional(string)<br> dynamodb_table = string<br> }))<br> custom = optional(object({<br> organization_secrets = map(string)<br> organization_variables = map(string)<br> repository_secrets = map(map(string))<br> repository_variables = map(map(string))<br> }))<br> })</pre> | n/a | yes |
6165
| <a name="input_organizations_repository_name"></a> [organizations\_repository\_name](#input\_organizations\_repository\_name) | The name of the organizations repository. | `string` | `"organizations"` | no |
6266
| <a name="input_readme_path"></a> [readme\_path](#input\_readme\_path) | Local Path to the README file in your current codebase. Pushed to the github foundation repository. | `string` | `""` | no |
6367

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
resource "github_actions_organization_variable" "s3_bucket" {
2+
count = var.oidc_configuration.aws != null ? 1 : 0
3+
4+
variable_name = coalesce(var.oidc_configuration.aws.s3_bucket_variable_name, "AWS_S3_BUCKET")
5+
value = var.oidc_configuration.aws.s3_bucket
6+
visibility = "selected"
7+
selected_repository_ids = [
8+
github_repository.bootstrap_repo.repo_id,
9+
github_repository.organizations_repo.repo_id
10+
]
11+
}
12+
13+
resource "github_actions_organization_variable" "region" {
14+
count = var.oidc_configuration.aws != null ? 1 : 0
15+
16+
variable_name = coalesce(var.oidc_configuration.aws.region_variable_name, "AWS_REGION")
17+
value = var.oidc_configuration.aws.region
18+
visibility = "selected"
19+
selected_repository_ids = [
20+
github_repository.bootstrap_repo.repo_id,
21+
github_repository.organizations_repo.repo_id
22+
]
23+
}
24+
25+
resource "github_actions_secret" "organizations_iam_role" {
26+
count = var.oidc_configuration.aws != null ? 1 : 0
27+
28+
repository = github_repository.organizations_repo.name
29+
secret_name = coalesce(var.oidc_configuration.aws.organizations_role_variable_name, "AWS_IAM_ROLE")
30+
plaintext_value = var.oidc_configuration.aws.organizations_role
31+
}
32+
33+
resource "github_actions_variable" "dynamodb_table_name" {
34+
count = var.oidc_configuration.aws != null ? 1 : 0
35+
36+
repository = github_repository.organizations_repo.name
37+
variable_name = coalesce(var.oidc_configuration.aws.dynamodb_table_variable_name, "AWS_DYNAMO_DB_TABLE")
38+
value = var.oidc_configuration.aws.dynamodb_table
39+
}

modules/github-foundations/variables.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,19 @@ variable "oidc_configuration" {
6868
key_vault_id_variable_name = optional(string)
6969
key_vault_id = string
7070
}))
71+
aws = optional(object({
72+
s3_bucket_variable_name = optional(string)
73+
s3_bucket = string
74+
75+
region_variable_name = optional(string)
76+
region = string
77+
78+
organizations_role_variable_name = optional(string)
79+
organizations_role = string
80+
81+
dynamodb_table_variable_name = optional(string)
82+
dynamodb_table = string
83+
}))
7184
custom = optional(object({
7285
organization_secrets = map(string)
7386
organization_variables = map(string)

0 commit comments

Comments
 (0)