-
-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: osamamagdy <[email protected]>
- Loading branch information
1 parent
d26fd0f
commit 4f13722
Showing
12 changed files
with
82 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
############################################################################################################################ | ||
## Here we need to create an Azure AD Application + a Service Principal and federate the application with the OIDC Issuer ## | ||
## so that Azure AD can exchange a token issued to the pod with a token that can be used to access other Azure resources. ## | ||
############################################################################################################################ | ||
|
||
|
||
locals { | ||
namespace_name = "default" | ||
## This should match the name of the service account created by helm chart | ||
service_account_name = "wrongsecrets-sa" | ||
} | ||
|
||
## Azure AD application that represents the app | ||
resource "azuread_application" "app" { | ||
display_name = "sp-wrongsecrets" | ||
} | ||
|
||
resource "azuread_service_principal" "app" { | ||
client_id = azuread_application.app.client_id | ||
app_role_assignment_required = false | ||
} | ||
|
||
resource "azuread_service_principal_password" "app" { | ||
service_principal_id = azuread_service_principal.app.id | ||
} | ||
|
||
## Azure AD federated identity used to federate kubernetes with Azure AD | ||
resource "azuread_application_federated_identity_credential" "app" { | ||
application_id = azuread_application.app.application_id | ||
display_name = "fed-identity-app-wrongsecrets" | ||
description = "The federated identity used to federate K8s with Azure AD with the app service running in k8s wrongsecrets" | ||
audiences = ["api://AzureADTokenExchange"] | ||
issuer = azurerm_kubernetes_cluster.cluster.oidc_issuer_url | ||
subject = "system:serviceaccount:${local.namespace_name}:${local.service_account_name}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: wrongsecrets-sa | ||
labels: | ||
azure.workload.identity/use: "true" # Represents the service account is to be used for workload identity, see https://azure.github.io/azure-workload-identity/docs/topics/service-account-labels-and-annotations.html | ||
annotations: | ||
azure.workload.identity/client-id: ${AZ_AD_APP_CLIENT_ID} | ||
azure.workload.identity/tenant-id: ${AZURE_TENANT_ID} | ||
azure.workload.identity/service-account-token-expiration: "86400" # Token is valid for 1 day |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters