Skip to content

Commit c91c9f6

Browse files
committed
updating codebase and stalling... thanks to Azure
1 parent 03d5d9c commit c91c9f6

File tree

5 files changed

+55
-94
lines changed

5 files changed

+55
-94
lines changed

terraform/acr_aks.tf

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
resource "azurerm_resource_group" "this_resource_group" {
42
name = var.resource_group_name
53
location = var.location
@@ -14,31 +12,31 @@ resource "azurerm_container_registry" "this_container_registry" {
1412
depends_on = [azurerm_resource_group.this_resource_group]
1513
}
1614

17-
resource "azurerm_kubernetes_cluster" "this_aks_cluster" {
18-
name = var.aks_name
19-
location = var.location
20-
resource_group_name = azurerm_resource_group.this_resource_group.name
21-
dns_prefix = "DevSecOps-Blueprint"
22-
23-
24-
default_node_pool {
25-
name = "default"
26-
node_count = 1
27-
vm_size = "Standard_A2_v2"
28-
}
29-
30-
identity {
31-
type = "UserAssigned"
32-
identity_ids = [azurerm_user_assigned_identity.this_uaid.id]
33-
}
34-
35-
tags = {
36-
Environment = "Production"
37-
}
38-
depends_on = [
39-
azurerm_role_assignment.uaid_contributor,
40-
azurerm_role_assignment.acr_pull,
41-
azurerm_role_assignment.acr_push
42-
]
43-
}
15+
# resource "azurerm_kubernetes_cluster" "this_aks_cluster" {
16+
# name = var.aks_name
17+
# location = var.location
18+
# resource_group_name = azurerm_resource_group.this_resource_group.name
19+
# dns_prefix = "DSB"
20+
21+
22+
# default_node_pool {
23+
# name = "default"
24+
# node_count = 1
25+
# vm_size = "Standard_A2_v2"
26+
# }
27+
28+
# identity {
29+
# type = "UserAssigned"
30+
# identity_ids = [azurerm_user_assigned_identity.this_uaid.id]
31+
# }
32+
33+
# tags = {
34+
# Environment = "Production"
35+
# }
36+
# depends_on = [
37+
# azurerm_role_assignment.uaid_contributor,
38+
# azurerm_role_assignment.acr_pull,
39+
# azurerm_role_assignment.acr_push
40+
# ]
41+
# }
4442

terraform/main.tf

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ data "azuread_client_config" "current" {}
33

44
### Create a new Azure DevOps project
55
resource "azuredevops_project" "this_project" {
6-
name = var.project_name
7-
visibility = "public"
6+
name = "python-fastapi"
7+
visibility = "private"
88
version_control = "Git"
99
work_item_template = "Agile"
1010
description = "This project is managed and Created by Terraform"
@@ -14,7 +14,6 @@ resource "azuredevops_project" "this_project" {
1414
boards = "disabled"
1515
pipelines = "enabled"
1616
repositories = "enabled"
17-
1817
}
1918
}
2019

@@ -43,7 +42,6 @@ resource "azuredevops_git_repository" "fast_api_git_repo" {
4342
init_type = "Import"
4443
source_type = "Git"
4544
source_url = var.fast_api_git_repo
46-
# service_connection_id = azuredevops_serviceendpoint_github.this_github.id
4745
}
4846

4947
}
@@ -64,7 +62,7 @@ resource "azuredevops_build_definition" "this_definition" {
6462
repository {
6563
repo_type = "TfsGit"
6664
repo_id = azuredevops_git_repository.infra_git_repo.id
67-
branch_name = "testing"
65+
branch_name = "main"
6866
yml_path = ".azdo-pipelines/azure-pipelines.yml"
6967
}
7068

@@ -79,12 +77,6 @@ resource "azuredevops_build_definition" "this_definition" {
7977
value = "FastAPI"
8078

8179
}
82-
83-
variable {
84-
name = "ProjetName"
85-
value = "Smooth-Project-Name"
86-
87-
}
8880
}
8981

9082
### Create Federated identity for Azure DevOps Pipeline ###
@@ -112,12 +104,6 @@ resource "azurerm_role_assignment" "uaid_contributor" {
112104
scope = azurerm_container_registry.this_container_registry.id
113105
}
114106

115-
# resource "azuread_application" "this_app" {
116-
# display_name = "Az-DevSecOps-App"
117-
# owners = [data.azuread_client_config.current.object_id]
118-
# }
119-
120-
121107
resource "azurerm_federated_identity_credential" "ado_fed-id" {
122108
name = "DevSecOps-Fed-Identity"
123109
resource_group_name = azurerm_resource_group.this_resource_group.name
@@ -147,9 +133,4 @@ resource "azuredevops_serviceendpoint_azurecr" "acr_registry_endpoint" {
147133
credentials {
148134
serviceprincipalid = azurerm_user_assigned_identity.this_uaid.client_id
149135
}
150-
151-
152-
153-
154-
}
155-
136+
}

terraform/providers.tf

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@ terraform {
2626

2727

2828
provider "azuredevops" {
29-
org_service_url = var.org_service_url
29+
org_service_url = var.TFC_AZ_DEVOPS_ORG_SERVICE_URL
30+
personal_access_token = var.TFC_AZ_DEVOPS_PAT
3031
}
3132

3233
provider "azuread" {
33-
tenant_id = "233318cd-0fbb-44eb-9437-4e2681adf87e"
34+
tenant_id = var.TFC_AZ_TENANT_ID
35+
client_id = var.TFC_AZ_CLIENT_ID
36+
client_secret = var.TFC_AZ_CLIENT_PASSWORD
3437

38+
use_cli = false
3539
}
3640

3741
provider "azurerm" {
@@ -41,10 +45,9 @@ provider "azurerm" {
4145
}
4246
}
4347

44-
use_cli = false
45-
use_oidc = true
46-
client_id_file_path = var.tfc_azure_dynamic_credentials.default.client_id_file_path
47-
oidc_token_file_path = var.tfc_azure_dynamic_credentials.default.oidc_token_file_path
48-
subscription_id = "9e3af6ab-6e22-4d23-a3ef-a6e883abe616"
49-
tenant_id = "233318cd-0fbb-44eb-9437-4e2681adf87e"
48+
use_cli = false
49+
subscription_id = var.TFC_AZ_SUBSCRIPTION_ID
50+
tenant_id = var.TFC_AZ_TENANT_ID
51+
client_id = var.TFC_AZ_CLIENT_ID
52+
client_secret = var.TFC_AZ_CLIENT_PASSWORD
5053
}

terraform/variable-group.tf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ resource "azuredevops_variable_group" "infra_variable_group" {
1515
name = "ACR_SERVICE_CONNECTION"
1616
secret_value = azuredevops_serviceendpoint_azurecr.acr_registry_endpoint.id
1717
is_secret = true
18-
1918
}
20-
19+
2120
variable {
2221
name = "image_repo"
2322
secret_value = var.fast_api_git_repo
@@ -50,5 +49,4 @@ resource "azuredevops_variable_group" "image_repo_variable" {
5049
value = ""
5150

5251
}
53-
5452
}

terraform/variables.tf

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
2-
variable "tfc_azure_dynamic_credentials" {
3-
description = "Object containing Azure dynamic credentials configuration"
4-
type = object({
5-
default = object({
6-
client_id_file_path = string
7-
oidc_token_file_path = string
8-
})
9-
aliases = map(object({
10-
client_id_file_path = string
11-
oidc_token_file_path = string
12-
}))
13-
})
14-
}
1+
# Default Variables
2+
variable "TFC_AZ_CLIENT_ID" {}
3+
variable "TFC_AZ_CLIENT_PASSWORD" {}
4+
variable "TFC_AZ_TENANT_ID" {}
5+
variable "TFC_AZ_SUBSCRIPTION_ID" {}
6+
variable "TFC_AZ_DEVOPS_ORG_SERVICE_URL" {}
7+
variable "TFC_AZ_DEVOPS_PAT" {}
158

169
### Resource Group Variables ###
1710

@@ -31,18 +24,17 @@ variable "location" {
3124
### Repo Variables ###
3225
variable "infra_git_repo" {
3326
type = string
34-
description = " of the infra git repo"
35-
default = "https://github.com/thogue12/azure-devsecops-pipeline.git"
36-
27+
description = "name of the infra git repo"
28+
default = "https://github.com/devsecblueprint/azure-devsecops-pipeline.git"
3729
}
3830

3931
variable "fast_api_git_repo" {
4032
type = string
41-
description = "name of the infra git repo"
42-
default = "https://github.com/thogue12/python-fastapi.git"
33+
description = "name of the fast api git repo"
34+
default = "https://github.com/devsecblueprint/azure-python-fastapi.git"
4335
}
44-
#### Azure Container Registry and Kubernetes Variables ###
4536

37+
#### Azure Container Registry and Kubernetes Variables ###
4638
variable "acr_name" {
4739
type = string
4840
description = "name of the Azure Container Registry"
@@ -65,17 +57,6 @@ variable "uaid_name" {
6557
}
6658

6759
### Azure DevOps Variables ###
68-
variable "project_name" {
69-
description = "The name of the Azure DevOps project to create."
70-
type = string
71-
default = "DevSecOps-FastApi"
72-
73-
}
74-
75-
variable "org_service_url" {
76-
type = string
77-
sensitive = true
78-
}
7960

8061
variable "use_yaml" {
8162
description = "Bolean to determine if the pipeline should use the trigger defined in the yaml file or not"

0 commit comments

Comments
 (0)