Azure Logic Apps - Terraform Infrastructure¶
This approach focuses on
setting up the required infrastructure via Terraform. It allows for source control of not only the solution code, connections, and setupsbut also the infrastructure itself. This repository specifically focuses on SAP integration with Azure Logic Apps, supporting both Stateful and Stateless workflow configurations.
The Terraform configuration supports both Stateful and Stateless Logic Apps, which have different characteristics: -
Stateful Logic Apps: - Retain complete run history - Support long-running workflows (up to 1 year) - Maintain state between requests (can handle session cookies) - Support built-in retry policies - Use when session persistence or workflow history is needed
-Stateless Logic Apps: - No run history stored (lower cost) - Faster execution - Limited to 5-minute maximum execution time - No state maintained between requests - Use for simple integrations without session requirements
Prerequisites¶
- An
Azure subscription is required. All other resources, including instructions for creating a Resource Group, are provided in this workshop. Contributor role assigned or any custom role that allows: access to manage all resources, and the ability to deploy resources within subscription.- Please ensure that:
- Terraform is installed on your local machine.
- Install the Azure CLI to work with both Terraform and Azure commands.
Overview¶
Templates structure:
.
├── README.md
├────── main.tf
├────── variables.tf
├────── provider.tf
├────── terraform.tfvars
├────── outputs.tf
- main.tf
(Main Terraform configuration file): This file contains the core infrastructure code. It defines the resources you want to create, such as virtual machines, networks, and storage. It's the primary file where you describe your infrastructure in a declarative manner. - variables.tf
(Variable definitions): This file is used to define variables that can be used throughout your Terraform configuration. By using variables, you can make your configuration more flexible and reusable. For example, you can define variables for resource names, sizes, and other parameters that might change between environments. - provider.tf
(Provider configurations): Providers are plugins that Terraform uses to interact with cloud providers, SaaS providers, and other APIs. This file specifies which providers (e.g., AWS, Azure, Google Cloud) you are using and any necessary configuration for them, such as authentication details. - terraform.tfvars
(Variable values): This file contains the actual values for the variables defined invariables.tf. By separating variable definitions and values, you can easily switch between different sets of values for different environments (e.g., development, staging, production) without changing the main configuration files. - outputs.tf
(Output values): This file defines the output values that Terraform should return after applying the configuration. Outputs are useful for displaying information about the resources created, such as IP addresses, resource IDs, and other important details. They can also be used as inputs for other Terraform configurations or scripts.
Finding principal_id Using Azure CLI¶
The
principal_idis typically the Object ID of a user, group, or service principal in Azure Entra ID (former AAD). You can find this ID in the Azure portal or by using the Azure CLI.
Get the Object ID of list of Users:
az ad user list --query "[].{Name:displayName, ObjectId:id, Email:userPrincipalName}" --output table
Here is an example value for admin_principal_id which is Object ID you retrieved.
admin_principal_id = "12345678-1234-1234-1234-1234567890ab"
How to execute it¶
Important Modify
terraform.tfvarswith your information, then run the following flow. For visual guidance, refer to the provisioning video.
1. Log in to Azure¶
This command logs you into your Azure account. It opens a browser window where you can enter your Azure credentials. Once logged in, you can manage your Azure resources from the command line.
cd terraform-infrastructure
az login
2. Initialize Terraform¶
Initialize the working directory containing the Terraform configuration files. This downloads the required provider plugins and sets up the state backend.
terraform init
3. Provision infrastructure¶
Review the plan¶
Create an execution plan that shows the changes Terraform will make using the values in terraform.tfvars.
terraform plan -var-file terraform.tfvars
A green completion message indicates that the command completed successfully.
Apply the configuration¶
Apply the changes required to reach the configured state. Terraform prompts for confirmation before making changes and uses the values in terraform.tfvars.
terraform apply -var-file terraform.tfvars
A green completion message indicates that the command completed successfully.
Remove the infrastructure¶
Destroy the infrastructure managed by Terraform when it is no longer needed. Terraform prompts for confirmation and uses the values in terraform.tfvars.
terraform destroy -var-file terraform.tfvars
A green completion message indicates that the command completed successfully.