Skip to content

Commit

Permalink
fix: remove deprecated terraform resources (#387)
Browse files Browse the repository at this point in the history
* fix: remove deprecated terraform resources

* style: fix tf style
  • Loading branch information
Pactionly authored Jul 3, 2023
1 parent 034f0b2 commit d27c340
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 20 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/apply-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:

env:
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/gratibot
IMAGE_PATH: ${{ github.repository_owner }}/gratibot

permissions:
id-token: write
Expand Down Expand Up @@ -64,7 +65,7 @@ jobs:
ARM_TENANT_ID: "1b4a4fed-fed8-4823-a8a0-3d5cea83d122"
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_PROD_SUBSCRIPTION_ID }}
ARM_USE_OIDC: true
TF_VAR_gratibot_image: "${{ env.IMAGE_NAME }}:${{ needs.build.outputs.docker_tag }}"
TF_VAR_gratibot_image: "${{ env.IMAGE_PATH }}:${{ needs.build.outputs.docker_tag }}"
TF_VAR_gratibot_limit: ${{ inputs.gratibot_limit }}
apply:
name: "Terraform Prod Apply"
Expand All @@ -89,5 +90,5 @@ jobs:
ARM_TENANT_ID: "1b4a4fed-fed8-4823-a8a0-3d5cea83d122"
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_PROD_SUBSCRIPTION_ID }}
ARM_USE_OIDC: true
TF_VAR_gratibot_image: "${{ env.IMAGE_NAME }}:${{ needs.build.outputs.docker_tag }}"
TF_VAR_gratibot_image: "${{ env.IMAGE_PATH }}:${{ needs.build.outputs.docker_tag }}"
GRATIBOT_LIMIT: ${{ inputs.gratibot_limit }}
6 changes: 3 additions & 3 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- "README.md"
- "catalog.yaml"
env:
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/gratibot
IMAGE_PATH: ${{ github.repository_owner }}/gratibot

permissions:
id-token: write
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
terragrunt validate --terragrunt-no-auto-init
working-directory: infra/terragrunt/nonprod/gratibot/
env:
TF_VAR_gratibot_image: "${{ env.IMAGE_NAME }}:${{ needs.build.outputs.docker_tag }}"
TF_VAR_gratibot_image: "${{ env.IMAGE_PATH }}:${{ needs.build.outputs.docker_tag }}"
plan:
name: "Terraform Nonprod plan"
runs-on: ubuntu-latest
Expand All @@ -88,7 +88,7 @@ jobs:
ARM_TENANT_ID: "1b4a4fed-fed8-4823-a8a0-3d5cea83d122"
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_NONPROD_SUBSCRIPTION_ID }}
ARM_USE_OIDC: true
TF_VAR_gratibot_image: "${{ env.IMAGE_NAME }}:${{ needs.build.outputs.docker_tag }}"
TF_VAR_gratibot_image: "${{ env.IMAGE_PATH }}:${{ needs.build.outputs.docker_tag }}"

- uses: liatrio/[email protected]
with:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:

env:
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/gratibot
IMAGE_PATH: ${{ github.repository_owner }}/gratibot

permissions:
id-token: write
Expand Down Expand Up @@ -68,7 +69,7 @@ jobs:
ARM_TENANT_ID: "1b4a4fed-fed8-4823-a8a0-3d5cea83d122"
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_NONPROD_SUBSCRIPTION_ID }}
ARM_USE_OIDC: true
TF_VAR_gratibot_image: "${{ env.IMAGE_NAME }}:${{ needs.build.outputs.docker_tag }}"
TF_VAR_gratibot_image: "${{ env.IMAGE_PATH }}:${{ needs.build.outputs.docker_tag }}"
TF_VAR_gratibot_limit: ${{ inputs.gratibot_limit }}
release:
name: "Create Release"
Expand Down
31 changes: 20 additions & 11 deletions infra/terraform/appservice.tf
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
resource "azurerm_app_service_plan" "gratibot_app_service_plan" {
resource "azurerm_service_plan" "gratibot_app_service_plan" {
name = "gratibot-${var.environment}-service-plan"
location = var.location
os_type = "Linux"
resource_group_name = var.resource_group_name
kind = "Linux"
reserved = true

sku {
tier = var.instance_tier
size = var.instance_size
capacity = var.instance_capacity
}
sku_name = var.instance_size
worker_count = var.instance_capacity
}

resource "azurerm_app_service" "gratibot_app_service" {
resource "azurerm_linux_web_app" "gratibot_app_service" {
name = "gratibot-${var.environment}-service"
location = var.location
resource_group_name = var.resource_group_name
app_service_plan_id = azurerm_app_service_plan.gratibot_app_service_plan.id
service_plan_id = azurerm_service_plan.gratibot_app_service_plan.id
https_only = true
client_affinity_enabled = true

logs {
http_logs {
file_system {
retention_in_days = 1
retention_in_mb = 35
}
}
}

site_config {
always_on = "true"
linux_fx_version = "DOCKER|${var.gratibot_image}"
health_check_path = "/health"
use_32_bit_worker = false
application_stack {
docker_image_name = var.gratibot_image
docker_registry_url = var.gratibot_image_registry
}
}

identity {
Expand Down
6 changes: 6 additions & 0 deletions infra/terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ variable "gratibot_image" {
type = string
}

variable "gratibot_image_registry" {
description = "Image registry for Gratibot"
type = string
default = "https://ghcr.io"
}

variable "gratibot_recognize_emoji" {
description = "Recognition emoji to use for recognitions"
type = string
Expand Down
2 changes: 1 addition & 1 deletion infra/terraform/vault.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ data "azurerm_key_vault" "gratibot" {
resource "azurerm_role_assignment" "gratibot" {
scope = data.azurerm_key_vault.gratibot.id
role_definition_name = "Key Vault Secrets User"
principal_id = azurerm_app_service.gratibot_app_service.identity.0.principal_id
principal_id = azurerm_linux_web_app.gratibot_app_service.identity.0.principal_id
}

resource "azurerm_key_vault_secret" "mongo_connection_string" {
Expand Down
2 changes: 1 addition & 1 deletion infra/terragrunt/nonprod/gratibot/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ include {
}

terraform {
source = "../../../terraform"
source = "../../..//terraform"
}
2 changes: 1 addition & 1 deletion infra/terragrunt/prod/gratibot/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ include {
}

terraform {
source = "../../../terraform"
source = "../../..//terraform"
}

0 comments on commit d27c340

Please sign in to comment.