Skip to content

Commit

Permalink
Merge pull request #2 from clouddrove/Hurodata-50
Browse files Browse the repository at this point in the history
[Hurodata-50] fix - initial commit
  • Loading branch information
d4kverma committed Apr 6, 2023
2 parents 221c445 + 728cf0a commit 8530c83
Show file tree
Hide file tree
Showing 10 changed files with 537 additions and 12 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: 'Create README.md file'
on:
push:
branches:
- master

jobs:
readme-create:
name: 'readme-create'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@master

- name: 'Set up Python 3.7'
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: 'create readme'
uses: 'clouddrove/github-actions@v9.0.2'
with:
actions_subcommand: 'readme'
github_token: '${{ secrets.GITHUB }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


- name: 'pre-commit check errors'
uses: pre-commit/action@v2.0.0
continue-on-error: true

- name: 'pre-commit fix erros'
uses: pre-commit/action@v2.0.0
continue-on-error: true

- name: 'push readme'
uses: 'clouddrove/github-actions@v9.0.2'
continue-on-error: true
with:
actions_subcommand: 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 'Slack Notification'
uses: clouddrove/action-slack@v2
with:
status: ${{ job.status }}
fields: repo,author
author_name: 'CloudDrove'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
if: always()
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# ignored files
*.tfstate
*.tfstate.backup
.terraform
.idea
*.iml
.terraform.tfstate.lock.info
.terraform.lock.hcl
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export GENIE_PATH ?= $(shell 'pwd')/../../../genie
include $(GENIE_PATH)/Makefile
70 changes: 70 additions & 0 deletions README.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
#
# This is the canonical configuration for the `README.md`
# Run `make readme` to rebuild the `README.md`
#


# Name of this project
name: Terraform AZURE APP SERVICE

# License of this project
license: "APACHE"

# Canonical GitHub repo
github_repo: clouddrove/terraform-azure-app-service

# Badges to display
badges:
- name: "Terraform"
image: "https://img.shields.io/badge/Terraform-v1.1.7-green"
url: "https://www.terraform.io"
- name: "Licence"
image: "https://img.shields.io/badge/License-APACHE-blue.svg"
url: "LICENSE.md"

# description of this project
description: |-
Terraform module to create app-service resource on AZURE.
# extra content
include:
- "terraform.md"

# How to use this project
# yamllint disable rule:line-length
usage: |-
### Simple Example
Here is an example of how you can use this module in your inventory structure:
#### Default App Service with NODE
```hcl
module "key_vault" {
source = "clouddrove/app-service/azure"
version = "1.0.0"
enabled = true
name = "app"
environment = "test"
label_order = ["name", "environment", ]
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location
service_plan = {
kind = "Windows"
size = "S1"
tier = "Free"
}
app_service_name = "test-app-service"
enable_client_affinity = true
enable_https = true
site_config = {
use_32_bit_worker_process = true
windows_fx_version = "node|18-lts"
}
app_settings = {
WEBSITE_NODE_DEFAULT_VERSION = "~16"
}
}
```
45 changes: 44 additions & 1 deletion _example/complete/main.tf
Original file line number Diff line number Diff line change
@@ -1 +1,44 @@
locals {}
provider "azurerm" {
features {}
}

# Resource Group
module "resource_group" {
source = "clouddrove/resource-group/azure"
version = "1.0.1"

label_order = ["name", "environment"]
name = "rg-rbac"
environment = "examplee"
location = "Canada Central"
}

# APP Service
module "app-service" {
source = "../../"
enabled = true
name = "app"
environment = "test"
label_order = ["name", "environment", ]
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location

service_plan = {
kind = "Windows"
size = "S1"
tier = "Free"
}

app_service_name = "test-app-service"
enable_client_affinity = true
enable_https = true

site_config = {
use_32_bit_worker_process = true
windows_fx_version = "node|18-lts"
}

app_settings = {
WEBSITE_NODE_DEFAULT_VERSION = "~16"
}
}
12 changes: 7 additions & 5 deletions _example/complete/versions.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
terraform {
required_version = ">= 1.0.0"
required_version = ">= 1.3.7"
}

terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.30"
azurerm = {
source = "hashicorp/azurerm"
version = ">=3.0.0"
}
}
}
}
145 changes: 144 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
@@ -1 +1,144 @@
locals {}

## Managed By : CloudDrove
## Copyright @ CloudDrove. All Right Reserved.


module "labels" {

source = "clouddrove/labels/azure"
version = "1.0.0"

name = var.name
environment = var.environment
managedby = var.managedby
label_order = var.label_order
repository = var.repository
}

locals {
# Default configuration for Site config block
default_site_config = {
always_on = "true"
}
}

data "azurerm_client_config" "main" {}

## APP SERVICE PLAN

resource "azurerm_app_service_plan" "main" {
name = format("app-service-plan-%s", lower(replace(module.labels.id, "/[[:^alnum:]]/", "")))
resource_group_name = var.resource_group_name
location = var.location
kind = var.service_plan.kind
reserved = var.service_plan.kind == "Linux" ? true : false
is_xenon = var.service_plan.kind == "xenon" ? true : false
per_site_scaling = var.service_plan.per_site_scaling
tags = module.labels.tags

sku {
tier = var.service_plan.tier
size = var.service_plan.size
capacity = var.service_plan.capacity
}
}

## APP SERVICE

resource "azurerm_app_service" "main" {
count = var.enabled ? 1 : 0
name = lower(format("%s-app-service", module.labels.id))
resource_group_name = var.resource_group_name
location = var.location
app_service_plan_id = azurerm_app_service_plan.main.id
client_affinity_enabled = var.enable_client_affinity
https_only = var.enable_https
client_cert_enabled = var.enable_client_certificate
tags = module.labels.tags
app_settings = var.app_settings

dynamic "site_config" {
for_each = [merge(local.default_site_config, var.site_config)]

content {
always_on = lookup(site_config.value, "always_on", false)
app_command_line = lookup(site_config.value, "app_command_line", null)
default_documents = lookup(site_config.value, "default_documents", null)
dotnet_framework_version = lookup(site_config.value, "dotnet_framework_version", "v2.0")
ftps_state = lookup(site_config.value, "ftps_state", "FtpsOnly")
health_check_path = lookup(site_config.value, "health_check_path", null)
number_of_workers = var.service_plan.per_site_scaling == true ? lookup(site_config.value, "number_of_workers") : null
http2_enabled = lookup(site_config.value, "http2_enabled", false)
java_container = lookup(site_config.value, "java_container", null)
java_container_version = lookup(site_config.value, "java_container_version", null)
java_version = lookup(site_config.value, "java_version", null)
local_mysql_enabled = lookup(site_config.value, "local_mysql_enabled", null)
linux_fx_version = lookup(site_config.value, "linux_fx_version", null)
windows_fx_version = lookup(site_config.value, "windows_fx_version", null)
managed_pipeline_mode = lookup(site_config.value, "managed_pipeline_mode", "Integrated")
min_tls_version = lookup(site_config.value, "min_tls_version", "1.2")
php_version = lookup(site_config.value, "php_version", null)
python_version = lookup(site_config.value, "python_version", null)
remote_debugging_enabled = lookup(site_config.value, "remote_debugging_enabled", null)
remote_debugging_version = lookup(site_config.value, "remote_debugging_version", null)
scm_type = lookup(site_config.value, "scm_type", null)
use_32_bit_worker_process = lookup(site_config.value, "use_32_bit_worker_process", true)
websockets_enabled = lookup(site_config.value, "websockets_enabled", null)
}
}

auth_settings {
enabled = var.enable_auth_settings
default_provider = var.default_auth_provider
allowed_external_redirect_urls = []
issuer = format("https://sts.windows.net/%s/", data.azurerm_client_config.main.tenant_id)
unauthenticated_client_action = var.unauthenticated_client_action
token_store_enabled = var.token_store_enabled

dynamic "active_directory" {
for_each = var.active_directory_auth_setttings
content {
client_id = lookup(active_directory_auth_setttings.value, "client_id", null)
client_secret = lookup(active_directory_auth_setttings.value, "client_secret", null)
allowed_audiences = concat(formatlist("https://%s", [format("%s.azurewebsites.net", var.app_service_name)]), [])
}
}
}

dynamic "connection_string" {
for_each = var.connection_strings
content {
name = lookup(connection_string.value, "name", null)
type = lookup(connection_string.value, "type", null)
value = lookup(connection_string.value, "value", null)
}
}

identity {
type = var.identity_ids != null ? "SystemAssigned, UserAssigned" : "SystemAssigned"
identity_ids = var.identity_ids
}

dynamic "storage_account" {
for_each = var.storage_mounts
content {
name = lookup(storage_account.value, "name")
type = lookup(storage_account.value, "type", "AzureFiles")
account_name = lookup(storage_account.value, "account_name", null)
share_name = lookup(storage_account.value, "share_name", null)
access_key = lookup(storage_account.value, "access_key", null)
mount_path = lookup(storage_account.value, "mount_path", null)
}
}

lifecycle {
ignore_changes = [
tags,
site_config,
auth_settings,
storage_account,
identity,
connection_string,
]
}
}
Loading

0 comments on commit 8530c83

Please sign in to comment.