Skip to content

Instantly share code, notes, and snippets.

View rollendxavier's full-sized avatar

Rollend Xavier rollendxavier

View GitHub Profile
@rollendxavier
rollendxavier / azure_scope_resource_access.tsv
Created August 3, 2022 01:26
Below are the scope details of Microsoft Graph permissions including IDs which are required when using Terraform, PowerShell or Azure CLI.
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 6 columns, instead of 4 in line 3.
Scope Name ID Admin Display Name Admin Description User Display Name User Description
APIConnectors.Read.All 1b6ff35f-31df-4332-8571-d31ea5a4893f Read API connectors for authentication flows Allows the app to read the API connectors used in user authentication flows, on behalf of the signed-in user. Read API connectors for authentication flows Allows the app to read the API connectors used in user authentication flows, on your behalf.
APIConnectors.ReadWrite.All c67b52c5-7c69-48b6-9d48-7b3af3ded914 Read and write API connectors for authentication flows Allows the app to read, create and manage the API connectors used in user authentication flows, on behalf of the signed-in user. Read and write API connectors for authentication flows Allows the app to read, create and manage the API connectors used in user authentication flows, on your behalf.
AccessReview.Read.All ebfcd32b-babb-40f4-a14b-42706e83bd28 Read all access reviews that user can access Allows the app to read access reviews, reviewers, decisions and s
@rollendxavier
rollendxavier / create_spa_app.tf
Last active August 3, 2022 05:39
Azure App registration for web portal using terraform
resource "random_uuid" "spa_admin_roled_id" {}
resource "random_uuid" "spa_user_roled_id" {}
resource "azuread_application" "spa_application" {
display_name = "${var.environment}-spa-app"
single_page_application {
redirect_uris = [
"https://yourdomain.com/"
]
}
@rollendxavier
rollendxavier / sales_data.csv
Last active August 18, 2022 08:27
Pyhton datasets
age gender product
21 male game
23 male game
24 male game
25 male mobile
27 male mobile
29 male tv
30 male tv
22 female mobile
23 female mobile
@rollendxavier
rollendxavier / key_vault.tf
Last active September 30, 2022 07:23
Example terraform code to create a key vault which the login service principal & your DevOps will have access to it.
data "azurerm_client_config" "current" {}
resource "azurerm_key_vault" "example" {
name = "example-keyvault"
location = var.location
resource_group_name = var.rg_name
tenant_id = data.azurerm_client_config.current.tenant_id
sku_name = "standard"
@rollendxavier
rollendxavier / cert.tf
Last active September 30, 2022 06:56
Generating a auto-renewing self signed certificate using terraform
# Generating a auto-renewing self signed certificate
resource "azurerm_key_vault_certificate" "self_signed_certificate" {
name = "self-signed-certificate"
key_vault_id = azurerm_key_vault.key_vault.id
certificate_policy {
issuer_parameters {
name = "Self"
}
@rollendxavier
rollendxavier / kv_policy.tf
Last active October 3, 2022 02:23
Key Vault access policy to read secrets from Key-Vault
data "azurerm_client_config" "current" {
}
resource "azurerm_key_vault_access_policy" "kv_read_access_policy" {
key_vault_id = var.keyvault_id
tenant_id = data.azurerm_client_config.current.tenant_id
object_id = data.azuread_service_principal.app_sp.id
secret_permissions = [
resource "azurerm_app_service" "app" {
name = "myhealth-apiapp"
location = "Australia East"
resource_group_name = "myhealth-rg"
app_service_plan_id = var.asp_id
app_settings = {
"APPINSIGHTS_INSTRUMENTATIONKEY" = var.ai_ins_key
"APPLICATIONINSIGHTS_CONNECTION_STRING" = var.ai_con_string
}
# SQL Database
resource "azurerm_mssql_server" "db" {
name = "tf-dbsrv"
resource_group_name = var.resource_group_name
location = var.resource_location
version = "12.0"
administrator_login = "missadministrator"
administrator_login_password = "Sq123@p-p455w0rd-enV1r0nm3nT"
public_network_access_enabled = true
# Resource Group
resource "azurerm_resource_group" "rg" {
name = var.resource_group_name
location = var.resource_location
}
#Virtual Network
resource "azurerm_virtual_network" "demo_vnet" {
name = "${var.vnet_name}-vnet"
location = var.resource_location
# App Service Plan + Slots
resource "azurerm_service_plan" "asp" {
name = "tf-asp-demo"
location = var.resource_location
resource_group_name = var.resource_group_name
os_type = "Windows"
sku_name = "P1v2"
tags = {
environment = var.environment_tag