1. Packages
  2. AzureDevOps
  3. API Docs
  4. CheckBranchControl
Azure DevOps v2.15.0 published on Thursday, Jan 11, 2024 by Pulumi

azuredevops.CheckBranchControl

Explore with Pulumi AI

azuredevops logo
Azure DevOps v2.15.0 published on Thursday, Jan 11, 2024 by Pulumi

    Manages a branch control check on a resource within Azure DevOps.

    Example Usage

    Protect a service connection

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AzureDevOps = Pulumi.AzureDevOps;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleProject = new AzureDevOps.Project("exampleProject");
    
        var exampleServiceEndpointGeneric = new AzureDevOps.ServiceEndpointGeneric("exampleServiceEndpointGeneric", new()
        {
            ProjectId = exampleProject.Id,
            ServerUrl = "https://some-server.example.com",
            Username = "username",
            Password = "password",
            ServiceEndpointName = "Example Generic",
            Description = "Managed by Terraform",
        });
    
        var exampleCheckBranchControl = new AzureDevOps.CheckBranchControl("exampleCheckBranchControl", new()
        {
            ProjectId = exampleProject.Id,
            DisplayName = "Managed by Terraform",
            TargetResourceId = exampleServiceEndpointGeneric.Id,
            TargetResourceType = "endpoint",
            AllowedBranches = "refs/heads/main, refs/heads/features/*",
            Timeout = 1440,
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azuredevops/sdk/v2/go/azuredevops"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		exampleProject, err := azuredevops.NewProject(ctx, "exampleProject", nil)
    		if err != nil {
    			return err
    		}
    		exampleServiceEndpointGeneric, err := azuredevops.NewServiceEndpointGeneric(ctx, "exampleServiceEndpointGeneric", &azuredevops.ServiceEndpointGenericArgs{
    			ProjectId:           exampleProject.ID(),
    			ServerUrl:           pulumi.String("https://some-server.example.com"),
    			Username:            pulumi.String("username"),
    			Password:            pulumi.String("password"),
    			ServiceEndpointName: pulumi.String("Example Generic"),
    			Description:         pulumi.String("Managed by Terraform"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = azuredevops.NewCheckBranchControl(ctx, "exampleCheckBranchControl", &azuredevops.CheckBranchControlArgs{
    			ProjectId:          exampleProject.ID(),
    			DisplayName:        pulumi.String("Managed by Terraform"),
    			TargetResourceId:   exampleServiceEndpointGeneric.ID(),
    			TargetResourceType: pulumi.String("endpoint"),
    			AllowedBranches:    pulumi.String("refs/heads/main, refs/heads/features/*"),
    			Timeout:            pulumi.Int(1440),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.azuredevops.Project;
    import com.pulumi.azuredevops.ServiceEndpointGeneric;
    import com.pulumi.azuredevops.ServiceEndpointGenericArgs;
    import com.pulumi.azuredevops.CheckBranchControl;
    import com.pulumi.azuredevops.CheckBranchControlArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var exampleProject = new Project("exampleProject");
    
            var exampleServiceEndpointGeneric = new ServiceEndpointGeneric("exampleServiceEndpointGeneric", ServiceEndpointGenericArgs.builder()        
                .projectId(exampleProject.id())
                .serverUrl("https://some-server.example.com")
                .username("username")
                .password("password")
                .serviceEndpointName("Example Generic")
                .description("Managed by Terraform")
                .build());
    
            var exampleCheckBranchControl = new CheckBranchControl("exampleCheckBranchControl", CheckBranchControlArgs.builder()        
                .projectId(exampleProject.id())
                .displayName("Managed by Terraform")
                .targetResourceId(exampleServiceEndpointGeneric.id())
                .targetResourceType("endpoint")
                .allowedBranches("refs/heads/main, refs/heads/features/*")
                .timeout(1440)
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_azuredevops as azuredevops
    
    example_project = azuredevops.Project("exampleProject")
    example_service_endpoint_generic = azuredevops.ServiceEndpointGeneric("exampleServiceEndpointGeneric",
        project_id=example_project.id,
        server_url="https://some-server.example.com",
        username="username",
        password="password",
        service_endpoint_name="Example Generic",
        description="Managed by Terraform")
    example_check_branch_control = azuredevops.CheckBranchControl("exampleCheckBranchControl",
        project_id=example_project.id,
        display_name="Managed by Terraform",
        target_resource_id=example_service_endpoint_generic.id,
        target_resource_type="endpoint",
        allowed_branches="refs/heads/main, refs/heads/features/*",
        timeout=1440)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as azuredevops from "@pulumi/azuredevops";
    
    const exampleProject = new azuredevops.Project("exampleProject", {});
    const exampleServiceEndpointGeneric = new azuredevops.ServiceEndpointGeneric("exampleServiceEndpointGeneric", {
        projectId: exampleProject.id,
        serverUrl: "https://some-server.example.com",
        username: "username",
        password: "password",
        serviceEndpointName: "Example Generic",
        description: "Managed by Terraform",
    });
    const exampleCheckBranchControl = new azuredevops.CheckBranchControl("exampleCheckBranchControl", {
        projectId: exampleProject.id,
        displayName: "Managed by Terraform",
        targetResourceId: exampleServiceEndpointGeneric.id,
        targetResourceType: "endpoint",
        allowedBranches: "refs/heads/main, refs/heads/features/*",
        timeout: 1440,
    });
    
    resources:
      exampleProject:
        type: azuredevops:Project
      exampleServiceEndpointGeneric:
        type: azuredevops:ServiceEndpointGeneric
        properties:
          projectId: ${exampleProject.id}
          serverUrl: https://some-server.example.com
          username: username
          password: password
          serviceEndpointName: Example Generic
          description: Managed by Terraform
      exampleCheckBranchControl:
        type: azuredevops:CheckBranchControl
        properties:
          projectId: ${exampleProject.id}
          displayName: Managed by Terraform
          targetResourceId: ${exampleServiceEndpointGeneric.id}
          targetResourceType: endpoint
          allowedBranches: refs/heads/main, refs/heads/features/*
          timeout: 1440
    

    Protect an environment

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AzureDevOps = Pulumi.AzureDevOps;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleProject = new AzureDevOps.Project("exampleProject");
    
        var exampleEnvironment = new AzureDevOps.Environment("exampleEnvironment", new()
        {
            ProjectId = exampleProject.Id,
        });
    
        var exampleCheckBranchControl = new AzureDevOps.CheckBranchControl("exampleCheckBranchControl", new()
        {
            ProjectId = exampleProject.Id,
            DisplayName = "Managed by Terraform",
            TargetResourceId = exampleEnvironment.Id,
            TargetResourceType = "environment",
            AllowedBranches = "refs/heads/main, refs/heads/features/*",
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azuredevops/sdk/v2/go/azuredevops"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		exampleProject, err := azuredevops.NewProject(ctx, "exampleProject", nil)
    		if err != nil {
    			return err
    		}
    		exampleEnvironment, err := azuredevops.NewEnvironment(ctx, "exampleEnvironment", &azuredevops.EnvironmentArgs{
    			ProjectId: exampleProject.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = azuredevops.NewCheckBranchControl(ctx, "exampleCheckBranchControl", &azuredevops.CheckBranchControlArgs{
    			ProjectId:          exampleProject.ID(),
    			DisplayName:        pulumi.String("Managed by Terraform"),
    			TargetResourceId:   exampleEnvironment.ID(),
    			TargetResourceType: pulumi.String("environment"),
    			AllowedBranches:    pulumi.String("refs/heads/main, refs/heads/features/*"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.azuredevops.Project;
    import com.pulumi.azuredevops.Environment;
    import com.pulumi.azuredevops.EnvironmentArgs;
    import com.pulumi.azuredevops.CheckBranchControl;
    import com.pulumi.azuredevops.CheckBranchControlArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var exampleProject = new Project("exampleProject");
    
            var exampleEnvironment = new Environment("exampleEnvironment", EnvironmentArgs.builder()        
                .projectId(exampleProject.id())
                .build());
    
            var exampleCheckBranchControl = new CheckBranchControl("exampleCheckBranchControl", CheckBranchControlArgs.builder()        
                .projectId(exampleProject.id())
                .displayName("Managed by Terraform")
                .targetResourceId(exampleEnvironment.id())
                .targetResourceType("environment")
                .allowedBranches("refs/heads/main, refs/heads/features/*")
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_azuredevops as azuredevops
    
    example_project = azuredevops.Project("exampleProject")
    example_environment = azuredevops.Environment("exampleEnvironment", project_id=example_project.id)
    example_check_branch_control = azuredevops.CheckBranchControl("exampleCheckBranchControl",
        project_id=example_project.id,
        display_name="Managed by Terraform",
        target_resource_id=example_environment.id,
        target_resource_type="environment",
        allowed_branches="refs/heads/main, refs/heads/features/*")
    
    import * as pulumi from "@pulumi/pulumi";
    import * as azuredevops from "@pulumi/azuredevops";
    
    const exampleProject = new azuredevops.Project("exampleProject", {});
    const exampleEnvironment = new azuredevops.Environment("exampleEnvironment", {projectId: exampleProject.id});
    const exampleCheckBranchControl = new azuredevops.CheckBranchControl("exampleCheckBranchControl", {
        projectId: exampleProject.id,
        displayName: "Managed by Terraform",
        targetResourceId: exampleEnvironment.id,
        targetResourceType: "environment",
        allowedBranches: "refs/heads/main, refs/heads/features/*",
    });
    
    resources:
      exampleProject:
        type: azuredevops:Project
      exampleEnvironment:
        type: azuredevops:Environment
        properties:
          projectId: ${exampleProject.id}
      exampleCheckBranchControl:
        type: azuredevops:CheckBranchControl
        properties:
          projectId: ${exampleProject.id}
          displayName: Managed by Terraform
          targetResourceId: ${exampleEnvironment.id}
          targetResourceType: environment
          allowedBranches: refs/heads/main, refs/heads/features/*
    

    Protect an agent queue

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AzureDevOps = Pulumi.AzureDevOps;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleProject = new AzureDevOps.Project("exampleProject");
    
        var examplePool = new AzureDevOps.Pool("examplePool");
    
        var exampleQueue = new AzureDevOps.Queue("exampleQueue", new()
        {
            ProjectId = exampleProject.Id,
            AgentPoolId = examplePool.Id,
        });
    
        var exampleCheckBranchControl = new AzureDevOps.CheckBranchControl("exampleCheckBranchControl", new()
        {
            ProjectId = exampleProject.Id,
            DisplayName = "Managed by Terraform",
            TargetResourceId = exampleQueue.Id,
            TargetResourceType = "queue",
            AllowedBranches = "refs/heads/main, refs/heads/features/*",
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azuredevops/sdk/v2/go/azuredevops"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		exampleProject, err := azuredevops.NewProject(ctx, "exampleProject", nil)
    		if err != nil {
    			return err
    		}
    		examplePool, err := azuredevops.NewPool(ctx, "examplePool", nil)
    		if err != nil {
    			return err
    		}
    		exampleQueue, err := azuredevops.NewQueue(ctx, "exampleQueue", &azuredevops.QueueArgs{
    			ProjectId:   exampleProject.ID(),
    			AgentPoolId: examplePool.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = azuredevops.NewCheckBranchControl(ctx, "exampleCheckBranchControl", &azuredevops.CheckBranchControlArgs{
    			ProjectId:          exampleProject.ID(),
    			DisplayName:        pulumi.String("Managed by Terraform"),
    			TargetResourceId:   exampleQueue.ID(),
    			TargetResourceType: pulumi.String("queue"),
    			AllowedBranches:    pulumi.String("refs/heads/main, refs/heads/features/*"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.azuredevops.Project;
    import com.pulumi.azuredevops.Pool;
    import com.pulumi.azuredevops.Queue;
    import com.pulumi.azuredevops.QueueArgs;
    import com.pulumi.azuredevops.CheckBranchControl;
    import com.pulumi.azuredevops.CheckBranchControlArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var exampleProject = new Project("exampleProject");
    
            var examplePool = new Pool("examplePool");
    
            var exampleQueue = new Queue("exampleQueue", QueueArgs.builder()        
                .projectId(exampleProject.id())
                .agentPoolId(examplePool.id())
                .build());
    
            var exampleCheckBranchControl = new CheckBranchControl("exampleCheckBranchControl", CheckBranchControlArgs.builder()        
                .projectId(exampleProject.id())
                .displayName("Managed by Terraform")
                .targetResourceId(exampleQueue.id())
                .targetResourceType("queue")
                .allowedBranches("refs/heads/main, refs/heads/features/*")
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_azuredevops as azuredevops
    
    example_project = azuredevops.Project("exampleProject")
    example_pool = azuredevops.Pool("examplePool")
    example_queue = azuredevops.Queue("exampleQueue",
        project_id=example_project.id,
        agent_pool_id=example_pool.id)
    example_check_branch_control = azuredevops.CheckBranchControl("exampleCheckBranchControl",
        project_id=example_project.id,
        display_name="Managed by Terraform",
        target_resource_id=example_queue.id,
        target_resource_type="queue",
        allowed_branches="refs/heads/main, refs/heads/features/*")
    
    import * as pulumi from "@pulumi/pulumi";
    import * as azuredevops from "@pulumi/azuredevops";
    
    const exampleProject = new azuredevops.Project("exampleProject", {});
    const examplePool = new azuredevops.Pool("examplePool", {});
    const exampleQueue = new azuredevops.Queue("exampleQueue", {
        projectId: exampleProject.id,
        agentPoolId: examplePool.id,
    });
    const exampleCheckBranchControl = new azuredevops.CheckBranchControl("exampleCheckBranchControl", {
        projectId: exampleProject.id,
        displayName: "Managed by Terraform",
        targetResourceId: exampleQueue.id,
        targetResourceType: "queue",
        allowedBranches: "refs/heads/main, refs/heads/features/*",
    });
    
    resources:
      exampleProject:
        type: azuredevops:Project
      examplePool:
        type: azuredevops:Pool
      exampleQueue:
        type: azuredevops:Queue
        properties:
          projectId: ${exampleProject.id}
          agentPoolId: ${examplePool.id}
      exampleCheckBranchControl:
        type: azuredevops:CheckBranchControl
        properties:
          projectId: ${exampleProject.id}
          displayName: Managed by Terraform
          targetResourceId: ${exampleQueue.id}
          targetResourceType: queue
          allowedBranches: refs/heads/main, refs/heads/features/*
    

    Protect a repository

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AzureDevOps = Pulumi.AzureDevOps;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleProject = new AzureDevOps.Project("exampleProject");
    
        var exampleGit = new AzureDevOps.Git("exampleGit", new()
        {
            ProjectId = exampleProject.Id,
            Initialization = new AzureDevOps.Inputs.GitInitializationArgs
            {
                InitType = "Clean",
            },
        });
    
        var exampleCheckBranchControl = new AzureDevOps.CheckBranchControl("exampleCheckBranchControl", new()
        {
            ProjectId = exampleProject.Id,
            DisplayName = "Managed by Terraform",
            TargetResourceId = Output.Tuple(exampleProject.Id, exampleGit.Id).Apply(values =>
            {
                var exampleProjectId = values.Item1;
                var exampleGitId = values.Item2;
                return $"{exampleProjectId}.{exampleGitId}";
            }),
            TargetResourceType = "repository",
            AllowedBranches = "refs/heads/main, refs/heads/features/*",
        });
    
    });
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-azuredevops/sdk/v2/go/azuredevops"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		exampleProject, err := azuredevops.NewProject(ctx, "exampleProject", nil)
    		if err != nil {
    			return err
    		}
    		exampleGit, err := azuredevops.NewGit(ctx, "exampleGit", &azuredevops.GitArgs{
    			ProjectId: exampleProject.ID(),
    			Initialization: &azuredevops.GitInitializationArgs{
    				InitType: pulumi.String("Clean"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = azuredevops.NewCheckBranchControl(ctx, "exampleCheckBranchControl", &azuredevops.CheckBranchControlArgs{
    			ProjectId:   exampleProject.ID(),
    			DisplayName: pulumi.String("Managed by Terraform"),
    			TargetResourceId: pulumi.All(exampleProject.ID(), exampleGit.ID()).ApplyT(func(_args []interface{}) (string, error) {
    				exampleProjectId := _args[0].(string)
    				exampleGitId := _args[1].(string)
    				return fmt.Sprintf("%v.%v", exampleProjectId, exampleGitId), nil
    			}).(pulumi.StringOutput),
    			TargetResourceType: pulumi.String("repository"),
    			AllowedBranches:    pulumi.String("refs/heads/main, refs/heads/features/*"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.azuredevops.Project;
    import com.pulumi.azuredevops.Git;
    import com.pulumi.azuredevops.GitArgs;
    import com.pulumi.azuredevops.inputs.GitInitializationArgs;
    import com.pulumi.azuredevops.CheckBranchControl;
    import com.pulumi.azuredevops.CheckBranchControlArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var exampleProject = new Project("exampleProject");
    
            var exampleGit = new Git("exampleGit", GitArgs.builder()        
                .projectId(exampleProject.id())
                .initialization(GitInitializationArgs.builder()
                    .initType("Clean")
                    .build())
                .build());
    
            var exampleCheckBranchControl = new CheckBranchControl("exampleCheckBranchControl", CheckBranchControlArgs.builder()        
                .projectId(exampleProject.id())
                .displayName("Managed by Terraform")
                .targetResourceId(Output.tuple(exampleProject.id(), exampleGit.id()).applyValue(values -> {
                    var exampleProjectId = values.t1;
                    var exampleGitId = values.t2;
                    return String.format("%s.%s", exampleProjectId,exampleGitId);
                }))
                .targetResourceType("repository")
                .allowedBranches("refs/heads/main, refs/heads/features/*")
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_azuredevops as azuredevops
    
    example_project = azuredevops.Project("exampleProject")
    example_git = azuredevops.Git("exampleGit",
        project_id=example_project.id,
        initialization=azuredevops.GitInitializationArgs(
            init_type="Clean",
        ))
    example_check_branch_control = azuredevops.CheckBranchControl("exampleCheckBranchControl",
        project_id=example_project.id,
        display_name="Managed by Terraform",
        target_resource_id=pulumi.Output.all(example_project.id, example_git.id).apply(lambda exampleProjectId, exampleGitId: f"{example_project_id}.{example_git_id}"),
        target_resource_type="repository",
        allowed_branches="refs/heads/main, refs/heads/features/*")
    
    import * as pulumi from "@pulumi/pulumi";
    import * as azuredevops from "@pulumi/azuredevops";
    
    const exampleProject = new azuredevops.Project("exampleProject", {});
    const exampleGit = new azuredevops.Git("exampleGit", {
        projectId: exampleProject.id,
        initialization: {
            initType: "Clean",
        },
    });
    const exampleCheckBranchControl = new azuredevops.CheckBranchControl("exampleCheckBranchControl", {
        projectId: exampleProject.id,
        displayName: "Managed by Terraform",
        targetResourceId: pulumi.interpolate`${exampleProject.id}.${exampleGit.id}`,
        targetResourceType: "repository",
        allowedBranches: "refs/heads/main, refs/heads/features/*",
    });
    
    resources:
      exampleProject:
        type: azuredevops:Project
      exampleGit:
        type: azuredevops:Git
        properties:
          projectId: ${exampleProject.id}
          initialization:
            initType: Clean
      exampleCheckBranchControl:
        type: azuredevops:CheckBranchControl
        properties:
          projectId: ${exampleProject.id}
          displayName: Managed by Terraform
          targetResourceId: ${exampleProject.id}.${exampleGit.id}
          targetResourceType: repository
          allowedBranches: refs/heads/main, refs/heads/features/*
    

    Protect a variable group

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AzureDevOps = Pulumi.AzureDevOps;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleProject = new AzureDevOps.Project("exampleProject");
    
        var exampleVariableGroup = new AzureDevOps.VariableGroup("exampleVariableGroup", new()
        {
            ProjectId = exampleProject.Id,
            Description = "Example Variable Group Description",
            AllowAccess = true,
            Variables = new[]
            {
                new AzureDevOps.Inputs.VariableGroupVariableArgs
                {
                    Name = "key1",
                    Value = "val1",
                },
                new AzureDevOps.Inputs.VariableGroupVariableArgs
                {
                    Name = "key2",
                    SecretValue = "val2",
                    IsSecret = true,
                },
            },
        });
    
        var exampleCheckBranchControl = new AzureDevOps.CheckBranchControl("exampleCheckBranchControl", new()
        {
            ProjectId = exampleProject.Id,
            DisplayName = "Managed by Terraform",
            TargetResourceId = exampleVariableGroup.Id,
            TargetResourceType = "variablegroup",
            AllowedBranches = "refs/heads/main, refs/heads/features/*",
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azuredevops/sdk/v2/go/azuredevops"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		exampleProject, err := azuredevops.NewProject(ctx, "exampleProject", nil)
    		if err != nil {
    			return err
    		}
    		exampleVariableGroup, err := azuredevops.NewVariableGroup(ctx, "exampleVariableGroup", &azuredevops.VariableGroupArgs{
    			ProjectId:   exampleProject.ID(),
    			Description: pulumi.String("Example Variable Group Description"),
    			AllowAccess: pulumi.Bool(true),
    			Variables: azuredevops.VariableGroupVariableArray{
    				&azuredevops.VariableGroupVariableArgs{
    					Name:  pulumi.String("key1"),
    					Value: pulumi.String("val1"),
    				},
    				&azuredevops.VariableGroupVariableArgs{
    					Name:        pulumi.String("key2"),
    					SecretValue: pulumi.String("val2"),
    					IsSecret:    pulumi.Bool(true),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = azuredevops.NewCheckBranchControl(ctx, "exampleCheckBranchControl", &azuredevops.CheckBranchControlArgs{
    			ProjectId:          exampleProject.ID(),
    			DisplayName:        pulumi.String("Managed by Terraform"),
    			TargetResourceId:   exampleVariableGroup.ID(),
    			TargetResourceType: pulumi.String("variablegroup"),
    			AllowedBranches:    pulumi.String("refs/heads/main, refs/heads/features/*"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.azuredevops.Project;
    import com.pulumi.azuredevops.VariableGroup;
    import com.pulumi.azuredevops.VariableGroupArgs;
    import com.pulumi.azuredevops.inputs.VariableGroupVariableArgs;
    import com.pulumi.azuredevops.CheckBranchControl;
    import com.pulumi.azuredevops.CheckBranchControlArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var exampleProject = new Project("exampleProject");
    
            var exampleVariableGroup = new VariableGroup("exampleVariableGroup", VariableGroupArgs.builder()        
                .projectId(exampleProject.id())
                .description("Example Variable Group Description")
                .allowAccess(true)
                .variables(            
                    VariableGroupVariableArgs.builder()
                        .name("key1")
                        .value("val1")
                        .build(),
                    VariableGroupVariableArgs.builder()
                        .name("key2")
                        .secretValue("val2")
                        .isSecret(true)
                        .build())
                .build());
    
            var exampleCheckBranchControl = new CheckBranchControl("exampleCheckBranchControl", CheckBranchControlArgs.builder()        
                .projectId(exampleProject.id())
                .displayName("Managed by Terraform")
                .targetResourceId(exampleVariableGroup.id())
                .targetResourceType("variablegroup")
                .allowedBranches("refs/heads/main, refs/heads/features/*")
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_azuredevops as azuredevops
    
    example_project = azuredevops.Project("exampleProject")
    example_variable_group = azuredevops.VariableGroup("exampleVariableGroup",
        project_id=example_project.id,
        description="Example Variable Group Description",
        allow_access=True,
        variables=[
            azuredevops.VariableGroupVariableArgs(
                name="key1",
                value="val1",
            ),
            azuredevops.VariableGroupVariableArgs(
                name="key2",
                secret_value="val2",
                is_secret=True,
            ),
        ])
    example_check_branch_control = azuredevops.CheckBranchControl("exampleCheckBranchControl",
        project_id=example_project.id,
        display_name="Managed by Terraform",
        target_resource_id=example_variable_group.id,
        target_resource_type="variablegroup",
        allowed_branches="refs/heads/main, refs/heads/features/*")
    
    import * as pulumi from "@pulumi/pulumi";
    import * as azuredevops from "@pulumi/azuredevops";
    
    const exampleProject = new azuredevops.Project("exampleProject", {});
    const exampleVariableGroup = new azuredevops.VariableGroup("exampleVariableGroup", {
        projectId: exampleProject.id,
        description: "Example Variable Group Description",
        allowAccess: true,
        variables: [
            {
                name: "key1",
                value: "val1",
            },
            {
                name: "key2",
                secretValue: "val2",
                isSecret: true,
            },
        ],
    });
    const exampleCheckBranchControl = new azuredevops.CheckBranchControl("exampleCheckBranchControl", {
        projectId: exampleProject.id,
        displayName: "Managed by Terraform",
        targetResourceId: exampleVariableGroup.id,
        targetResourceType: "variablegroup",
        allowedBranches: "refs/heads/main, refs/heads/features/*",
    });
    
    resources:
      exampleProject:
        type: azuredevops:Project
      exampleVariableGroup:
        type: azuredevops:VariableGroup
        properties:
          projectId: ${exampleProject.id}
          description: Example Variable Group Description
          allowAccess: true
          variables:
            - name: key1
              value: val1
            - name: key2
              secretValue: val2
              isSecret: true
      exampleCheckBranchControl:
        type: azuredevops:CheckBranchControl
        properties:
          projectId: ${exampleProject.id}
          displayName: Managed by Terraform
          targetResourceId: ${exampleVariableGroup.id}
          targetResourceType: variablegroup
          allowedBranches: refs/heads/main, refs/heads/features/*
    

    Create CheckBranchControl Resource

    new CheckBranchControl(name: string, args: CheckBranchControlArgs, opts?: CustomResourceOptions);
    @overload
    def CheckBranchControl(resource_name: str,
                           opts: Optional[ResourceOptions] = None,
                           allowed_branches: Optional[str] = None,
                           display_name: Optional[str] = None,
                           ignore_unknown_protection_status: Optional[bool] = None,
                           project_id: Optional[str] = None,
                           target_resource_id: Optional[str] = None,
                           target_resource_type: Optional[str] = None,
                           timeout: Optional[int] = None,
                           verify_branch_protection: Optional[bool] = None)
    @overload
    def CheckBranchControl(resource_name: str,
                           args: CheckBranchControlArgs,
                           opts: Optional[ResourceOptions] = None)
    func NewCheckBranchControl(ctx *Context, name string, args CheckBranchControlArgs, opts ...ResourceOption) (*CheckBranchControl, error)
    public CheckBranchControl(string name, CheckBranchControlArgs args, CustomResourceOptions? opts = null)
    public CheckBranchControl(String name, CheckBranchControlArgs args)
    public CheckBranchControl(String name, CheckBranchControlArgs args, CustomResourceOptions options)
    
    type: azuredevops:CheckBranchControl
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args CheckBranchControlArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args CheckBranchControlArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args CheckBranchControlArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args CheckBranchControlArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args CheckBranchControlArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    CheckBranchControl Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The CheckBranchControl resource accepts the following input properties:

    ProjectId string
    The project ID.
    TargetResourceId string
    The ID of the resource being protected by the check.
    TargetResourceType string
    The type of resource being protected by the check. Valid values: endpoint, environment, queue, repository, securefile, variablegroup.
    AllowedBranches string
    The branches allowed to use the resource. Specify a comma separated list of allowed branches in refs/heads/branch_name format. To allow deployments from all branches, specify * . refs/heads/features/* , refs/heads/releases/* restricts deployments to all branches under features/ or releases/ . Defaults to *.
    DisplayName string
    The name of the branch control check displayed in the web UI.
    IgnoreUnknownProtectionStatus bool
    Allow deployment from branches for which protection status could not be obtained. Only relevant when verify_branch_protection is true. Defaults to false.
    Timeout int
    The timeout in minutes for the branch control check. Defaults to 1440.
    VerifyBranchProtection bool
    Validate the branches being deployed are protected. Defaults to false.
    ProjectId string
    The project ID.
    TargetResourceId string
    The ID of the resource being protected by the check.
    TargetResourceType string
    The type of resource being protected by the check. Valid values: endpoint, environment, queue, repository, securefile, variablegroup.
    AllowedBranches string
    The branches allowed to use the resource. Specify a comma separated list of allowed branches in refs/heads/branch_name format. To allow deployments from all branches, specify * . refs/heads/features/* , refs/heads/releases/* restricts deployments to all branches under features/ or releases/ . Defaults to *.
    DisplayName string
    The name of the branch control check displayed in the web UI.
    IgnoreUnknownProtectionStatus bool
    Allow deployment from branches for which protection status could not be obtained. Only relevant when verify_branch_protection is true. Defaults to false.
    Timeout int
    The timeout in minutes for the branch control check. Defaults to 1440.
    VerifyBranchProtection bool
    Validate the branches being deployed are protected. Defaults to false.
    projectId String
    The project ID.
    targetResourceId String
    The ID of the resource being protected by the check.
    targetResourceType String
    The type of resource being protected by the check. Valid values: endpoint, environment, queue, repository, securefile, variablegroup.
    allowedBranches String
    The branches allowed to use the resource. Specify a comma separated list of allowed branches in refs/heads/branch_name format. To allow deployments from all branches, specify * . refs/heads/features/* , refs/heads/releases/* restricts deployments to all branches under features/ or releases/ . Defaults to *.
    displayName String
    The name of the branch control check displayed in the web UI.
    ignoreUnknownProtectionStatus Boolean
    Allow deployment from branches for which protection status could not be obtained. Only relevant when verify_branch_protection is true. Defaults to false.
    timeout Integer
    The timeout in minutes for the branch control check. Defaults to 1440.
    verifyBranchProtection Boolean
    Validate the branches being deployed are protected. Defaults to false.
    projectId string
    The project ID.
    targetResourceId string
    The ID of the resource being protected by the check.
    targetResourceType string
    The type of resource being protected by the check. Valid values: endpoint, environment, queue, repository, securefile, variablegroup.
    allowedBranches string
    The branches allowed to use the resource. Specify a comma separated list of allowed branches in refs/heads/branch_name format. To allow deployments from all branches, specify * . refs/heads/features/* , refs/heads/releases/* restricts deployments to all branches under features/ or releases/ . Defaults to *.
    displayName string
    The name of the branch control check displayed in the web UI.
    ignoreUnknownProtectionStatus boolean
    Allow deployment from branches for which protection status could not be obtained. Only relevant when verify_branch_protection is true. Defaults to false.
    timeout number
    The timeout in minutes for the branch control check. Defaults to 1440.
    verifyBranchProtection boolean
    Validate the branches being deployed are protected. Defaults to false.
    project_id str
    The project ID.
    target_resource_id str
    The ID of the resource being protected by the check.
    target_resource_type str
    The type of resource being protected by the check. Valid values: endpoint, environment, queue, repository, securefile, variablegroup.
    allowed_branches str
    The branches allowed to use the resource. Specify a comma separated list of allowed branches in refs/heads/branch_name format. To allow deployments from all branches, specify * . refs/heads/features/* , refs/heads/releases/* restricts deployments to all branches under features/ or releases/ . Defaults to *.
    display_name str
    The name of the branch control check displayed in the web UI.
    ignore_unknown_protection_status bool
    Allow deployment from branches for which protection status could not be obtained. Only relevant when verify_branch_protection is true. Defaults to false.
    timeout int
    The timeout in minutes for the branch control check. Defaults to 1440.
    verify_branch_protection bool
    Validate the branches being deployed are protected. Defaults to false.
    projectId String
    The project ID.
    targetResourceId String
    The ID of the resource being protected by the check.
    targetResourceType String
    The type of resource being protected by the check. Valid values: endpoint, environment, queue, repository, securefile, variablegroup.
    allowedBranches String
    The branches allowed to use the resource. Specify a comma separated list of allowed branches in refs/heads/branch_name format. To allow deployments from all branches, specify * . refs/heads/features/* , refs/heads/releases/* restricts deployments to all branches under features/ or releases/ . Defaults to *.
    displayName String
    The name of the branch control check displayed in the web UI.
    ignoreUnknownProtectionStatus Boolean
    Allow deployment from branches for which protection status could not be obtained. Only relevant when verify_branch_protection is true. Defaults to false.
    timeout Number
    The timeout in minutes for the branch control check. Defaults to 1440.
    verifyBranchProtection Boolean
    Validate the branches being deployed are protected. Defaults to false.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the CheckBranchControl resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing CheckBranchControl Resource

    Get an existing CheckBranchControl resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: CheckBranchControlState, opts?: CustomResourceOptions): CheckBranchControl
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            allowed_branches: Optional[str] = None,
            display_name: Optional[str] = None,
            ignore_unknown_protection_status: Optional[bool] = None,
            project_id: Optional[str] = None,
            target_resource_id: Optional[str] = None,
            target_resource_type: Optional[str] = None,
            timeout: Optional[int] = None,
            verify_branch_protection: Optional[bool] = None) -> CheckBranchControl
    func GetCheckBranchControl(ctx *Context, name string, id IDInput, state *CheckBranchControlState, opts ...ResourceOption) (*CheckBranchControl, error)
    public static CheckBranchControl Get(string name, Input<string> id, CheckBranchControlState? state, CustomResourceOptions? opts = null)
    public static CheckBranchControl get(String name, Output<String> id, CheckBranchControlState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    AllowedBranches string
    The branches allowed to use the resource. Specify a comma separated list of allowed branches in refs/heads/branch_name format. To allow deployments from all branches, specify * . refs/heads/features/* , refs/heads/releases/* restricts deployments to all branches under features/ or releases/ . Defaults to *.
    DisplayName string
    The name of the branch control check displayed in the web UI.
    IgnoreUnknownProtectionStatus bool
    Allow deployment from branches for which protection status could not be obtained. Only relevant when verify_branch_protection is true. Defaults to false.
    ProjectId string
    The project ID.
    TargetResourceId string
    The ID of the resource being protected by the check.
    TargetResourceType string
    The type of resource being protected by the check. Valid values: endpoint, environment, queue, repository, securefile, variablegroup.
    Timeout int
    The timeout in minutes for the branch control check. Defaults to 1440.
    VerifyBranchProtection bool
    Validate the branches being deployed are protected. Defaults to false.
    AllowedBranches string
    The branches allowed to use the resource. Specify a comma separated list of allowed branches in refs/heads/branch_name format. To allow deployments from all branches, specify * . refs/heads/features/* , refs/heads/releases/* restricts deployments to all branches under features/ or releases/ . Defaults to *.
    DisplayName string
    The name of the branch control check displayed in the web UI.
    IgnoreUnknownProtectionStatus bool
    Allow deployment from branches for which protection status could not be obtained. Only relevant when verify_branch_protection is true. Defaults to false.
    ProjectId string
    The project ID.
    TargetResourceId string
    The ID of the resource being protected by the check.
    TargetResourceType string
    The type of resource being protected by the check. Valid values: endpoint, environment, queue, repository, securefile, variablegroup.
    Timeout int
    The timeout in minutes for the branch control check. Defaults to 1440.
    VerifyBranchProtection bool
    Validate the branches being deployed are protected. Defaults to false.
    allowedBranches String
    The branches allowed to use the resource. Specify a comma separated list of allowed branches in refs/heads/branch_name format. To allow deployments from all branches, specify * . refs/heads/features/* , refs/heads/releases/* restricts deployments to all branches under features/ or releases/ . Defaults to *.
    displayName String
    The name of the branch control check displayed in the web UI.
    ignoreUnknownProtectionStatus Boolean
    Allow deployment from branches for which protection status could not be obtained. Only relevant when verify_branch_protection is true. Defaults to false.
    projectId String
    The project ID.
    targetResourceId String
    The ID of the resource being protected by the check.
    targetResourceType String
    The type of resource being protected by the check. Valid values: endpoint, environment, queue, repository, securefile, variablegroup.
    timeout Integer
    The timeout in minutes for the branch control check. Defaults to 1440.
    verifyBranchProtection Boolean
    Validate the branches being deployed are protected. Defaults to false.
    allowedBranches string
    The branches allowed to use the resource. Specify a comma separated list of allowed branches in refs/heads/branch_name format. To allow deployments from all branches, specify * . refs/heads/features/* , refs/heads/releases/* restricts deployments to all branches under features/ or releases/ . Defaults to *.
    displayName string
    The name of the branch control check displayed in the web UI.
    ignoreUnknownProtectionStatus boolean
    Allow deployment from branches for which protection status could not be obtained. Only relevant when verify_branch_protection is true. Defaults to false.
    projectId string
    The project ID.
    targetResourceId string
    The ID of the resource being protected by the check.
    targetResourceType string
    The type of resource being protected by the check. Valid values: endpoint, environment, queue, repository, securefile, variablegroup.
    timeout number
    The timeout in minutes for the branch control check. Defaults to 1440.
    verifyBranchProtection boolean
    Validate the branches being deployed are protected. Defaults to false.
    allowed_branches str
    The branches allowed to use the resource. Specify a comma separated list of allowed branches in refs/heads/branch_name format. To allow deployments from all branches, specify * . refs/heads/features/* , refs/heads/releases/* restricts deployments to all branches under features/ or releases/ . Defaults to *.
    display_name str
    The name of the branch control check displayed in the web UI.
    ignore_unknown_protection_status bool
    Allow deployment from branches for which protection status could not be obtained. Only relevant when verify_branch_protection is true. Defaults to false.
    project_id str
    The project ID.
    target_resource_id str
    The ID of the resource being protected by the check.
    target_resource_type str
    The type of resource being protected by the check. Valid values: endpoint, environment, queue, repository, securefile, variablegroup.
    timeout int
    The timeout in minutes for the branch control check. Defaults to 1440.
    verify_branch_protection bool
    Validate the branches being deployed are protected. Defaults to false.
    allowedBranches String
    The branches allowed to use the resource. Specify a comma separated list of allowed branches in refs/heads/branch_name format. To allow deployments from all branches, specify * . refs/heads/features/* , refs/heads/releases/* restricts deployments to all branches under features/ or releases/ . Defaults to *.
    displayName String
    The name of the branch control check displayed in the web UI.
    ignoreUnknownProtectionStatus Boolean
    Allow deployment from branches for which protection status could not be obtained. Only relevant when verify_branch_protection is true. Defaults to false.
    projectId String
    The project ID.
    targetResourceId String
    The ID of the resource being protected by the check.
    targetResourceType String
    The type of resource being protected by the check. Valid values: endpoint, environment, queue, repository, securefile, variablegroup.
    timeout Number
    The timeout in minutes for the branch control check. Defaults to 1440.
    verifyBranchProtection Boolean
    Validate the branches being deployed are protected. Defaults to false.

    Import

    Importing this resource is not supported.

    Package Details

    Repository
    Azure DevOps pulumi/pulumi-azuredevops
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the azuredevops Terraform Provider.
    azuredevops logo
    Azure DevOps v2.15.0 published on Thursday, Jan 11, 2024 by Pulumi