Skip to content

Commit 0345b95

Browse files
Fix(): Set tflock db write capacity default (#51)
* fix(): tflock db write capacity default * chore(): variable name update * chore(): added variables to customize org and bootstrap repo name for az and gcp oidc setup * terraform-docs: automated action --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 73aa2ff commit 0345b95

File tree

9 files changed

+47
-24
lines changed

9 files changed

+47
-24
lines changed

modules/github-aws-oidc/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ No modules.
3535
| Name | Description | Type | Default | Required |
3636
|------|-------------|------|---------|:--------:|
3737
| <a name="input_bucket_name"></a> [bucket\_name](#input\_bucket\_name) | The name of the s3 bucket that will store terraform state. | `string` | `"GithubFoundationState"` | no |
38-
| <a name="input_github_repo_owner"></a> [github\_repo\_owner](#input\_github\_repo\_owner) | The owner of the github foundations organizations repository. This value should be whatever github account you plan to make the repository under. | `string` | n/a | yes |
38+
| <a name="input_github_foundations_organization_name"></a> [github\_foundations\_organization\_name](#input\_github\_foundations\_organization\_name) | The owner of the github foundations organizations repository. This value should be whatever github account you plan to make the repository under. | `string` | n/a | yes |
3939
| <a name="input_github_thumbprints"></a> [github\_thumbprints](#input\_github\_thumbprints) | A list of top intermediate certifact authority thumbprints to use for setting up an openid connect provider with github. Info on how to obtain thumbprints here: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_oidc_verify-thumbprint.html | `list(string)` | n/a | yes |
4040
| <a name="input_organizations_repo_name"></a> [organizations\_repo\_name](#input\_organizations\_repo\_name) | The name of the github foundations organizations repository. Defaults to `organizations` | `string` | `"organizations"` | no |
4141
| <a name="input_organizations_role_name"></a> [organizations\_role\_name](#input\_organizations\_role\_name) | The name of the role that will be assummed by the github runner for the organizations repository. | `string` | `"GhFoundationsOrganizationsAction"` | no |
4242
| <a name="input_rg_name"></a> [rg\_name](#input\_rg\_name) | The name of the AWS resource group to create for github foundation resources. | `string` | `"GithubFoundationResources"` | no |
4343
| <a name="input_tflock_db_billing_mode"></a> [tflock\_db\_billing\_mode](#input\_tflock\_db\_billing\_mode) | The billing mode to use for the dynamodb table storing lock file ids. Defaults to `PROVISIONED`. | `string` | `"PROVISIONED"` | no |
4444
| <a name="input_tflock_db_name"></a> [tflock\_db\_name](#input\_tflock\_db\_name) | The name of the dynamodb table that will store lock file ids. | `string` | `"TFLockIds"` | no |
4545
| <a name="input_tflock_db_read_capacity"></a> [tflock\_db\_read\_capacity](#input\_tflock\_db\_read\_capacity) | The read capacity to set for the dynamodb table storing lock file ids. Only required if billing mode is `PROVISIONED`. Defaults to 20. | `number` | `20` | no |
46-
| <a name="input_tflock_db_write_capacity"></a> [tflock\_db\_write\_capacity](#input\_tflock\_db\_write\_capacity) | The write capacity to set for the dynamodb table storing lock file ids. Only required if billing mode is `PROVISIONED`. Defaults to 20. | `number` | n/a | yes |
46+
| <a name="input_tflock_db_write_capacity"></a> [tflock\_db\_write\_capacity](#input\_tflock\_db\_write\_capacity) | The write capacity to set for the dynamodb table storing lock file ids. Only required if billing mode is `PROVISIONED`. Defaults to 20. | `number` | `20` | no |
4747

4848
## Outputs
4949

modules/github-aws-oidc/oidc.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ resource "aws_iam_role" "organizations_role" {
2828
},
2929
"StringLike" = {
3030
"token.actions.githubusercontent.com:sub": [
31-
"repo:${var.github_repo_owner}/${var.organizations_repo_name}:*"
31+
"repo:${var.github_foundations_organization_name}/${var.organizations_repo_name}:*"
3232
]
3333
}
3434
}

modules/github-aws-oidc/variables.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ variable "tflock_db_read_capacity" {
2828
variable "tflock_db_write_capacity" {
2929
type = number
3030
description = "The write capacity to set for the dynamodb table storing lock file ids. Only required if billing mode is `PROVISIONED`. Defaults to 20."
31+
default = 20
3132
}
3233

3334
variable "tflock_db_billing_mode" {
@@ -53,7 +54,7 @@ variable "organizations_role_name" {
5354
default = "GhFoundationsOrganizationsAction"
5455
}
5556

56-
variable "github_repo_owner" {
57+
variable "github_foundations_organization_name" {
5758
type = string
5859
description = "The owner of the github foundations organizations repository. This value should be whatever github account you plan to make the repository under."
5960
}

modules/github-azure-oidc/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ No modules.
4141

4242
| Name | Description | Type | Default | Required |
4343
|------|-------------|------|---------|:--------:|
44+
| <a name="input_bootstrap_repo_name"></a> [bootstrap\_repo\_name](#input\_bootstrap\_repo\_name) | The name of the github foundations bootstrap repository. Defaults to `bootstrap` | `string` | `"bootstrap"` | no |
4445
| <a name="input_drift_detection_branch_name"></a> [drift\_detection\_branch\_name](#input\_drift\_detection\_branch\_name) | The name of the branch to use for drift detection. | `string` | n/a | yes |
4546
| <a name="input_github_foundations_organization_name"></a> [github\_foundations\_organization\_name](#input\_github\_foundations\_organization\_name) | The name of the organization that the github foundation repos will be under. | `string` | n/a | yes |
4647
| <a name="input_kv_name"></a> [kv\_name](#input\_kv\_name) | The name of the key vault to use for github foundation secrets. If storing secrets to authenticate against github in a different way then this does not need to be set. (Optional) | `string` | `""` | no |
4748
| <a name="input_kv_resource_group"></a> [kv\_resource\_group](#input\_kv\_resource\_group) | The name of the resource group that the key vault is in. If empty it will default to the github foundations resource group. | `string` | n/a | yes |
49+
| <a name="input_organizations_repo_name"></a> [organizations\_repo\_name](#input\_organizations\_repo\_name) | The name of the github foundations organizations repository. Defaults to `organizations` | `string` | `"organizations"` | no |
4850
| <a name="input_rg_create"></a> [rg\_create](#input\_rg\_create) | Create the resource group. When set to false it uses the `rg_name` input to reference an existing resource group. Defaults to true. | `bool` | `true` | no |
4951
| <a name="input_rg_location"></a> [rg\_location](#input\_rg\_location) | The location of the resource group to create the github foundation azure resources in. | `string` | n/a | yes |
5052
| <a name="input_rg_name"></a> [rg\_name](#input\_rg\_name) | The name of the resource group to create the github foundation azure resources in. | `string` | n/a | yes |

modules/github-azure-oidc/oidc.tf

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ locals {
22
default_audience_name = "api://AzureADTokenExchange"
33
github_issuer_url = "https://token.actions.githubusercontent.com"
44

5-
bootstrap_repo_name = "bootstrap"
6-
organizations_repo_name = "organizations"
7-
85
state_file_access_roles = {
96
"container-${local.tf_state_container.name}-write" = {
107
scope = "${local.tf_state_container.resource_manager_id}"
@@ -49,7 +46,7 @@ data "azurerm_key_vault" "key_vault" {
4946
resource "azurerm_user_assigned_identity" "bootstrap_identity" {
5047
location = local.github_foundations_rg.location
5148
resource_group_name = local.github_foundations_rg.name
52-
name = "${local.bootstrap_repo_name}-identity"
49+
name = "${var.bootstrap_repo_name}-identity"
5350
}
5451

5552
resource "azurerm_role_assignment" "bootstrap_role_assignment" {
@@ -62,7 +59,7 @@ resource "azurerm_role_assignment" "bootstrap_role_assignment" {
6259
resource "azurerm_user_assigned_identity" "organization_identity" {
6360
location = local.github_foundations_rg.location
6461
resource_group_name = local.github_foundations_rg.name
65-
name = "${local.organizations_repo_name}-identity"
62+
name = "${var.organizations_repo_name}-identity"
6663
}
6764

6865
resource "azurerm_role_assignment" "organization_role_assignment" {
@@ -73,37 +70,37 @@ resource "azurerm_role_assignment" "organization_role_assignment" {
7370
}
7471

7572
resource "azurerm_federated_identity_credential" "bootstrap_pull_request_credentials" {
76-
name = "${var.github_foundations_organization_name}-${local.bootstrap_repo_name}-pr-credentials"
73+
name = "${var.github_foundations_organization_name}-${var.bootstrap_repo_name}-pr-credentials"
7774
resource_group_name = local.github_foundations_rg.name
7875
audience = [local.default_audience_name]
7976
issuer = local.github_issuer_url
8077
parent_id = azurerm_user_assigned_identity.bootstrap_identity.id
81-
subject = "repo:${var.github_foundations_organization_name}/${local.bootstrap_repo_name}:pull_request"
78+
subject = "repo:${var.github_foundations_organization_name}/${var.bootstrap_repo_name}:pull_request"
8279
}
8380

8481
resource "azurerm_federated_identity_credential" "bootstrap_drift_credentials" {
85-
name = "${var.github_foundations_organization_name}-${local.bootstrap_repo_name}-drift-credentials"
82+
name = "${var.github_foundations_organization_name}-${var.bootstrap_repo_name}-drift-credentials"
8683
resource_group_name = local.github_foundations_rg.name
8784
audience = [local.default_audience_name]
8885
issuer = local.github_issuer_url
8986
parent_id = azurerm_user_assigned_identity.bootstrap_identity.id
90-
subject = "repo:${var.github_foundations_organization_name}/${local.bootstrap_repo_name}:ref:refs/heads/${var.drift_detection_branch_name}"
87+
subject = "repo:${var.github_foundations_organization_name}/${var.bootstrap_repo_name}:ref:refs/heads/${var.drift_detection_branch_name}"
9188
}
9289

9390
resource "azurerm_federated_identity_credential" "organization_pull_request_credentials" {
94-
name = "${var.github_foundations_organization_name}-${local.organizations_repo_name}-pr-credentials"
91+
name = "${var.github_foundations_organization_name}-${var.organizations_repo_name}-pr-credentials"
9592
resource_group_name = local.github_foundations_rg.name
9693
audience = [local.default_audience_name]
9794
issuer = local.github_issuer_url
9895
parent_id = azurerm_user_assigned_identity.organization_identity.id
99-
subject = "repo:${var.github_foundations_organization_name}/${local.organizations_repo_name}:pull_request"
96+
subject = "repo:${var.github_foundations_organization_name}/${var.organizations_repo_name}:pull_request"
10097
}
10198

10299
resource "azurerm_federated_identity_credential" "organization_drift_credentials" {
103-
name = "${var.github_foundations_organization_name}-${local.organizations_repo_name}-drift-credentials"
100+
name = "${var.github_foundations_organization_name}-${var.organizations_repo_name}-drift-credentials"
104101
resource_group_name = local.github_foundations_rg.name
105102
audience = [local.default_audience_name]
106103
issuer = local.github_issuer_url
107104
parent_id = azurerm_user_assigned_identity.organization_identity.id
108-
subject = "repo:${var.github_foundations_organization_name}/${local.organizations_repo_name}:ref:refs/heads/${var.drift_detection_branch_name}"
105+
subject = "repo:${var.github_foundations_organization_name}/${var.organizations_repo_name}:ref:refs/heads/${var.drift_detection_branch_name}"
109106
}

modules/github-azure-oidc/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,15 @@ variable "drift_detection_branch_name" {
9292
type = string
9393
description = "The name of the branch to use for drift detection."
9494
}
95+
96+
variable "organizations_repo_name" {
97+
type = string
98+
description = "The name of the github foundations organizations repository. Defaults to `organizations`"
99+
default = "organizations"
100+
}
101+
102+
variable "bootstrap_repo_name" {
103+
type = string
104+
description = "The name of the github foundations bootstrap repository. Defaults to `bootstrap`"
105+
default = "bootstrap"
106+
}

modules/github-gcloud-oidc/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
| <a name="input_auto_create_network"></a> [auto\_create\_network](#input\_auto\_create\_network) | Whether to create the default network for the project. | `bool` | `false` | no |
4444
| <a name="input_autoclass"></a> [autoclass](#input\_autoclass) | Enable autoclass to automatically transition objects to appropriate storage classes based on their access pattern. If set to true, storage\_class must be set to STANDARD. Defaults to false. | `bool` | `false` | no |
4545
| <a name="input_billing_account"></a> [billing\_account](#input\_billing\_account) | Billing account id. | `string` | `null` | no |
46+
| <a name="input_bootstrap_repo_name"></a> [bootstrap\_repo\_name](#input\_bootstrap\_repo\_name) | The name of the github foundations bootstrap repository. Defaults to `bootstrap` | `string` | `"bootstrap"` | no |
4647
| <a name="input_bucket_name"></a> [bucket\_name](#input\_bucket\_name) | Bucket name | `string` | n/a | yes |
4748
| <a name="input_cors"></a> [cors](#input\_cors) | CORS configuration for the bucket. Defaults to null. | <pre>object({<br> origin = optional(list(string))<br> method = optional(list(string))<br> response_header = optional(list(string))<br> max_age_seconds = optional(number)<br> })</pre> | `null` | no |
4849
| <a name="input_custom_placement_config"></a> [custom\_placement\_config](#input\_custom\_placement\_config) | The bucket's custom location configuration, which specifies the individual regions that comprise a dual-region bucket. If the bucket is designated as REGIONAL or MULTI\_REGIONAL, the parameters are empty. | `list(string)` | `null` | no |
@@ -58,6 +59,7 @@
5859
| <a name="input_lifecycle_rules"></a> [lifecycle\_rules](#input\_lifecycle\_rules) | Bucket lifecycle rule. | <pre>map(object({<br> action = object({<br> type = string<br> storage_class = optional(string)<br> })<br> condition = object({<br> age = optional(number)<br> created_before = optional(string)<br> custom_time_before = optional(string)<br> days_since_custom_time = optional(number)<br> days_since_noncurrent_time = optional(number)<br> matches_prefix = optional(list(string))<br> matches_storage_class = optional(list(string)) # STANDARD, MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, ARCHIVE, DURABLE_REDUCED_AVAILABILITY<br> matches_suffix = optional(list(string))<br> noncurrent_time_before = optional(string)<br> num_newer_versions = optional(number)<br> with_state = optional(string) # "LIVE", "ARCHIVED", "ANY"<br> })<br> }))</pre> | `{}` | no |
5960
| <a name="input_location"></a> [location](#input\_location) | Bucket location. | `string` | n/a | yes |
6061
| <a name="input_logging_config"></a> [logging\_config](#input\_logging\_config) | Bucket logging configuration. | <pre>object({<br> log_bucket = string<br> log_object_prefix = optional(string)<br> })</pre> | `null` | no |
62+
| <a name="input_organizations_repo_name"></a> [organizations\_repo\_name](#input\_organizations\_repo\_name) | The name of the github foundations organizations repository. Defaults to `organizations` | `string` | `"organizations"` | no |
6163
| <a name="input_parent"></a> [parent](#input\_parent) | Parent in folders/folder\_id or organizations/org\_id format. | `string` | `null` | no |
6264
| <a name="input_prefix"></a> [prefix](#input\_prefix) | Optional prefix used to generate project id and name. | `string` | `null` | no |
6365
| <a name="input_project_create"></a> [project\_create](#input\_project\_create) | Create project. When set to false, uses a data source to reference existing project. | `bool` | `true` | no |

modules/github-gcloud-oidc/oidc.tf

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ locals {
22
pool_id = "pool-oidc-github-foundation"
33
provider_id = "provider-oidc-github-foundation"
44

5-
bootstrap_repo_name = "bootstrap"
6-
organizations_repo_name = "organizations"
7-
85
state_file_access_roles = tolist(["roles/storage.objectAdmin", "roles/storage.admin"])
96

107
bootstrap_project_roles = local.state_file_access_roles
@@ -25,7 +22,7 @@ locals {
2522

2623
resource "google_service_account" "bootstrap_sa" {
2724
project = google_project.project[0].project_id
28-
account_id = "${local.bootstrap_repo_name}-sa"
25+
account_id = "${var.bootstrap_repo_name}-sa"
2926
}
3027

3128
resource "google_project_iam_member" "bootstrap_project_member" {
@@ -37,7 +34,7 @@ resource "google_project_iam_member" "bootstrap_project_member" {
3734

3835
resource "google_service_account" "organizations_sa" {
3936
project = google_project.project[0].project_id
40-
account_id = "${local.organizations_repo_name}-sa"
37+
account_id = "${var.organizations_repo_name}-sa"
4138
}
4239

4340
resource "google_project_iam_member" "organizations_member" {
@@ -60,11 +57,11 @@ module "oidc" {
6057
sa_mapping = {
6158
(google_service_account.bootstrap_sa.account_id) = {
6259
sa_name = google_service_account.bootstrap_sa.name
63-
attribute = "attribute.repository/${var.github_foundations_organization_name}/${local.bootstrap_repo_name}"
60+
attribute = "attribute.repository/${var.github_foundations_organization_name}/${var.bootstrap_repo_name}"
6461
},
6562
(google_service_account.organizations_sa.account_id) = {
6663
sa_name = google_service_account.organizations_sa.name
67-
attribute = "attribute.repository/${var.github_foundations_organization_name}/${local.organizations_repo_name}"
64+
attribute = "attribute.repository/${var.github_foundations_organization_name}/${var.organizations_repo_name}"
6865
}
6966
}
7067
}

modules/github-gcloud-oidc/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,15 @@ variable "github_foundations_organization_name" {
272272
type = string
273273
description = "The name of the organization that the github foundation repos will be under."
274274
}
275+
276+
variable "organizations_repo_name" {
277+
type = string
278+
description = "The name of the github foundations organizations repository. Defaults to `organizations`"
279+
default = "organizations"
280+
}
281+
282+
variable "bootstrap_repo_name" {
283+
type = string
284+
description = "The name of the github foundations bootstrap repository. Defaults to `bootstrap`"
285+
default = "bootstrap"
286+
}

0 commit comments

Comments
 (0)