Skip to content

Commit

Permalink
Merge pull request #1 from iquzart/development
Browse files Browse the repository at this point in the history
restructure
  • Loading branch information
iquzart authored Feb 1, 2021
2 parents 46ed14c + 20eea20 commit 66f5b16
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 87 deletions.
19 changes: 19 additions & 0 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 49 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
# Azure App Service

Terraform module to create Azure App Service

# Usage
## Usage
```
data "azurerm_resource_group" "rg" {
name = "RG_Apps"
}
module "appservice_plan" {
source = "github.com/iquzart/terraform-azurerm-appservice-plan"
resource_group_name = data.azurerm_resource_group.rg.name
location = data.azurerm_resource_group.rg.location
name = var.appservice_plan_name
kind = var.kind
tier = var.tier
size = var.size
tags = var.tags
}
module "appservice" {
source = "github.com/iquzart/terraform-azurerm-appservice"
Expand All @@ -20,61 +32,48 @@ module "appservice" {
container_image = var.container_image
container_image_tag = var.container_image_tag
container_image_registry = var.container_image_registry
}
```

# Variables
```
variable "resource_group_name" {
description = "App service resource group name"
type = string
default = ""
}
variable "location" {
description = "App service location"
type = string
default = ""
}
variable "app_name" {
description = "App service name"
type = string
default = ""
site_config = {
linux_fx_version = "docker|diquzart/go-app:latest"
always_on = true
http2_enabled = true
min_tls_version = 1.2
}
app_settings = {
"BANNER" = var.appbanner,
"PORT" = var.app_port
}
connection_string = [{
name = "database"
type = "MySQL"
value = "xxxxxxx.xxxxxxxx.xx"
}]
tags = var.tags
}
variable "app_service_plan_id" {
description = "App service plan id"
type = string
default = ""
}
variable "container_type" {
description = "Type of container. The options are: `docker`, `compose` or `kube`."
type = string
default = ""
}
variable "container_image" {
description = "Container image name. Example: diquzart/flaskapp"
type = string
default = ""
}
```

variable "container_image_tag" {
description = "Container image tag"
type = string
default = ""
}
## Input Variables
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| resource_group_name | The name of the resource group in which to create the App Service Plan component. | string | na | yes |
| location | Specifies the supported Azure location where the resource exists. | string | na | yes |
| app_name | (Required) Specifies the name of the App Service | string | na | yes |
| app_service_plan_id | (Required) Specifies the name of the App Service plan | string | na | yes |
| app_settings | (Optional) A key-value pair of App Settings | map(string) | na | no |
| site_config | (Optional) A site_config block. | any | {} | yes |
| connection_string | (Optional) One or more connection_string | list(map(string)) | [] | no |
| tags | (Optional) A mapping of default tags to assign to the resource | map(string) | na | no |

variable "container_image_registry" {
description = "Container image registry"
type = string
default = "https://index.docker.io"
}

```

# License
## License
MIT

## Author Information
Muhammed Iqbal <iquzart@hotmail.com>
45 changes: 35 additions & 10 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,21 +1,46 @@
# # Azure App service
# Azure App service

terraform {
required_version = "> 0.12.0"
}

resource "azurerm_app_service" "app" {
name = var.app_name
location = var.location
resource_group_name = var.resource_group_name
app_service_plan_id = var.app_service_plan_id

site_config {
linux_fx_version = "${var.container_type}|${var.container_image}:${var.container_image_tag}"
always_on = true
http2_enabled = true
}

dynamic "site_config" {
for_each = [var.site_config]

content {
always_on = lookup(site_config.value, "always_on", null)
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", null)
ftps_state = lookup(site_config.value, "ftps_state", null)
health_check_path = lookup(site_config.value, "health_check_path", null)
http2_enabled = lookup(site_config.value, "http2_enabled", null)
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)
linux_fx_version = lookup(site_config.value, "linux_fx_version", null)
min_tls_version = lookup(site_config.value, "min_tls_version", null)
php_version = lookup(site_config.value, "php_version", null)
python_version = lookup(site_config.value, "python_version", null)
windows_fx_version = lookup(site_config.value, "windows_fx_version", null)
}
}

app_settings = var.app_settings

app_settings = {
"DOCKER_REGISTRY_SERVER_URL" = var.container_image_registry
"PORT" = "8080"
dynamic "connection_string" {
for_each = var.connection_string
content {
name = lookup(connection_string.value, "name", null)
type = lookup(connection_string.value, "type", null)
value = lookup(connection_string.value, "value", null)
}
}

tags = var.tags
Expand Down
14 changes: 13 additions & 1 deletion output.tf
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
# Azure App service Plan
# Azure App service

output "app_service_name" {
description = "Name of the App Service"
value = azurerm_app_service.app.name
}

output "app_service_default_site_hostname" {
description = "The Default Hostname associated with the App Service"
value = azurerm_app_service.app.default_site_hostname
}


46 changes: 20 additions & 26 deletions variable.tf
Original file line number Diff line number Diff line change
@@ -1,54 +1,48 @@
# Azure App service Plan
# Azure App service

variable "resource_group_name" {
description = "App service resource group name"
description = "(Required) The name of the resource group in which to create the App Service"
type = string
default = ""
}

variable "location" {
description = "App service location"
description = "(Required) Specifies the supported Azure location where the resource exists"
type = string
default = ""
}

variable "app_name" {
description = "App service name"
description = "(Required) Specifies the name of the App Service"
type = string
default = ""
}

variable "app_service_plan_id" {
description = "App service plan id"
description = "(Required) Specifies the name of the App Service plan"
type = string
default = ""
}

variable "container_type" {
description = "Type of container. The options are: `docker`, `compose` or `kube`."
type = string
default = ""
}

variable "container_image" {
description = "Container image name. Example: diquzart/flaskapp"
type = string
default = ""
variable "tags" {
description = "(Optional) A mapping of default tags to assign to the resource"
type = map(string)
}

variable "container_image_tag" {
description = "Container image tag"
type = string
default = ""
variable "app_settings" {
description = "(Optional) A key-value pair of App Settings"
type = map(string)
default = {}
}

variable "container_image_registry" {
description = "Container image registry"
type = string
default = "https://index.docker.io"
variable "site_config" {
description = "(Optional) A site_config block."
type = any
default = {}
}

variable "tags" {
description = "A mapping of tags to assign to the resource"
type = map(string)
variable "connection_string" {
description = "(Optional) One or more connection_string"
type = list(map(string))
default = []
}

0 comments on commit 66f5b16

Please sign in to comment.