Skip to content

Commit

Permalink
Update to terraform 0.14 (#14)
Browse files Browse the repository at this point in the history
* update module to terraform 0.14
* update CI to terraform 0.14 / golang 1.14 (using custom test Docker image)
* update Azure pipeline
  • Loading branch information
jcorioland authored Jan 15, 2021
1 parent b2c1abc commit 56a3d8d
Show file tree
Hide file tree
Showing 20 changed files with 133 additions and 86 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
**/.terraform/*
terraform.tfstate.d/
logs/
.terraform.lock.hcl

# Variable files
terraform.tfvars
Expand Down
9 changes: 3 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pull the base image with given version.
ARG BUILD_TERRAFORM_VERSION="0.12.20"
FROM mcr.microsoft.com/terraform-test:${BUILD_TERRAFORM_VERSION}
ARG BUILD_TERRAFORM_VERSION="0.14.4"
FROM jcorioland/terraform-test:${BUILD_TERRAFORM_VERSION}

ARG MODULE_NAME="terraform-azure-devops-eagent-aci"

Expand All @@ -21,10 +21,7 @@ ENV ARM_TEST_LOCATION=${BUILD_ARM_TEST_LOCATION}
ENV ARM_TEST_LOCATION_ALT=${BUILD_ARM_TEST_LOCATION_ALT}

# Set work directory.
RUN mkdir /go
RUN mkdir /go/bin
RUN mkdir /go/src
RUN mkdir /go/src/${MODULE_NAME}
RUN mkdir -p /go/src/${MODULE_NAME}
COPY . /go/src/${MODULE_NAME}
WORKDIR /go/src/${MODULE_NAME}

Expand Down
11 changes: 7 additions & 4 deletions azure-pipeline.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# Azure Pipeline that runs module integration tests

trigger: none
trigger:
- master
pr:
- master

variables:
- group: AzureDevOpsACI.Secrets
- name: dockerImage
value: 'terraform-azure-devops-aci'
- name: terraformVersion
value: 0.12.25
value: 0.14.4
- name: vmImage
value: ubuntu-latest
value: ubuntu-18.04
- name: serviceConnection
value: "terraform-azure-devops-aci"

Expand Down Expand Up @@ -43,7 +46,7 @@ stages:
repository: $(dockerImage)
dockerfile: '$(System.DefaultWorkingDirectory)/Dockerfile'
buildContext: $(System.DefaultWorkingDirectory)
arguments: --build-arg BUILD_ARM_SUBSCRIPTION_ID=$(ARM_SUBSCRIPTION_ID) --build-arg BUILD_ARM_CLIENT_ID=$(ARM_CLIENT_ID) --build-arg BUILD_ARM_CLIENT_SECRET=$(ARM_CLIENT_SECRET) --build-arg BUILD_ARM_TENANT_ID=$(ARM_TENANT_ID)
arguments: --build-arg BUILD_ARM_SUBSCRIPTION_ID=$(ARM_SUBSCRIPTION_ID) --build-arg BUILD_ARM_CLIENT_ID=$(ARM_CLIENT_ID) --build-arg BUILD_ARM_CLIENT_SECRET=$(ARM_CLIENT_SECRET) --build-arg BUILD_ARM_TENANT_ID=$(ARM_TENANT_ID) --build-arg BUILD_TERRAFORM_VERSION=$(terraformVersion)
tags: |
$(Build.BuildId)
- script: |
Expand Down
3 changes: 0 additions & 3 deletions provider.tf

This file was deleted.

2 changes: 2 additions & 0 deletions test/azure_devops_agent_aci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ func TestDeployAzureDevOpsLinuxAgentsInVirtualNetwork(t *testing.T) {
devopsPoolName := os.Getenv("TF_VAR_azure_devops_pool_name")
testPoolName := fmt.Sprintf("%s-%s", devopsPoolName, randomSuffix)
os.Setenv("TF_VAR_azure_devops_pool_name", testPoolName)
// reset env var after test
defer os.Setenv("TF_VAR_azure_devops_pool_name", devopsPoolName)

devopsOrganizationName := os.Getenv("TF_VAR_azure_devops_org_name")
devopsPersonalAccessToken := os.Getenv("TF_VAR_azure_devops_personal_access_token")
Expand Down
7 changes: 4 additions & 3 deletions test/fixture/linux-agents-import-rg/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ resource "azurerm_resource_group" "rg" {
}

module "aci-devops-agent" {
source = "../../../"
enable_vnet_integration = false
create_resource_group = false
source = "../../../"
enable_vnet_integration = false
create_resource_group = false
linux_agents_configuration = {
agent_name_prefix = "linuxagent-${var.random_suffix}"
count = var.agents_count
Expand All @@ -20,4 +20,5 @@ module "aci-devops-agent" {
location = azurerm_resource_group.rg.location
azure_devops_org_name = var.azure_devops_org_name
azure_devops_personal_access_token = var.azure_devops_personal_access_token
depends_on = [azurerm_resource_group.rg]
}
9 changes: 9 additions & 0 deletions test/fixture/linux-agents-import-rg/provider.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 2.0"
}
}
}

provider "azurerm" {
features {}
}
16 changes: 8 additions & 8 deletions test/fixture/linux-agents-import-rg/variables.tf
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
variable azure_devops_org_name {
variable "azure_devops_org_name" {
type = string
description = "The name of the Azure DevOps organization in which the containerized agents will be deployed (e.g. https://dev.azure.com/YOUR_ORGANIZATION_NAME, must exist)"
}

variable azure_devops_pool_name {
variable "azure_devops_pool_name" {
type = string
description = "The name of the Azure DevOps agent pool in which the containerized agents will be deployed (must exist)"
}

variable azure_devops_personal_access_token {
variable "azure_devops_personal_access_token" {
type = string
description = "The personal access token to use to connect to Azure DevOps (see https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/v2-windows?view=azure-devops#permissions)"
}

variable location {
variable "location" {
type = string
description = "The Azure location to use"
default = "westeurope"
}

variable agent_docker_image {
variable "agent_docker_image" {
type = string
description = "The Docker image to use for the Linux agent"
default = "jcorioland/aci-devops-agent"
}

variable agent_docker_tag {
variable "agent_docker_tag" {
type = string
description = "The Docker tag to use for the Linux agent"
default = "0.2-linux"
}

variable agents_count {
variable "agents_count" {
type = number
description = "The number of agents to create"
default = 2
}

variable random_suffix {
variable "random_suffix" {
type = number
description = "A random suffix for resources generated during the test"
}
9 changes: 9 additions & 0 deletions test/fixture/linux-agents-private-registry/provider.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 2.0"
}
}
}

provider "azurerm" {
features {}
}
22 changes: 11 additions & 11 deletions test/fixture/linux-agents-private-registry/variables.tf
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
variable azure_devops_org_name {
variable "azure_devops_org_name" {
type = string
description = "The name of the Azure DevOps organization in which the containerized agents will be deployed (e.g. https://dev.azure.com/YOUR_ORGANIZATION_NAME, must exist)"
}

variable azure_devops_pool_name {
variable "azure_devops_pool_name" {
type = string
description = "The name of the Azure DevOps agent pool in which the containerized agents will be deployed (must exist)"
}

variable azure_devops_personal_access_token {
variable "azure_devops_personal_access_token" {
type = string
description = "The personal access token to use to connect to Azure DevOps (see https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/v2-windows?view=azure-devops#permissions)"
}

variable location {
variable "location" {
type = string
description = "The Azure location to use"
default = "westeurope"
}

variable agent_docker_image {
variable "agent_docker_image" {
type = string
description = "The Docker image to use for the Linux agent"
default = "jcorioland/aci-devops-agent"
}

variable agent_docker_tag {
variable "agent_docker_tag" {
type = string
description = "The Docker tag to use for the Linux agent"
default = "0.2-linux"
}

variable agents_count {
variable "agents_count" {
type = number
description = "The number of agents to create"
default = 2
}

variable random_suffix {
variable "random_suffix" {
type = number
description = "A random suffix for resources generated during the test"
}

variable docker_registry_url {
variable "docker_registry_url" {
type = string
description = "The server URL of the Docker private registry"
}

variable docker_registry_username {
variable "docker_registry_username" {
type = string
description = "The username of the Docker private registry"
}

variable docker_registry_password {
variable "docker_registry_password" {
type = string
description = "The password of the Docker private registry"
}
13 changes: 7 additions & 6 deletions test/fixture/linux-agents-vnet/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ resource "azurerm_subnet" "aci-subnet" {
}

module "aci-devops-agent" {
source = "../../../"
enable_vnet_integration = true
create_resource_group = true
vnet_resource_group_name = azurerm_resource_group.vnet-rg.name
vnet_name = azurerm_virtual_network.vnet.name
subnet_name = azurerm_subnet.aci-subnet.name
source = "../../../"
enable_vnet_integration = true
create_resource_group = true
vnet_resource_group_name = azurerm_resource_group.vnet-rg.name
vnet_name = azurerm_virtual_network.vnet.name
subnet_name = azurerm_subnet.aci-subnet.name
linux_agents_configuration = {
agent_name_prefix = "linuxagent-${var.random_suffix}"
count = var.agents_count
Expand All @@ -46,4 +46,5 @@ module "aci-devops-agent" {
location = var.location
azure_devops_org_name = var.azure_devops_org_name
azure_devops_personal_access_token = var.azure_devops_personal_access_token
depends_on = [azurerm_subnet.aci-subnet]
}
9 changes: 9 additions & 0 deletions test/fixture/linux-agents-vnet/provider.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 2.0"
}
}
}

provider "azurerm" {
features {}
}
16 changes: 8 additions & 8 deletions test/fixture/linux-agents-vnet/variables.tf
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
variable azure_devops_org_name {
variable "azure_devops_org_name" {
type = string
description = "The name of the Azure DevOps organization in which the containerized agents will be deployed (e.g. https://dev.azure.com/YOUR_ORGANIZATION_NAME, must exist)"
}

variable azure_devops_pool_name {
variable "azure_devops_pool_name" {
type = string
description = "The name of the Azure DevOps agent pool in which the containerized agents will be deployed (must exist)"
}

variable azure_devops_personal_access_token {
variable "azure_devops_personal_access_token" {
type = string
description = "The personal access token to use to connect to Azure DevOps (see https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/v2-windows?view=azure-devops#permissions)"
}

variable location {
variable "location" {
type = string
description = "The Azure location to use"
default = "westus"
}

variable agent_docker_image {
variable "agent_docker_image" {
type = string
description = "The Docker image to use for the Linux agent"
default = "jcorioland/aci-devops-agent"
}

variable agent_docker_tag {
variable "agent_docker_tag" {
type = string
description = "The Docker tag to use for the Linux agent"
default = "0.2-linux"
}

variable agents_count {
variable "agents_count" {
type = number
description = "The number of agents to create"
default = 2
}

variable random_suffix {
variable "random_suffix" {
type = number
description = "A random suffix for resources generated during the test"
}
6 changes: 3 additions & 3 deletions test/fixture/linux-agents/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module "aci-devops-agent" {
source = "../../../"
enable_vnet_integration = false
create_resource_group = true
source = "../../../"
enable_vnet_integration = false
create_resource_group = true
linux_agents_configuration = {
agent_name_prefix = "linuxagent-${var.random_suffix}"
count = var.agents_count
Expand Down
9 changes: 9 additions & 0 deletions test/fixture/linux-agents/provider.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 2.0"
}
}
}

provider "azurerm" {
features {}
}
Loading

0 comments on commit 56a3d8d

Please sign in to comment.