Skip to content

Commit

Permalink
Very basic terraform and terraform deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
harryy94 committed Jan 23, 2025
1 parent a9ca988 commit 008cc51
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
26 changes: 23 additions & 3 deletions .github/workflows/deploy-env.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
on:
push:
branches: [ "feat/azure_setup" ]
branches: [ "feat/terraform" ]


jobs:
Expand All @@ -22,9 +22,29 @@ jobs:
creds: ${{ secrets.AZURE_CREDENTIALS }}
enable-AzPSSession: true

- name: Azure CLI script
- name: Create TF State dependencies
uses: azure/cli@v2
with:
azcliversion: latest
inlineScript: |
az account show
az group create --name s186${{ var.ENVIRONMENT_PREFIX }}cl-tfstate --location westeurope
az storage account create --name s186${{ var.ENVIRONMENT_PREFIX }}cltfstate --resource-group s186${{ var.ENVIRONMENT_PREFIX }}cl-tfstate --location westeurope --sku Standard_LRS
az storage container create --name tfstate --account-name s186${{ var.ENVIRONMENT_PREFIX }}cltfstate
- name: 'Terraform Init'
id: terraform_init
working-directory: ./src/infrastructure/terraform
run: terraform init -backend-config="resource_group_name=s186${{ var.ENVIRONMENT_PREFIX }}cl-tfstate" -backend-config="storage_account_name=s186${{ var.ENVIRONMENT_PREFIX }}cltfstate" -backend-config="container_name=tfstate" -backend-config="key=terraform.tfstate"

- name: 'Terraform Plan'
id: terraform_plan
working-directory: ./src/infrastructure/terraform
run: terraform plan -out plan.plan

- name: 'Terraform Apply'
id: terraform_apply
working-directory: ./src/infrastructure/terraform
run: terraform apply plan.plan

3 changes: 2 additions & 1 deletion src/infrastructure/terraform/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ locals {
"Service" = "Newly onboarded"
"Service offering" = "Design operations"
}
service_prefix = "s186"
service_prefix = "s186${var.environment_prefix}-cl"
location = "westeurope"
}
5 changes: 5 additions & 0 deletions src/infrastructure/terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "azurerm_resource_group" "core-rg" {
name = "${local.service_prefix}-core-rg"
location = local.location
tags = local.common_tags
}
5 changes: 5 additions & 0 deletions src/infrastructure/terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ variable "cip_environment" {
default = "Dev"
}

variable "environment_prefix" {
description = "Environment prefix (e.g. d01)"
type = string
}

0 comments on commit 008cc51

Please sign in to comment.