Skip to content

Add Terraform with the BTP Provider Example #109

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

Merged
merged 10 commits into from
Jun 9, 2025
Merged
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
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 @@ -130,6 +130,7 @@ After importing, you'll see a new catalog tile - **Automation Pilot Examples**.
| [Use Custom Python Package](use-custom-python-package) | Install and use custom Python package in a script |
| [Use Custom NPM Package](use-custom-npm-package) | Install and use custom NPM package in a NodeJS script |
| [Use make and helm](use-make-and-helm) | Pull git repo and use make and helm to deploy the helm chart to kubernetes cluster |
| [Terraform with BTP Provider](terraform-with-btp-provider) | Use Terraform with the BTP Provider |

### Utility Commands

Expand Down
26 changes: 26 additions & 0 deletions terraform-with-btp-provider/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Terraform with BTP Provider

Table of Contents

* [Description](#description)
* [Requirements](#requirements)
* [How to use](#how-to-use)
* [Expected result](#expected-result)

## Description

This examples demonstrates how you can use SAP Automation Pilot sandbox environment with the Execute Script command to install and run terraform with a sample terraform configuration that install the BTP Provider for Terraform.

## Requirements

There are no requirements.

## How to use

* Import the catalog
* Execute the TerraformWithBTPProvider command
* See the output of the execution

## Expected result

The command outputs the terraform installation and the output from the `terraform init` command.
81 changes: 81 additions & 0 deletions terraform-with-btp-provider/catalog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"id": "examples-<<<TENANT_ID>>>",
"technicalName": "examples",
"name": "Automation Pilot Examples",
"description": "Source: https://github.com/SAP-samples/automation-pilot-examples",
"owner": "<<<TENANT_ID>>>",
"inputs": [],
"commands": [
{
"configuration": {
"values": [],
"output": {
"output": "$(.terraformInit.output.output | join(\"\\n\"))"
},
"executors": [
{
"execute": "scripts-sapcp:ExecuteScript:2",
"input": {
"environment": "{\"MAIN\":\"$(.execution.input.main | toEscapedJson)\"}",
"script": "# Set the Terraform version and URL\nTF_VERSION=\"1.9.1\"\nTF_URL=\"https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_amd64.zip\"\n\n# Download Terraform\necho \"Downloading Terraform ${TF_VERSION}\"\ncurl -sSL \"${TF_URL}\" -o /tmp/terraform.zip\n\n# Extract the Terraform binary\necho \"Extracting Terraform binary...\"\nunzip -o /tmp/terraform.zip -d /tmp\n\n# Moving terraform\nmv /tmp/terraform ./terraform\nchmod +x terraform\n\necho \"Terraform ${TF_VERSION} has been installed.\"\n\n# Create Terraform Config Files\necho \"${MAIN}\" > main.tf\n\n# Execute Terraform\n./terraform init"
},
"alias": "terraformInit",
"description": null,
"progressMessage": null,
"initialDelay": null,
"pause": null,
"when": null,
"validate": null,
"autoRetry": null,
"repeat": null,
"errorMessages": [],
"dryRun": null
}
],
"listeners": [
{
"status": "FAILED",
"execute": "utils-sapcp:Void:1",
"input": {
"message": "$(.execution.error)"
},
"when": null
}
]
},
"id": "examples-<<<TENANT_ID>>>:TerraformWithBTPProvider:1",
"name": "TerraformWithBTPProvider",
"description": null,
"catalog": "examples-<<<TENANT_ID>>>",
"version": 1,
"inputKeys": {
"main": {
"type": "string",
"sensitive": false,
"required": false,
"minSize": null,
"maxSize": null,
"minValue": null,
"maxValue": null,
"allowedValues": null,
"allowedValuesFromInputKeys": null,
"suggestedValues": null,
"suggestedValuesFromInputKeys": null,
"defaultValue": "terraform {\n required_providers {\n btp = {\n source = \"sap/btp\"\n }\n }\n}\n\nprovider \"btp\" {\n# You can leave this block empty for now, as we're not configuring any resources yet.\n# The provider will still be installed.\n}",
"defaultValueFromInput": null,
"description": null
}
},
"outputKeys": {
"output": {
"type": "string",
"sensitive": false,
"description": null
}
},
"tags": {
"feature:priority": "medium"
}
}
]
}