diff --git a/README.md b/README.md index 98315c2..ef43c73 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/terraform-with-btp-provider/README.md b/terraform-with-btp-provider/README.md new file mode 100644 index 0000000..de58e45 --- /dev/null +++ b/terraform-with-btp-provider/README.md @@ -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. diff --git a/terraform-with-btp-provider/catalog.json b/terraform-with-btp-provider/catalog.json new file mode 100644 index 0000000..71dd21f --- /dev/null +++ b/terraform-with-btp-provider/catalog.json @@ -0,0 +1,81 @@ +{ + "id": "examples-<<>>", + "technicalName": "examples", + "name": "Automation Pilot Examples", + "description": "Source: https://github.com/SAP-samples/automation-pilot-examples", + "owner": "<<>>", + "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-<<>>:TerraformWithBTPProvider:1", + "name": "TerraformWithBTPProvider", + "description": null, + "catalog": "examples-<<>>", + "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" + } + } + ] +} \ No newline at end of file