This file contains hidden or 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
terraform { | |
required_providers { | |
azuread = { | |
version = "=1.6.0" | |
} | |
} | |
backend "azurerm" { | |
key = "msgraphapp.tfstate" | |
resource_group_name = "terraform-state-demo" | |
storage_account_name = "update-with-storage-account-name" |
This file contains hidden or 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
application_name="MS Graph Directory Role Application" | |
homepage_url = "https://localhost" | |
logout_url = "https://localhost/logout" | |
identifier_uris = ["https://msgdra"] | |
redirect_uris = ["https://msgdra/"] |
This file contains hidden or 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
terraform { | |
required_providers { | |
azuread = { | |
version = "=1.6.0" | |
} | |
} | |
} | |
variable "application_name" { | |
type = string |
This file contains hidden or 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
# Script to get all User Principal Names of users in the Global Administrators role in Azure Active Directory. | |
# Uses the MSGraph beta endpoint and requires the correct permissions to access the data. See: https://docs.microsoft.com/en-us/graph/api/rbacapplication-list-roledefinitions?view=graph-rest-beta&tabs=http#permissions. | |
Select-MgProfile -Name "beta" | |
Connect-MgGraph -Scopes 'RoleManagement.Read.Directory' | |
$memberList = [System.Collections.Generic.List[string]]::new() | |
$roleId = (Get-MgDirectoryRole -Filter "DisplayName eq 'Global Administrator'").Id | |
$userList = Get-MgDirectoryRoleMember -DirectoryRoleId $roleId |
This file contains hidden or 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
# Don't use MS Account, use account in AzureAD | |
Install-Module microsoft.graph | |
Select-MgProfile -Name "beta" | |
Connect-MgGraph -Scopes "User.Read.All" | |
# View auth commands | |
Get-Command -Module Microsoft.Graph.Authentication | |
# Check scopes | |
# Permission: https://docs.microsoft.com/en-us/graph/permissions-reference |
This file contains hidden or 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
# Returns the login names of all the user in a specified Okta group. | |
# Requires an API token to be generated: https://developer.okta.com/docs/guides/create-an-api-token/overview/ | |
$apiToken = Get-Secret -Name 'okta-api-token' | |
$oktaUri = 'example-admin.okta.com' | |
$groupId = '' | |
$uri = "https://$oktaUri/api/v1/groups/$groupId/users" | |
$headers = @{ | |
'Authorization' = "SSWS $apiToken" |
This file contains hidden or 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
# Extract just the email address of user from string. | |
$regex = "[a-z0-9!#\$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#\$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?" | |
$userList = 'Mick Jagger <[email protected]>', 'Keith Richards [email protected]', 'Ronnie W [[email protected]]' | |
$emailList = [System.Collections.Generic.List[string]]::new() | |
foreach ($user in $userList) { | |
$user -match $regex | Out-Null | |
$emailList.Add($Matches.values) | |
} |
This file contains hidden or 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
# To use the terraform import aws_cloudwatch_event_target provider, we need the rule name and target ID. To find the target ID, | |
# run the following with the AWS cli. | |
aws events list-targets-by-rule --rule "ruleName" | |
# This will return the following and the ID can be used to import the resource. | |
#{ | |
# "Targets": [ | |
# { |
This file contains hidden or 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
terraform { | |
required_providers { | |
okta = { | |
source = "oktadeveloper/okta" | |
version = "~> 3.6" | |
} | |
} | |
} | |
# Configure the Okta Provider - API token set in env var. |
This file contains hidden or 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
variable "org_name" { | |
default = "dev-12345" | |
} | |
variable "base_url" { | |
default = "okta.com" | |
} |