Skip to content
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

Mtms #202

Merged
merged 81 commits into from
Jun 23, 2021
Merged

Mtms #202

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
2d06e40
Initial commit
LaurentLesle Apr 27, 2021
2336f34
update devops config based on devops v1 LZ
May 3, 2021
4fcd7a7
update pipeline to fix repo issue
May 3, 2021
59d6f5a
Add output agent_pools
jorseng May 5, 2021
6b7931f
Update azuread_applications output attribute
jorseng May 5, 2021
82095df
added support for remote repo for pipeline
May 6, 2021
157a496
Merge branch 'master' of https://github.com/Azure/caf-terraform-landi…
hieumoscow May 6, 2021
44b747f
default to project key for repo in same poject
May 7, 2021
ea3ddb4
use integration branch
LaurentLesle May 19, 2021
cb2ab22
Update azuread in landingzone
LaurentLesle May 19, 2021
7868063
Refactor AKS addons
hieumoscow May 19, 2021
a94d1f0
Merge branch 'azure_devops_v1' of https://github.com/Azure/caf-terraf…
hieumoscow May 19, 2021
fb3e3ef
Add support for mtms bootstrap scenario
LaurentLesle May 20, 2021
285ab82
Update for mtms scenarios
LaurentLesle May 21, 2021
0e1fe01
Merge remote-tracking branch 'origin/azure_devops_v1' into mtms
LaurentLesle May 21, 2021
d6bf992
Removed duplicate azuread_applications stanza
May 24, 2021
700b4a8
update devops and azuread_app
May 28, 2021
776f2a2
Added aks_secure_baseline_v2 with Flux provider and refactor aks addons
hieumoscow May 30, 2021
7e53af3
Merge branch 'master' of https://github.com/Azure/caf-terraform-landi…
hieumoscow May 30, 2021
7e446e0
Add sas_token to remote_tfstate different tenant
LaurentLesle May 31, 2021
ad7eb70
Merge branch 'mtms' of https://github.com/Azure/caf-terraform-landing…
LaurentLesle May 31, 2021
336a9fe
Fix mtms sas token for remote states
LaurentLesle May 31, 2021
9be14c2
Update kustomization.tf
hieumoscow Jun 2, 2021
8c0961d
Merge remote-tracking branch 'origin/azure_devops_v1' into mtms
Jun 2, 2021
ef2728d
Add org_url for aks_azure_devops_agents addon
hieumoscow Jun 2, 2021
05f55c2
Merge branch 'azure_devops_v1' of https://github.com/Azure/caf-terraf…
hieumoscow Jun 2, 2021
4b6f9cd
Fix kuztomize agent bug
hieumoscow Jun 2, 2021
905e803
Merge remote-tracking branch 'origin/azure_devops_v1' into mtms
Jun 2, 2021
e85e7c7
Update kustomization.tf
hieumoscow Jun 3, 2021
148be2f
Merge remote-tracking branch 'origin/azure_devops_v1' into mtms
Jun 3, 2021
9339a7a
Update flux.tf
eedorenko Jun 3, 2021
091af7d
aks_kubeconfig_cmd to output
eedorenko Jun 3, 2021
a7b6adc
added remote objects to support eslz
Jun 4, 2021
8286338
Update aks-pod-identity-assignment.tf
eedorenko Jun 4, 2021
1073290
Update aks-pod-identity-assignment.tf
eedorenko Jun 4, 2021
580530b
Rename aks-pod-identity-assignment.tf to aks-pod-identity-assignment.…
eedorenko Jun 4, 2021
645d489
Rename aks-pod-identity-assignment.ignore to aks-pod-identity-assignm…
hieumoscow Jun 5, 2021
39e5b49
Update flux.tf
hieumoscow Jun 5, 2021
b9b021a
Update flux.tf
hieumoscow Jun 5, 2021
5ce3a95
Merge remote-tracking branch 'origin/master' into mtms
LaurentLesle Jun 5, 2021
9270104
Update to mtms module
LaurentLesle Jun 5, 2021
87889ae
Add azuread_password_policies
LaurentLesle Jun 6, 2021
fbd2fb2
Update launchpad with azuread variables
LaurentLesle Jun 6, 2021
ee78cd2
Fix mtms bootstrap
LaurentLesle Jun 6, 2021
59160f4
Update source
LaurentLesle Jun 6, 2021
b8f325e
Add flux_install_yaml_documents_without_namespace
hieumoscow Jun 7, 2021
f8e4c5a
Merge remote-tracking branch 'origin/azure_devops_v1' into mtms
Jun 7, 2021
e0bb4b7
hahicorp vault add on
Jun 8, 2021
15d641b
added uniform module name
Jun 8, 2021
b4268f3
unload caf solution and removed unwanted variables
Jun 8, 2021
b9588dc
removed unused variables
Jun 8, 2021
f4b3916
added readme and example to deploy
Jun 8, 2021
bc4b204
modified readme and folder name
Jun 8, 2021
2c4a284
readme updated and generic example
Jun 8, 2021
7ba8bd6
removed unwanted providers
Jun 9, 2021
d05a829
functionality to fetch secrets from key vault
Jun 9, 2021
a5cafe1
added comment for information
Jun 9, 2021
6293ca0
typo fixed
Jun 9, 2021
705b2a5
typo fixed
Jun 9, 2021
21ae22f
chnage naming convention for add-on
Jun 10, 2021
6f3c657
Add remote azurerm_firewall_policies
jorseng Jun 11, 2021
1a4eb62
fix source in caf solutions
Jun 14, 2021
6ddb1ab
Add fw policy rule collection groups
LaurentLesle Jun 15, 2021
3d025ca
Add cross-tenant vnet to vhub
LaurentLesle Jun 15, 2021
2c78df6
Fix module source
LaurentLesle Jun 15, 2021
b264765
Added support for vpn_sites
Jun 8, 2021
b0233bd
Added support for vpn_gateway_connections
Jun 16, 2021
3962b7e
fix source caf solutions
Jun 17, 2021
d6c54ae
Add create namespace to helm chart
LaurentLesle Jun 18, 2021
9640b4d
fix remote tfstate issue for eslz
Jun 17, 2021
d6f3d94
Merge pull request #207 from papunsenapati07/feature/vault-addon
LaurentLesle Jun 18, 2021
27c224e
Merge pull request #210 from carldjohnston/vpn-site
LaurentLesle Jun 18, 2021
3c747ad
Add cross subscription access support for kv secret
jorseng Jun 21, 2021
2231632
Add cross subscrition access for kv in devops_v1
jorseng Jun 21, 2021
2cda697
added output to debug
Jun 22, 2021
e1a701d
chnages for remote states
Jun 22, 2021
528780c
remove output from module
Jun 22, 2021
2cda869
revert back to mtms
Jun 22, 2021
aa39c46
add remote objects feature for var group
Jun 23, 2021
b618e9f
Merge pull request #213 from papunsenapati07/mtms
arnaudlh Jun 23, 2021
052cee1
Merge branch '5.4.0' into mtms
arnaudlh Jun 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
**/*.log
**/backend.azurerm.tf
public
aztfmod
aztfmod
*output.json
26 changes: 17 additions & 9 deletions caf_launchpad/landingzone.tf
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
module "launchpad" {
source = "aztfmod/caf/azurerm"
version = "~>5.3.2"
# source = "aztfmod/caf/azurerm"
# version = "~>5.3.2"

# source = "git::https://github.com/aztfmod/terraform-azurerm-caf.git?ref=master"
source = "git::https://github.com/aztfmod/terraform-azurerm-caf.git?ref=mtms"
# source = "../../aztfmod"

# azuread = var.azuread
azuread_api_permissions = var.azuread_api_permissions
azuread_apps = var.azuread_apps
azuread_groups = var.azuread_groups
azuread_roles = var.azuread_roles
azuread_users = var.azuread_users
current_landingzone_key = var.landingzone.key
custom_role_definitions = var.custom_role_definitions
enable = var.enable
Expand All @@ -22,6 +17,7 @@ module "launchpad" {
logged_aad_app_objectId = var.logged_aad_app_objectId
logged_user_objectId = var.logged_user_objectId
managed_identities = var.managed_identities
remote_objects = local.remote
resource_groups = var.resource_groups
role_mapping = var.role_mapping
storage_accounts = var.storage_accounts
Expand All @@ -30,6 +26,18 @@ module "launchpad" {
tenant_id = var.tenant_id
user_type = var.user_type

azuread = {
azuread_api_permissions = var.azuread_api_permissions
azuread_applications = var.azuread_applications
azuread_apps = var.azuread_apps
azuread_credential_policies = var.azuread_credential_policies
azuread_groups = var.azuread_groups
azuread_roles = var.azuread_roles
azuread_service_principal_passwords = var.azuread_service_principal_passwords
azuread_service_principals = var.azuread_service_principals
azuread_users = var.azuread_users
}

diagnostics = {
diagnostics_definition = try(var.diagnostics.diagnostics_definition, var.diagnostics_definition)
diagnostics_destinations = try(var.diagnostics.diagnostics_destinations, var.diagnostics_destinations)
Expand Down
7 changes: 7 additions & 0 deletions caf_launchpad/local.remote.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
locals {
remote = {
azuread_service_principals = {
for key, value in try(var.landingzone.tfstates, {}) : key => merge(try(data.terraform_remote_state.remote[key].outputs.objects[key].azuread_service_principals, {}))
}
}
}
36 changes: 36 additions & 0 deletions caf_launchpad/locals.remote_tfstates.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
locals {
landingzone = {
current = {
storage_account_name = var.tfstate_storage_account_name
container_name = var.tfstate_container_name
resource_group_name = var.tfstate_resource_group_name
}
}
}

data "terraform_remote_state" "remote" {
for_each = try(var.landingzone.tfstates, {})

backend = var.landingzone.backend_type
config = local.remote_state[try(each.value.backend_type, var.landingzone.backend_type, "azurerm")][each.key]
}

locals {

remote_state = {

azurerm = {
for key, value in try(var.landingzone.tfstates, {}) : key => {
container_name = value.workspace
key = value.tfstate
resource_group_name = value.resource_group_name
storage_account_name = value.storage_account_name
subscription_id = value.subscription_id
tenant_id = value.tenant_id
sas_token = try(value.sas_token, null) != null ? var.sas_token : null
}
}

}

}
17 changes: 17 additions & 0 deletions caf_launchpad/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ variable "tenant_id" {}
variable "landingzone" {
description = "The landing zone name is used to reference the tfstate in configuration files. Therefore while set it is recommended not to change"
}
variable "sas_token" {
description = "SAS Token to access the remote state in another Azure AD tenant."
default = null
}

variable "passthrough" {
default = false
Expand Down Expand Up @@ -100,6 +104,15 @@ variable "azuread_users" {
variable "azuread_roles" {
default = {}
}
variable "azuread_credential_policies" {
default = {}
}
variable "azuread_service_principals" {
default = {}
}
variable "azuread_service_principal_passwords" {
default = {}
}
variable "managed_identities" {
default = {}
}
Expand Down Expand Up @@ -152,6 +165,10 @@ variable "azuread_api_permissions" {
default = {}
}

variable "azuread_applications" {
default = {}
}

variable "environment" {
type = string
description = "This variable is set by the rover during the deployment based on the -env or -environment flags. Default to sandpit"
Expand Down
5 changes: 4 additions & 1 deletion caf_solution/add-ons/aad-pod-identity/aad-msi-binding.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# https://github.com/Azure/aad-pod-identity/blob/b3ee1d07209f26c47a96abf3ba20749932763de6/website/content/en/docs/Concepts/azureidentity.md

apiVersion: aadpodidentity.k8s.io/v1
kind: AzureIdentity
metadata:
Expand All @@ -13,4 +15,5 @@ metadata:
name: podmi-gitlab-runner-binding
spec:
azureIdentity: podmi-caf-rover-platform-level0
selector: podmi-caf-rover-platform-level0
selector: podmi-caf-rover-platform-level0

2 changes: 2 additions & 0 deletions caf_solution/add-ons/aad-pod-identity/aad_pod_identity.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# https://github.com/Azure/aad-pod-identity/blob/b3ee1d07209f26c47a96abf3ba20749932763de6/website/content/en/docs/Concepts/azureidentity.md

resource "kubernetes_namespace" "ns" {
metadata {
name = var.aad_pod_identity.namespace
Expand Down
2 changes: 1 addition & 1 deletion caf_solution/add-ons/aad-pod-identity/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ variable "lower_container_name" {}
variable "lower_resource_group_name" {}

variable "tfstate_subscription_id" {
description = "This value is propulated by the rover. subscription id hosting the remote tfstates"
description = "This value is populated by the rover. subscription id hosting the remote tfstates"
}
variable "tfstate_storage_account_name" {}
variable "tfstate_container_name" {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,13 @@ locals {
) : format("%s-%s", msi.key, msi.msi_key) => msi
}
}

resource "azurerm_key_vault_access_policy" "keyvault_policy" {
# provider = azurerm.launchpad
for_each = var.keyvaults

key_vault_id = local.remote.keyvaults[each.value.lz_key][each.value.key].id
tenant_id = data.azurerm_client_config.current.tenant_id
object_id = local.remote.aks_clusters[var.aks_clusters[var.aks_cluster_key].lz_key][var.aks_clusters[var.aks_cluster_key].key].kubelet_identity[0].object_id
secret_permissions = each.value.secret_permissions
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ locals {
aks_clusters = {
for key, value in try(var.landingzone.tfstates, {}) : key => merge(try(data.terraform_remote_state.remote[key].outputs.objects[key].aks_clusters, {}))
}
keyvaults = {
for key, value in try(var.landingzone.tfstates, {}) : key => merge(try(data.terraform_remote_state.remote[key].outputs.objects[key].keyvaults, {}))
}
managed_identities = {
for key, value in try(var.landingzone.tfstates, {}) : key => merge(try(data.terraform_remote_state.remote[key].outputs.objects[key].managed_identities, {}))
}
Expand Down
9 changes: 9 additions & 0 deletions caf_solution/add-ons/aks-secure-baseline/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ provider "azurerm" {
}
}

provider "azurerm" {
alias = "launchpad"
subscription_id = var.tfstate_subscription_id
features {
}
}

provider "kubernetes" {
host = local.k8sconfigs[var.aks_cluster_key].host
username = local.k8sconfigs[var.aks_cluster_key].username
Expand Down Expand Up @@ -31,6 +38,8 @@ locals {
}
}

data "azurerm_client_config" "current" {}

# Get kubeconfig from AKS clusters
data "azurerm_kubernetes_cluster" "kubeconfig" {
for_each = var.aks_clusters
Expand Down
5 changes: 4 additions & 1 deletion caf_solution/add-ons/aks-secure-baseline/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,7 @@ variable "managed_identities" {
description = "Map of the user managed identities."
}

variable "aad_pod_identity" {}
variable "aad_pod_identity" {}
variable "keyvaults" {
default = {}
}
20 changes: 13 additions & 7 deletions caf_solution/add-ons/aks_applications/app/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
provider "kubernetes" {
alias = "k8s"
}

provider "helm" {
alias = "helm"
}
terraform {
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
}
helm = {
source = "hashicorp/helm"
}
kustomization = {
source = "kbst/kustomization"
}
}
}
5 changes: 2 additions & 3 deletions caf_solution/add-ons/aks_applications/app/module.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ resource "kubernetes_namespace" "namespaces" {
name = each.value.name
}

provider = kubernetes.k8s
}

# https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release
Expand All @@ -22,6 +21,7 @@ resource "helm_release" "charts" {
timeout = try(each.value.timeout, 900)
skip_crds = try(each.value.skip_crds, false)
create_namespace = try(each.value.create_namespace, false)
values = try(each.value.values, null)

dynamic "set" {
for_each = try(each.value.sets, {})
Expand All @@ -39,9 +39,8 @@ resource "helm_release" "charts" {
}
}

provider = helm.helm

depends_on = [kubernetes_namespace.namespaces]
# depends_on = [kubernetes_namespace.namespaces]
# values = [
# "${file("values.yaml")}"
# ]
Expand Down
12 changes: 9 additions & 3 deletions caf_solution/add-ons/aks_applications/app/variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
variable "cluster" {}
variable "namespaces" {
default = {}
}

variable "namespaces" {}
variable "helm_charts" {
default = {}
}

variable "helm_charts" {}
variable "kuztomization_settings" {
default = {}
}
24 changes: 1 addition & 23 deletions caf_solution/add-ons/aks_applications/applications.tf
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
module "app1" {
module "app" {
source = "./app"
for_each = try(local.clusters[var.cluster_re1_key], null) != null ? { (var.cluster_re1_key) = local.clusters[var.cluster_re1_key] } : {}

cluster = each.value
namespaces = var.namespaces
helm_charts = var.helm_charts

providers = {
kubernetes.k8s = kubernetes.k8s1
helm.helm = helm.helm1
}
}

module "app2" {
source = "./app"
for_each = try(local.clusters[var.cluster_re2_key], null) != null ? { (var.cluster_re2_key) = local.clusters[var.cluster_re2_key] } : {}

cluster = each.value
namespaces = var.namespaces
helm_charts = var.helm_charts

providers = {
kubernetes.k8s = kubernetes.k8s2
helm.helm = helm.helm2
}
}
31 changes: 31 additions & 0 deletions caf_solution/add-ons/aks_applications/kustomization.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module "kustomization" {
source = "./kustomize"
for_each = try(data.kustomization_overlay.manifest, {})

settings = each.value

}

data "kustomization_overlay" "manifest" {
for_each = var.kustomization_overlays

resources = each.value.resources

namespace = each.value.namespace

dynamic "patches"{
for_each = try(each.value.patches, {})
content {
patch = patches.value.patch
target = patches.value.target
}
}
kustomize_options = {
load_restrictor = "none"
}
}

output "manifests" {
value = data.kustomization_overlay.manifest
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
resource "kustomization_resource" "p0" {
for_each = var.settings.ids_prio[0]
manifest = var.settings.manifests[each.value]
}

resource "kustomization_resource" "p1" {
depends_on = [kustomization_resource.p0]
for_each = var.settings.ids_prio[1]
manifest = var.settings.manifests[each.value]
}

resource "kustomization_resource" "p2" {
depends_on = [kustomization_resource.p1]
for_each = var.settings.ids_prio[2]
manifest = var.settings.manifests[each.value]
}
7 changes: 7 additions & 0 deletions caf_solution/add-ons/aks_applications/kustomize/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
terraform {
required_providers {
kustomization = {
source = "kbst/kustomization"
}
}
}
2 changes: 2 additions & 0 deletions caf_solution/add-ons/aks_applications/kustomize/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
variable "settings" {
}