Skip to content

Commit 40cfa12

Browse files
authored
Allow zero days secret expiration (#47)
* Update providers * Allow secret_expiration_days = 0 * Ignore backend.tf * Set TF_VAR_resource_suffix
1 parent e392379 commit 40cfa12

File tree

4 files changed

+56
-54
lines changed

4 files changed

+56
-54
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# .tfstate files
55
*.tfstate
66
*.tfstate.*
7+
backend.tf
78

89
# Crash log files
910
crash.log

terraform/azure-devops/create-service-connection/.terraform.lock.hcl

Lines changed: 52 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

terraform/azure-devops/create-service-connection/azure-pipelines.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ jobs:
132132
TF_VAR_azdo_creates_identity: ${{ lower(eq(parameters.serviceConnectionCreationMode, 'Automatic')) }}
133133
TF_VAR_create_federation: ${{ lower(contains(parameters.identityType, 'federation')) }}
134134
TF_VAR_create_managed_identity: ${{ lower(contains(parameters.identityType, 'Managed Identity')) }}
135+
TF_VAR_resource_suffix: $(Build.BuildId)
135136
managedIdentityResourceGroupLocation: centralus
136137
managedIdentityResourceGroupName: ${{ split(variables['System.CollectionUri'], '/')[3] }}-service-connections
137138

terraform/azure-devops/create-service-connection/modules/service-principal/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ data azuread_client_config current {}
22

33
locals {
44
owner_object_id = var.owner_object_id != null && var.owner_object_id != "" ? lower(var.owner_object_id) : data.azuread_client_config.current.object_id
5-
expiration_expression = "${var.secret_expiration_days * 24}h"
5+
expiration_expression = "${var.secret_expiration_days * 24}h01m"
66
}
77

88
resource azuread_application app_registration {
@@ -28,7 +28,7 @@ resource azuread_application_federated_identity_credential fic {
2828
}
2929

3030
resource time_rotating secret_expiration {
31-
rotation_days = var.secret_expiration_days
31+
rotation_days = max(var.secret_expiration_days,1)
3232

3333
count = var.create_federation ? 0 : 1
3434
}

0 commit comments

Comments
 (0)