@@ -2,7 +2,7 @@ data "azuread_client_config" "current" {}
22
33
44# ## Create a new Azure DevOps project
5- resource "azuredevops_project" "this_project " {
5+ resource "azuredevops_project" "this " {
66 name = " python-fastapi"
77 visibility = " private"
88 version_control = " Git"
@@ -18,22 +18,18 @@ resource "azuredevops_project" "this_project" {
1818}
1919
2020# ## Create a new Git repository for FastAPI
21- resource "azuredevops_git_repository" "fast_api_git_repo" {
22- project_id = azuredevops_project. this_project . id
23- name = " azure-python-fastapi"
24-
25- initialization {
26- init_type = " Import"
27- source_type = " Git"
28- source_url = var. fast_api_git_repo
29- }
21+ resource "azuredevops_serviceendpoint_github" "this" {
22+ project_id = azuredevops_project. this . id
23+ service_endpoint_name = " python-fastapi"
3024
25+ auth_personal {
26+ personal_access_token = var. TFC_AZ_DEVOPS_GITHUB_PAT
27+ }
3128}
3229
33-
3430# ## Create Build Definition ###
35- resource "azuredevops_build_definition" "this_definition " {
36- project_id = azuredevops_project. this_project . id
31+ resource "azuredevops_build_definition" "this " {
32+ project_id = azuredevops_project. this . id
3733 name = " Default"
3834
3935 ci_trigger {
@@ -42,10 +38,11 @@ resource "azuredevops_build_definition" "this_definition" {
4238
4339
4440 repository {
45- repo_type = " default "
46- repo_id = azuredevops_git_repository . fast_api_git_repo . id
41+ repo_type = " GitHub "
42+ repo_id = " devsecblueprint/azure-python-fastapi "
4743 branch_name = " main"
4844 yml_path = " .azdo-pipelines/azure-pipelines.yml"
45+ service_connection_id = azuredevops_serviceendpoint_github. this . id
4946 }
5047
5148
@@ -96,13 +93,13 @@ resource "azurerm_federated_identity_credential" "ado_fed-id" {
9693 # sc://thogue1267/DevSecOps-FastApi/TimBoslice-Connection
9794 # # sc://<organization>/<project>/<service-connection-name> "this = subject"
9895
99- depends_on = [azuredevops_build_definition . this_definition ]
96+ depends_on = [azuredevops_build_definition . this ]
10097}
10198
10299# ## Create Service Connection to Azure Container Registry ###
103100# ## Authenticates the pipeline to ACR using OIDC and a User-Assigned Managed Identity ###
104101resource "azuredevops_serviceendpoint_azurecr" "acr_registry_endpoint" {
105- project_id = azuredevops_project. this_project . id
102+ project_id = azuredevops_project. this . id
106103 resource_group = var. resource_group_name
107104 service_endpoint_name = " AzureCR Endpoint"
108105 service_endpoint_authentication_scheme = " WorkloadIdentityFederation"
0 commit comments