Skip to content

Commit

Permalink
feat: Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fdmsantos committed Apr 30, 2024
1 parent 685db94 commit 1ad9b58
Show file tree
Hide file tree
Showing 20 changed files with 666 additions and 1 deletion.
83 changes: 83 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Pre-Commit

on:
pull_request:
branches:
- main
- master

env:
TERRAFORM_DOCS_VERSION: v0.16.0
TFLINT_VERSION: v0.44.1

jobs:
collectInputs:
name: Collect workflow inputs
runs-on: ubuntu-latest
outputs:
directories: ${{ steps.dirs.outputs.directories }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get root directories
id: dirs
uses: clowdhaus/terraform-composite-actions/directories@v1.8.3

preCommitMinVersions:
name: Min TF pre-commit
needs: collectInputs
runs-on: ubuntu-latest
strategy:
matrix:
directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Terraform min/max versions
id: minMax
uses: clowdhaus/terraform-min-max@v1.2.4
with:
directory: ${{ matrix.directory }}

- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}
# Run only validate pre-commit check on min version supported
if: ${{ matrix.directory != '.' }}
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.3
with:
terraform-version: ${{ steps.minMax.outputs.minVersion }}
tflint-version: ${{ env.TFLINT_VERSION }}
args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'

- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}
# Run only validate pre-commit check on min version supported
if: ${{ matrix.directory == '.' }}
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.3
with:
terraform-version: ${{ steps.minMax.outputs.minVersion }}
tflint-version: ${{ env.TFLINT_VERSION }}
args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'

preCommitMaxVersion:
name: Max TF pre-commit
runs-on: ubuntu-latest
needs: collectInputs
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{github.event.pull_request.head.repo.full_name}}

- name: Terraform min/max versions
id: minMax
uses: clowdhaus/terraform-min-max@v1.2.4

- name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.3
with:
terraform-version: ${{ steps.minMax.outputs.maxVersion }}
tflint-version: ${{ env.TFLINT_VERSION }}
terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}
install-hcledit: true
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release

on:
workflow_dispatch:
push:
branches:
- main
paths:
- '**/*.tf'
- '.github/workflows/release.yml'

jobs:
release:
name: Release
runs-on: ubuntu-latest
# Skip running release workflow on forks
if: github.repository_owner == 'fdmsantos'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0

- name: Release
uses: cycjimmy/semantic-release-action@v3
with:
semantic_version: 18.0.0
extra_plugins: |
@semantic-release/changelog@6.0.0
@semantic-release/git@10.0.0
conventional-changelog-conventionalcommits@4.6.3
env:
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ override.tf.json
# Ignore CLI configuration files
.terraformrc
terraform.rc

# Ignore Lock
.terraform.lock.hcl

# Ignore IDE Folders
.idea
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.71.0
hooks:
- id: terraform_fmt
- id: terraform_validate
- id: terraform_docs
args:
- '--args=--lockfile=false'
- id: terraform_tflint
args:
- '--args=--only=terraform_deprecated_interpolation'
- '--args=--only=terraform_deprecated_index'
- '--args=--only=terraform_unused_declarations'
- '--args=--only=terraform_comment_syntax'
- '--args=--only=terraform_documented_outputs'
- '--args=--only=terraform_documented_variables'
- '--args=--only=terraform_typed_variables'
- '--args=--only=terraform_module_pinned_source'
- '--args=--only=terraform_naming_convention'
- '--args=--only=terraform_required_version'
- '--args=--only=terraform_required_providers'
- '--args=--only=terraform_standard_module_structure'
- '--args=--only=terraform_workspace_remote'
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
44 changes: 44 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"branches": [
"main"
],
"ci": false,
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/github",
{
"successComment": "This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:",
"labels": false,
"releasedLabels": false
}
],
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md",
"changelogTitle": "# Changelog\n\nAll notable changes to this project will be documented in this file."
}
],
[
"@semantic-release/git",
{
"assets": [
"CHANGELOG.md"
],
"message": "chore(release): version ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
]
}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Changelog

All notable changes to this project will be documented in this file.
131 changes: 130 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,131 @@
# terraform-azurerm-logicapp
# Azure Logic App Terraform Module

[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)

Dynamic Terraform module, which creates a Logic App and others resources.

## Table of Contents

* [Module versioning rule](README.md#module-versioning-rule)
* [How to Use](README.md#how-to-use)
* [Basic](README.md#basic)
* [Examples](README.md#examples)
* [Requirements](README.md#requirements)
* [Providers](README.md#providers)
* [Modules](README.md#modules)
* [Resources](README.md#resources)
* [Inputs](README.md#inputs)
* [Outputs](README.md#outputs)
* [License](README.md#license)

## Module versioning rule

| Module version | Azure Provider version |
|----------------|------------------------|
| >= 1.x.x | => 3.22 |

## How to Use

### Basic

```hcl
module "logic_app" {
source = "fdmsantos/logicapp/azurerm"
version = "x.x.x"
name = "logicapp-name"
location = "westeurope"
resource_group_name = "<resource-group"
identity_type = "SystemAssigned"
connections_parameters = [
module.azureblob_api_connection.logic_app_parameter,
module.sharepoint_api_connection.logic_app_parameter
]
workflow_parameters = {
storage_account_name : {
type : "String",
defaultValue : "storageaccountname"
}
}
http_triggers = {
"HTTP_Trigger" = {
method = "POST",
schema = file("${path.module}/templates/triggers/http_trigger.json")
}
}
custom_actions = {
"Initialize_variable" : file("${path.module}/templates/actions/initialize_variable.json")
"Response" : file("${path.module}/templates/actions/response.json")
}
tags = {
env: "dev"
}
}
```

## Examples

- [complete](https://github.com/fdmsantos/terraform-azurerm-logicapp/tree/main/examples/complete) - Creates Logic App with all supported features.

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | >= 3.22 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | >= 3.22 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [azurerm_logic_app_action_custom.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/logic_app_action_custom) | resource |
| [azurerm_logic_app_trigger_http_request.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/logic_app_trigger_http_request) | resource |
| [azurerm_logic_app_workflow.workflow](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/logic_app_workflow) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_connections_parameters"></a> [connections\_parameters](#input\_connections\_parameters) | Parameters related with API Connections. | `list(map(any))` | `[]` | no |
| <a name="input_custom_actions"></a> [custom\_actions](#input\_custom\_actions) | Map of Logic App Custom Actions. | `map(string)` | `null` | no |
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Is the Logic App enabled? Defaults to true | `bool` | `true` | no |
| <a name="input_http_triggers"></a> [http\_triggers](#input\_http\_triggers) | Map of Logic App HTTP Triggers. | <pre>map(object({<br> schema = string<br> method = optional(string, null)<br> relative_path = optional(string, null)<br> }))</pre> | `null` | no |
| <a name="input_identity_ids"></a> [identity\_ids](#input\_identity\_ids) | Specifies a list of User Assigned Managed Identity IDs to be assigned to this Logic App. | `list(string)` | `[]` | no |
| <a name="input_identity_type"></a> [identity\_type](#input\_identity\_type) | Specifies the type of Managed Service Identity that should be associated with this Logic App. | `string` | `null` | no |
| <a name="input_integration_service_environment_id"></a> [integration\_service\_environment\_id](#input\_integration\_service\_environment\_id) | The ID of the Integration Service Environment to which this Logic App Workflow belongs. Changing this forces a new Logic App Workflow to be created. | `string` | `null` | no |
| <a name="input_location"></a> [location](#input\_location) | Specifies the Azure Region where the logic app should exists. Changing this forces a new resource to be created. | `string` | n/a | yes |
| <a name="input_logic_app_integration_account_id"></a> [logic\_app\_integration\_account\_id](#input\_logic\_app\_integration\_account\_id) | The ID of the integration account linked by this Logic App Workflow. | `string` | `null` | no |
| <a name="input_name"></a> [name](#input\_name) | Specifies the name of the Logic App. Changing this forces a new resource to be created. | `string` | n/a | yes |
| <a name="input_parameters"></a> [parameters](#input\_parameters) | A map of Key-Value pairs. Any parameters specified must exist in the Schema defined in workflow\_parameters. | `map(any)` | `{}` | no |
| <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name) | Specifies the name of the Resource Group where the logic should exists. Changing this forces a new resource to be created. | `string` | n/a | yes |
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to assign to resources. | `map(string)` | `{}` | no |
| <a name="input_workflow_parameters"></a> [workflow\_parameters](#input\_workflow\_parameters) | Specifies a map of Key-Value pairs of the Parameter Definitions to use for this Logic App Workflow. The key is the parameter name, and the value is a JSON encoded string of the parameter definition (see: https://docs.microsoft.com/azure/logic-apps/logic-apps-workflow-definition-language#parameters). | <pre>map(object({<br> type = string<br> defaultValue = any<br> allowedValues = optional(list(string), null)<br> metadata = optional(object({<br> description = string<br> }))<br> }))</pre> | `{}` | no |
| <a name="input_workflow_schema"></a> [workflow\_schema](#input\_workflow\_schema) | Specifies the Schema to use for this Logic App Workflow. Defaults to https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json# | `string` | `"https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#"` | no |
| <a name="input_workflow_version"></a> [workflow\_version](#input\_workflow\_version) | Specifies the version of the Schema used for this Logic App Workflow. Defaults to 1.0.0.0. Changing this forces a new resource to be created. | `string` | `"1.0.0.0"` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_access_endpoint"></a> [access\_endpoint](#output\_access\_endpoint) | The Access Endpoint for the Logic App Workflow. |
| <a name="output_connector_endpoint_ip_addresses"></a> [connector\_endpoint\_ip\_addresses](#output\_connector\_endpoint\_ip\_addresses) | The list of access endpoint IP addresses of connector for the Logic App Workflow. |
| <a name="output_connector_outbound_ip_addresses"></a> [connector\_outbound\_ip\_addresses](#output\_connector\_outbound\_ip\_addresses) | The list of outgoing IP addresses of connector for the Logic App Workflow. |
| <a name="output_id"></a> [id](#output\_id) | The Logic App ID. |
| <a name="output_identity"></a> [identity](#output\_identity) | Logic App Identity |
| <a name="output_workflow_endpoint_ip_addresses"></a> [workflow\_endpoint\_ip\_addresses](#output\_workflow\_endpoint\_ip\_addresses) | The list of access endpoint IP addresses of workflow for the Logic App Workflow. |
| <a name="output_workflow_outbound_ip_addresses"></a> [workflow\_outbound\_ip\_addresses](#output\_workflow\_outbound\_ip\_addresses) | The list of outgoing IP addresses of workflow for the Logic App Workflow. |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

## License

Apache 2 Licensed. See [LICENSE](https://github.com/fdmsantos/terraform-azurerm-logicapp/tree/main/LICENSE) for full details.
57 changes: 57 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
resource "azurerm_resource_group" "this" {
name = "RG-${title(var.name)}"
location = var.location
}

module "logic_app" {
source = "../../"
name = var.name
location = var.location
resource_group_name = azurerm_resource_group.this.name
identity_type = "SystemAssigned"
connections_parameters = [
module.azureblob_api_connection.logic_app_parameter,
module.sharepoint_api_connection.logic_app_parameter
]
workflow_parameters = {
storage_account_name : {
type : "String",
defaultValue : "storageaccountname"
}
}
http_triggers = {
"HTTP_Trigger" = {
method = "POST",
schema = file("${path.module}/templates/triggers/http_trigger.json")
}
}
custom_actions = {
"Initialize_variable" : file("${path.module}/templates/actions/initialize_variable.json")
"Response" : file("${path.module}/templates/actions/response.json")
}
tags = {
env : "dev"
}
}

################# Api Connections #################
module "azureblob_api_connection" {
source = "fdmsantos/api-connections/azurerm"
version = "1.0.0"
api_type = "azureblob"
connection_name = "${var.name}-azureblob"
deployment_name = "${var.name}-azureblob-deployment"
resource_group_name = azurerm_resource_group.this.name
connection_display_name = "${var.name}-azureblob"
azureblob_authentication_type = "Logic Apps Managed Identity"
}

module "sharepoint_api_connection" {
source = "fdmsantos/api-connections/azurerm"
version = "1.0.0"
api_type = "sharepointonline"
connection_name = "${var.name}-sharepointonline"
deployment_name = "${var.name}-sharepointonline-deployment"
resource_group_name = azurerm_resource_group.this.name
connection_display_name = "${var.name}-sharepointonline"
}
Loading

0 comments on commit 1ad9b58

Please sign in to comment.