-
Notifications
You must be signed in to change notification settings - Fork 0
Dev to qa #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev to qa #97
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,12 @@ resource "azurerm_resource_group" "rg" { | |
| } | ||
|
|
||
| #### Create the Azure Key Vault ##### | ||
|
|
||
| # Retrieve the runner's public IP | ||
| data "http" "ip" { | ||
| url = "https://api.ipify.org" | ||
| } | ||
|
|
||
| module "key_vault" { | ||
| source = "../modules/key_vault" | ||
|
|
||
|
|
@@ -28,6 +34,15 @@ module "key_vault" { | |
| depends_on = [azurerm_resource_group.rg] | ||
|
|
||
| tags = local.environment_vars.tags | ||
|
|
||
| key_vault_ip_rules = [data.http.ip.response_body] | ||
| } | ||
|
|
||
| # Wait for firewall rule propagation | ||
| resource "time_sleep" "wait_for_firewall" { | ||
| create_duration = "60s" | ||
|
|
||
| depends_on = [module.key_vault] | ||
| } | ||
|
Comment on lines
+42
to
46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using |
||
|
|
||
| # Get the current service principal/client object ID | ||
|
|
@@ -42,6 +57,20 @@ resource "azurerm_role_assignment" "key_vault_secrets_officer" { | |
| depends_on = [module.key_vault] | ||
| } | ||
|
|
||
| # Look up the user to grant access to | ||
| data "azuread_user" "admin_user" { | ||
| user_principal_name = "frederic.pitteloud@fpittelo.ch" | ||
| } | ||
|
Comment on lines
+61
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The user principal name (UPN) is hardcoded. This is not a good practice as it makes the code less reusable and harder to maintain. If another user needs access, or if you deploy this to another environment, you'll need to change the code. This should be a variable. You should add a new variable in variable "admin_user_principal_name" {
description = "The User Principal Name of the admin user to grant Key Vault access."
type = string
}Then, use that variable here. |
||
|
|
||
| # Assign Key Vault Administrator role to the user | ||
| resource "azurerm_role_assignment" "key_vault_admin_user" { | ||
| scope = module.key_vault.key_vault_id | ||
| role_definition_name = "Key Vault Administrator" | ||
| principal_id = data.azuread_user.admin_user.object_id | ||
|
|
||
| depends_on = [module.key_vault] | ||
| } | ||
|
|
||
| resource "azurerm_key_vault_secret" "openai_key" { | ||
| name = "openai-api-key" | ||
| value = module.cognitive_account.openai_key | ||
|
|
@@ -50,7 +79,8 @@ resource "azurerm_key_vault_secret" "openai_key" { | |
| depends_on = [ | ||
| module.key_vault, | ||
| module.cognitive_account, | ||
| azurerm_role_assignment.key_vault_secrets_officer | ||
| azurerm_role_assignment.key_vault_secrets_officer, | ||
| time_sleep.wait_for_firewall | ||
| ] | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -186,3 +186,5 @@ variable "google_client_secret" { | |
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relying on a single external service like
api.ipify.orgto fetch the runner's IP address introduces a single point of failure. If this service is unavailable, your deployment pipeline will fail. Consider using a more robust solution, such as querying multiple services and using the first successful response, or using a service with higher availability guarantees if possible.