Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ If you have many remote repositories that you need to manage via this pattern, y
| <a name="input_aws_integration_attachment_write"></a> [aws\_integration\_attachment\_write](#input\_aws\_integration\_attachment\_write) | Indicates whether this attachment is used for write operations. | `bool` | `true` | no |
| <a name="input_aws_integration_enabled"></a> [aws\_integration\_enabled](#input\_aws\_integration\_enabled) | Indicates whether the AWS integration is enabled. | `bool` | `false` | no |
| <a name="input_aws_integration_id"></a> [aws\_integration\_id](#input\_aws\_integration\_id) | ID of the AWS integration to attach. | `string` | `null` | no |
| <a name="input_azure_devops"></a> [azure\_devops](#input\_azure\_devops) | The Azure DevOps integration settings | <pre>object({<br/> project = string<br/> id = optional(string)<br/> })</pre> | `null` | no |
| <a name="input_before_apply"></a> [before\_apply](#input\_before\_apply) | List of before-apply scripts | `list(string)` | `[]` | no |
| <a name="input_before_destroy"></a> [before\_destroy](#input\_before\_destroy) | List of before-destroy scripts | `list(string)` | `[]` | no |
| <a name="input_before_init"></a> [before\_init](#input\_before\_init) | List of before-init scripts | `list(string)` | `[]` | no |
Expand Down
22 changes: 22 additions & 0 deletions examples/azure-devops/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Azure DevOps Integration Example

This example demonstrates how to configure the spacelift-automation module with Azure DevOps as the version control system.

See Spacelift's full walk through here, https://docs.spacelift.io/integrations/source-control/azure-devops

## Configuration

The key difference from GitHub integration is using the `azure_devops` block instead of `github_enterprise`:

```hcl
azure_devops = {
project = "MyProject" # Your Azure DevOps project name
id = "integration-id" # Spacelift Azure DevOps integration ID
}
```

## Usage

1. Update the `azure_devops.project` and `azure_devops.id` values with your Azure DevOps project and Spacelift integration ID
2. Update the `repository` value with your actual repository name
3. Run `terraform init` and `terraform plan` to see what resources will be created
39 changes: 39 additions & 0 deletions examples/azure-devops/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module "automation_azure_devops" {
source = "../../"

azure_devops = {
project = "MyProject-Spacelift-Project"
id = "name-of-your-azure-devops-integration-in-spacelift"
}
repository = "MyProject-Spacelift-Project"
branch = "main"

root_modules_path = "../../examples/complete/root-modules"
all_root_modules_enabled = true

aws_integration_id = "01JEC7ZACVKHTSVY4NF8QNZVVB"
aws_integration_enabled = true
}

module "spacelift_policies" {
source = "masterpointio/spacelift/policies"
version = "0.2.0"

policies = {
"access-default" = {
body = <<-EOT
package spacelift
default allow = true
EOT
type = "ACCESS"
description = "Policy allowing access to resources"
labels = ["team:sre", "env:dev"]
}

trigger-administrative = {
body_url = "https://raw.githubusercontent.com/cloudposse/terraform-spacelift-cloud-infrastructure-automation/1.6.0/catalog/policies/trigger.administrative.rego"
type = "TRIGGER"
labels = ["autoattach:*"] # Showcasing how to attach to ALL stacks
}
}
}
10 changes: 10 additions & 0 deletions examples/azure-devops/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = ">= 1.9"

required_providers {
spacelift = {
source = "spacelift-io/spacelift"
version = ">= 1.14"
}
}
}
10 changes: 9 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ locals {
for stack in local.stacks : stack => try(coalesce(
try(local.stack_configs[stack].worker_pool_id, null), # worker_pool_id always takes precedence since it's the most explicit
try(local.worker_pool_name_to_id[local.stack_configs[stack].worker_pool_name], null), # Then try to look up worker_pool_name from the stack.yaml to ID
var.worker_pool_id, # Then try to use the global variable worker_pool_id
var.worker_pool_id, # Then try to use the global variable worker_pool_id
try(local.worker_pool_name_to_id[var.worker_pool_name], null), # Then try to look up the global variable worker_pool_name to ID
), null) # If no worker_pool_id or worker_pool_name is provided, default to null
}
Expand Down Expand Up @@ -468,6 +468,14 @@ resource "spacelift_stack" "default" {
id = github_enterprise.value["id"]
}
}

dynamic "azure_devops" {
for_each = var.azure_devops != null ? [var.azure_devops] : []
content {
project = azure_devops.value["project"]
id = azure_devops.value["id"]
}
}
}

# The Spacelift Destructor is a feature designed to automatically clean up the resources no longer managed by our IaC.
Expand Down
9 changes: 9 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ variable "github_enterprise" {
default = null
}

variable "azure_devops" {
type = object({
project = string
id = optional(string)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the ID is left off, does anything work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If id is null, spacelift will try to use the default Azure DevOps integration.

})
description = "The Azure DevOps integration settings"
default = null
}

variable "repository" {
type = string
description = "The name of your infrastructure repo"
Expand Down