Skip to content

Commit 22508ee

Browse files
Feature/modify workflow description (#8)
* DEVOPS-257 updated app.tf t have time based expiry for secret * updated outut file to ahve woners and expiry date DEVOPS-257 * added variable to have expiry date as input DEVOPS-257 * Added `app_registation_expiry` input to GitHub workflow with default value and options, and updated `Terraform Plan` step to include this new input. DEVOPS-257 * "Updated Terraform Plan step in Azure create app registrations workflow to use a multi-line command" * "Update workflow YAML: modify descriptions for app_registration_description and app_registration_owners inputs" DEVOPS-257 * "Added 'sensitive = false' to 'azure_app_registration_secret' output in output.tf"
1 parent 9d39467 commit 22508ee

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

.github/workflows/azure-create-app-registrations-using-terraform.yaml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,23 @@ on:
99
app_registration_description:
1010
type: string
1111
required: false
12-
description: 'Provide description for your application if any'
12+
description: 'Provide description for your application if any. Donot enclose in quotes'
1313
app_registration_owners:
1414
type: string
1515
required: true
16-
description: 'Owners of Application registration. Seperate by comma if more than one owner. Donot enclose in quotes'
16+
description: 'Owners of Application registration. Seperate by comma if more than one owner.'
17+
app_registation_expiry:
18+
default : "60"
19+
type: choice
20+
options:
21+
- 30
22+
- 60
23+
- 90
24+
- 120
25+
- 150
26+
- 180
27+
- 270
28+
- 360
1729

1830
run-name: Creating app registration ${{ inputs.app_registration_name }} in azure
1931
jobs:
@@ -39,7 +51,13 @@ jobs:
3951
run: terraform init
4052

4153
- name: Terraform Plan
42-
run: terraform plan -var="app_registration_name=${{ inputs.app_registration_name }}" -var="app_registration_owners=${{ inputs.app_registration_owners }}" -var="app_registration_description=${{ inputs.app_registration_description }}" -out "plan.out"
54+
run: |
55+
terraform plan \
56+
-var="app_registration_name=${{ inputs.app_registration_name }}" \
57+
-var="app_registration_owners=${{ inputs.app_registration_owners }}" \
58+
-var="app_registration_description=${{ inputs.app_registration_description }}" \
59+
-var="app_registation_expiry=${{ inputs.app_registation_expiry }}" \
60+
-out "plan.out"
4361
4462
- name: Terraform show
4563
run: terraform show "plan.out"

app.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,15 @@ resource "azuread_application" "app" {
1717
description = var.app_registration_description
1818
}
1919

20+
# Time based expiry
21+
resource "time_rotating" "time" {
22+
rotation_days = var.app_registation_expiry
23+
}
24+
2025
# Azure app registration secret
2126
resource "azuread_application_password" "app" {
2227
application_id = azuread_application.app.id
23-
end_date_relative = "720h" # a month
28+
end_date = time_rotating.time.rotation_rfc3339
2429
display_name = "Secret Created Using Terraform"
2530
}
2631

output.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@ output "azure_app_registration_id" {
44

55
output "azure_app_registration_secret" {
66
value = nonsensitive(azuread_application_password.app.value)
7+
sensitive = false
78
}
89

910
output "azure_app_registation_tenant" {
1011
value = azuread_service_principal.sp.application_tenant_id
12+
}
13+
14+
output "azure_app_registation_owners" {
15+
value = var.app_registration_owners
16+
}
17+
18+
output "azure_app_registation_expiry_date" {
19+
value = azuread_application_password.app.end_date
1120
}

variable.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
variable "app_registration_name" {
2-
default = "test-app"
2+
default = "ewtest-app"
33
type = string
44
description = "New azure App registration name"
55
}
@@ -13,4 +13,9 @@ variable "app_registration_description" {
1313
type = string
1414
description = "Description for you app"
1515
default = "Azure App registration created using terraform"
16+
}
17+
18+
variable "app_registation_expiry" {
19+
type = string
20+
description = "App registration secret expiration period"
1621
}

0 commit comments

Comments
 (0)