Skip to content

Terraform to OpenTofu #306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 6 additions & 6 deletions .azure-pipelines/azure-pipeline-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ variables:
- name: minor
value: '1'
- name: extensionName
value: 'Terraform'
value: 'OpenTofu'
- name: marketplaceServiceConnection
value: 'marketplaceServiceConnection'
value: 'Azure Marketplace cotality'
- name: publisherId
value: 'ms-devlabs'
value: 'cotality'
- name: publicExtensionName
value: "Terraform"
value: "OpenTofu"

name: $(major).$(minor)$(rev:.r)

Expand Down Expand Up @@ -43,10 +43,10 @@ stages:
steps:
- task: NodeTool@0
inputs:
versionSpec: '16.x'
versionSpec: '20.x'
- template: build.yml@pipeline-templates
- template: package.yml@pipeline-templates
parameters:
extensionName: $(extensionName)
outputPath: 'out'
rootPath: './build'
rootPath: './build'
70 changes: 35 additions & 35 deletions .azure-pipelines/azure-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ variables:
- name: minor
value: '1'
- name: extensionName
value: 'Terraform'
value: 'OpenTofu'
- name: marketplaceServiceConnection
value: 'marketplaceServiceConnection'
value: 'Azure Marketplace cotality'
- name: publisherId
value: 'ms-devlabs'
value: 'cotality'
- name: publicExtensionName
value: "Terraform"
value: "OpenTofu"
- name: extensionId
value: "custom-terraform-tasks"
value: "custom-opentofu-tasks"

name: $(major).$(minor)$(rev:.r)

Expand Down Expand Up @@ -40,42 +40,42 @@ stages:
steps:
- task: NodeTool@0
inputs:
versionSpec: '16.x'
versionSpec: '20.x'
- template: build.yml@pipeline-templates
- template: package.yml@pipeline-templates
parameters:
extensionName: $(extensionName)
outputPath: 'out'
rootPath: './build'

- stage: 'DeployDev'
displayName: 'Deploy to dev'
dependsOn: Build
condition: succeeded()
jobs:
- template: deploy.yml@pipeline-templates
parameters:
environment: 'dev'
extensionName: $(extensionName)
marketplaceConnectedServiceName: $(marketplaceServiceConnection)
publisherId: $(publisherId)
publicExtensionName: $(publicExtensionName)
updateTaskVersion: true
# - stage: 'DeployDev'
# displayName: 'Deploy to dev'
# dependsOn: Build
# condition: succeeded()
# jobs:
# - template: deploy.yml@pipeline-templates
# parameters:
# environment: 'dev'
# extensionName: $(extensionName)
# marketplaceConnectedServiceName: $(marketplaceServiceConnection)
# publisherId: $(publisherId)
# publicExtensionName: $(publicExtensionName)
# updateTaskVersion: true

- stage: 'DeployTest'
displayName: 'Deploy to Test'
dependsOn: DeployDev
condition: succeeded()
jobs:
- template: deploy.yml@pipeline-templates
parameters:
environment: 'test'
extensionName: $(extensionName)
marketplaceConnectedServiceName: $(marketplaceServiceConnection)
publisherId: $(publisherId)
publicExtensionName: $(publicExtensionName)
updateTaskVersion: true
extensionId: $(extensionId)
# - stage: 'DeployTest'
# displayName: 'Deploy to Test'
# dependsOn: DeployDev
# condition: succeeded()
# jobs:
# - template: deploy.yml@pipeline-templates
# parameters:
# environment: 'test'
# extensionName: $(extensionName)
# marketplaceConnectedServiceName: $(marketplaceServiceConnection)
# publisherId: $(publisherId)
# publicExtensionName: $(publicExtensionName)
# updateTaskVersion: true
# extensionId: $(extensionId)

- stage: 'DeployRelease'
displayName: 'Deploy Release'
Expand All @@ -89,6 +89,6 @@ stages:
marketplaceConnectedServiceName: $(marketplaceServiceConnection)
publisherId: $(publisherId)
publicExtensionName: $(publicExtensionName)
extensionVisibility: 'public'
extensionVisibility: 'private'
updateTaskVersion: true
extensionId: $(extensionId)
extensionId: $(extensionId)
17 changes: 3 additions & 14 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Unit Testing for TerraformTaskV4
name: Unit Testing for OpenTofuTaskV1
on:
pull_request:
branches:
Expand All @@ -10,25 +10,14 @@ on:
workflow_dispatch:

jobs:
unit-test-v4:
unit-test-v1:
name: Unit Test V4 Task
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run Unit Tests
run: |
cd Tasks/TerraformTask/TerraformTaskV4
npm install -include=dev
npm test
unit-test-v5:
name: Unit Test V5 Task
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run Unit Tests
run: |
cd Tasks/TerraformTask/TerraformTaskV5
cd Tasks/OpenTofuTask/OpenTofuTaskV1
npm install -include=dev
npm test
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}\\Tasks\\TerraformTask\\TerraformTaskV5\\Tests\\L0.ts",
"program": "${workspaceFolder}\\Tasks\\OpenTofuTask\\OpenTofuTaskV5\\Tests\\L0.ts",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
Expand All @@ -24,15 +24,15 @@
"program": "node_modules/mocha/bin/_mocha",
"stopOnEntry": false,
"args": [ "-r", "ts-node/register", "Tests/**/*.ts", "--no-timeouts"],
"cwd": "${workspaceRoot}/Tasks/TerraformTask/TerraformTaskV5"
"cwd": "${workspaceRoot}/Tasks/OpenTofuTask/OpenTofuTaskV5"
},
{
"name": "mocha tests npm",
"type": "node",
"request": "launch",
"runtimeExecutable": "npm",
"runtimeArgs": [ "run-script", "test" ],
"cwd": "${workspaceRoot}/Tasks/TerraformTask/TerraformTaskV5"
"cwd": "${workspaceRoot}/Tasks/OpenTofuTask/OpenTofuTaskV5"
}
]
}
40 changes: 16 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
# Terraform Extension for Azure DevOps
Azure DevOps OpenTofu Task

## Overview:
Overview

This repo contains the Azure DevOps Pipeline tasks for installing Terraform and running Terraform commands in a build or release pipeline. The goal of this extension is to guide the user in the process of using Terraform to deploy infrastructure within Azure, Amazon Web Services(AWS) and Google Cloud Platform(GCP).
This extension enables you to run OpenTofu commands as part of your Azure Pipelines build and release workflows. This extension is designed as a direct replacement for the Azure DevOps Terraform extension, offering the same functionality but with OpenTofu instead of Terraform.

This extension contains the following contributions:
- Terraform tool installer - for installing Terraform if not installed on the build agent
- Terraform - for executing the core Terraform commands
- Amazon Web Services(AWS) service connection - for creating a service connection for AWS to provide AWS credentials
- Google Cloud Platform(GCP) service connection - for creating a service connection for GCP to provide GCP credentials
OpenTofu is an open-source infrastructure as code tool that is a direct fork of Terraform. It allows you to define and provision infrastructure using a declarative configuration language.

The tasks are capable of running on the following build agent operating systems:
- Windows
- MacOS
- Linux
Changes from the Terraform Extension
This project is a fork of the Azure DevOps Terraform Tasks that has been modified to work with OpenTofu instead. Key changes include:

For more detailed information about the tasks, see the README for each from the below links:
Replacing all command executions from terraform to tofu
Renaming handler classes from TerraformCommand* to OpenTofuCommand*
Updating variable names accordingly (e.g., terraformCommandHandler → openTofuCommandHandler)
Modifying import paths to reference the new OpenTofu command handler files
Updating all tests to use the OpenTofu binary and classes
All functionality remains identical to the original extension, including:

- [Terraform tool installer](https://aka.ms/AAf1a0p)
- [Terraform](https://github.com/microsoft/azure-pipelines-terraform/tree/main/Tasks/TerraformTask/TerraformTaskV4)


## Contact Information

This extension is authored by [Microsoft DevLabs](https://marketplace.visualstudio.com/publishers/Microsoft%20DevLabs). It is not supported by Microsoft.

To report a problem with this extension, create an issue in this repository. The maintainers of this repository will review and respond to the issue.

You can also report problems or share feedback about this extension on [Developer Community Forum](https://developercommunity.visualstudio.com/spaces/21/index.html).
Support for AWS, Azure, and GCP providers
All Terraform commands (apply, destroy, init, validate, etc.)
Authentication with cloud providers
Command options and parameters
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"loc.friendlyName": "OpenTofu tool installer",
"loc.helpMarkDown": "[Learn more about this task](https://opentofu.org/docs/)",
"loc.description": "Find in cache or download a specific version of OpenTofu and prepend it to the PATH",
"loc.instanceNameFormat": "Install OpenTofu $(opentofuVersion)",
"loc.input.label.opentofuVersion": "Version",
"loc.input.help.opentofuVersion": "The version of OpenTofu which should be installed on the agent if not already present",
"loc.messages.VerifyOpenTofuInstallation": "Verifying OpenTofu installation...",
"loc.messages.InputVersionNotValidSemanticVersion": "Input version %s is not a valid semantic version",
"loc.messages.OpenTofuNotFoundInFolder": "OpenTofu executable not found in path %s",
"loc.messages.OperatingSystemNotSupported": "Operating system %s is not supported",
"loc.messages.ArchitectureNotSupported": "Architecture %s is not supported",
"loc.messages.OpenTofuDownloadFailed": "Failed to download OpenTofu from url %s. Error %s",
"loc.messages.OpenTofuVersionNotFound": "Unable to get latest version: using 1.9.0",
"loc.messages.GettingLatestOpenTofuVersion": "Getting latest OpenTofu version."
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading