TeamCity Terraform Provider
This provider leverages the HashiCorp Terraform infrastructure as code approach to allow DevOps engineers to initialize the JetBrains TeamCity server and automate its administration.
Check out our great blog post about this terraform provider with an awesome demo made by Daniel Gallo!
TeamCity Terraform provider supports Terraform 0.13 and newer.
Common Information
The TeamCity Terraform Provider allows you to:
- Manage global server settings (server URL, maximum artifact size, VCS polling interval, and more)
- Set up routine server operations like cleanups and email notifications
- Create and manage users, user groups, and permissions
- Set up licenses and authentication modules
See the Documentation for the complete list of available resources and their fields.
In addition, you can include blocks that initialize and set up TeamCity projects, VCS roots, and more. However, be aware that the same operations are also available to project administrators via Kotlin DSL configuration files.
We recommend setting some ground rules for your workflow to enforce a single source of truth and avoid conflicting settings from
.tfand.ktsconfigurations. For example, you may want to utilize the Terraform Provider only for the initial TeamCity server setup and global administration, whereas individual projects are managed using Kotlin DSL.
Initial Setup
Add the TeamCity Terraform Provider to the required_providers block of your configuration and specify valid credentials as follows:
terraform {
required_providers {
teamcity = {
source = "jetbrains/teamcity"
}
}
}
provider "teamcity" {
host = "http://localhost:8111"
token = "env.TEAMCITY_TOKEN"
}
host— the URL of your TeamCity servertoken— the TeamCity Access Token issued for a user who has sufficient permissions to manage users, projects, and the server itself. It is recommended to store this token in an environment variable instead of passing it as a plain string value.
Examples
Refer to our Documentation for available resources and configuration samples.
For more advanced examples, see the /examples/ folder:
-
examples/1-server_settingsBasic TeamCity server configuration with built-in and GitHub App authentication, GitHub connection and simple clean up rules.
-
examples/2-permissionsThis example demonstrates how to configure Role and User group for a Project
-
examples/3-projectA TeamCity project with Versioned Settings enabled, VCS root with SSH key and a waiter script to wait for Kotlin DSL to be compiled and applied to the project
-
examples/4-moduleExample with a module used for creating several similar Projects
-
examples/5-clone_reposCreate a new GitHub repository from existing template and add corresponding Project to TeamCity server.
-
examples/6-read_reposImport all existing GitHub repositories in organisation to TeamCity server creating corresponding Project for each fo them.
-
examples/7-import_resourcesImporting existing resources from a running TeamCity instance.
These samples rely on existing GitHub organisation, so, they are not easily runnable as is, since the custom GitHub app cannot be re-used, and GitHub provides no API to create it automatically. Also, all used repositories are created in teamcity-terraform-test organisation.
License
This project is licensed under the Mozilla Public License 2.0. For more information, please see the LICENSE file.