Skip to content

Commit

Permalink
feat: add azure integration for FLINT.Cloud (#133)
Browse files Browse the repository at this point in the history
* chore: add terraform auto-generated files to .gitignore

* feat: add terraform scripts for deploying rest_api_flint.example

* feat: add terraform scripts for deploying rest_api_gcbm

* chore: format terraform files
  • Loading branch information
HarshCasper authored Jun 22, 2022
1 parent e6a7632 commit d461ec6
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,37 @@ cython_debug/

# Input files
local/rest_api_gcbm/input/

# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*
.terraform.lock.hcl

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Ignore CLI configuration files
.terraformrc
terraform.rc

# Add GCBM Demo runs
GCBM_Demo_Run/
GCBM_New_Demo_Run/
31 changes: 31 additions & 0 deletions provider/azure/rest_api_flint.example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# REST API FLINT.Example Terraform integration for Azure

This Terraform script provisions a Linux App Service which runs the `ghcr.io/moja-global/rest_api_flint.example` Docker container.

## Variables

- `prefix` - (Required) The prefix used for all resources in this example.
- `location` - (Required) Azure Region in which all resources in this example should be provisioned.

## Outputs

- `app_name` - The name of the app.
- `app_url` - The default URL to access the app.

## Usage

- Initialize the directory:
```sh
terraform init
```

- Deploy the infrastructure:
```sh
terraform apply
```

If the plan is acceptable, type "yes" at the confirmation prompt to proceed. Executing the plan will take a few minutes. Once deployed, the Container is launched on the first HTTP Request, which can take a while.

## Notes

Continuous Deployment of a single Docker Container can be achieved using the App Setting `DOCKER_ENABLE_CI` to `true`.
36 changes: 36 additions & 0 deletions provider/azure/rest_api_flint.example/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
provider "azurerm" {
features {}
}

resource "azurerm_resource_group" "example" {
name = "${var.prefix}-resources"
location = var.location
}

resource "azurerm_service_plan" "example" {
name = "${var.prefix}-sp-zipdeploy"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
os_type = "Linux"
sku_name = "S1"
}


resource "azurerm_linux_web_app" "example" {
name = "${var.prefix}-example"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
service_plan_id = azurerm_service_plan.example.id

app_settings = {
"WEBSITES_ENABLE_APP_SERVICE_STORAGE" = "false"
"WEBSITES_PORT" = 8080
}

site_config {
application_stack {
docker_image = "ghcr.io/moja-global/rest_api_flint.example"
docker_image_tag = "master"
}
}
}
7 changes: 7 additions & 0 deletions provider/azure/rest_api_flint.example/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
output "linux_web_app_name" {
value = azurerm_linux_web_app.example.name
}

output "app_url" {
value = "https://${azurerm_linux_web_app.example.default_hostname}"
}
9 changes: 9 additions & 0 deletions provider/azure/rest_api_flint.example/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
variable "prefix" {
type = string
description = "The prefix used for all resources in this example"
}

variable "location" {
type = string
description = "The Azure location where all resources in this example should be created"
}
31 changes: 31 additions & 0 deletions provider/azure/rest_api_gcbm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# REST API GCBM Terraform integration for Azure

This Terraform script provisions a Linux App Service which runs the `ghcr.io/moja-global/rest_api_gcbm` Docker container.

## Variables

- `prefix` - (Required) The prefix used for all resources in this example.
- `location` - (Required) Azure Region in which all resources in this example should be provisioned.

## Outputs

- `app_name` - The name of the app.
- `app_url` - The default URL to access the app.

## Usage

- Initialize the directory:
```sh
terraform init
```

- Deploy the infrastructure:
```sh
terraform apply
```

If the plan is acceptable, type "yes" at the confirmation prompt to proceed. Executing the plan will take a few minutes. Once deployed, the Container is launched on the first HTTP Request, which can take a while.

## Notes

Continuous Deployment of a single Docker Container can be achieved using the App Setting `DOCKER_ENABLE_CI` to `true`.
36 changes: 36 additions & 0 deletions provider/azure/rest_api_gcbm/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
provider "azurerm" {
features {}
}

resource "azurerm_resource_group" "example" {
name = "${var.prefix}-resources"
location = var.location
}

resource "azurerm_service_plan" "example" {
name = "${var.prefix}-sp-zipdeploy"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
os_type = "Linux"
sku_name = "S1"
}


resource "azurerm_linux_web_app" "example" {
name = "${var.prefix}-example"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
service_plan_id = azurerm_service_plan.example.id

app_settings = {
"WEBSITES_ENABLE_APP_SERVICE_STORAGE" = "false"
"WEBSITES_PORT" = 8080
}

site_config {
application_stack {
docker_image = "ghcr.io/moja-global/rest_api_gcbm"
docker_image_tag = "master"
}
}
}
7 changes: 7 additions & 0 deletions provider/azure/rest_api_gcbm/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
output "linux_web_app_name" {
value = azurerm_linux_web_app.example.name
}

output "app_url" {
value = "https://${azurerm_linux_web_app.example.default_hostname}"
}
9 changes: 9 additions & 0 deletions provider/azure/rest_api_gcbm/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
variable "prefix" {
type = string
description = "The prefix used for all resources in this example"
}

variable "location" {
type = string
description = "The Azure location where all resources in this example should be created"
}

0 comments on commit d461ec6

Please sign in to comment.