From 21061780752a160641d54ba051dc04ace4628cde Mon Sep 17 00:00:00 2001 From: ThomasCardin Date: Thu, 4 Jul 2024 10:40:23 -0400 Subject: [PATCH] terraform --- .github/workflows/main.yml | 50 ++++++++++++++++++++++++++++++++++++++ terraform/main.tf | 50 ++++++++++++++++++++------------------ terraform/variables.tf | 19 ++++++--------- 3 files changed, 83 insertions(+), 36 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e69de29..ebecc0c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -0,0 +1,50 @@ +name: 'Deployment terraform plan and apply' + +on: + push: + branches: + - main + - after-hours + +permissions: + contents: read + +jobs: + terraform: + name: Terraform fmt, init, plan and apply + runs-on: ubuntu-latest + environment: production + + defaults: + run: + shell: bash + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Terraform + uses: hashicorp/setup-terraform@v2 + with: + cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} + + - name: Terraform Format + id: fmt + run: terraform fmt + continue-on-error: false + + - name: Terraform Init + id: init + run: terraform init + + - name: Terraform Validate + id: validate + run: terraform validate -no-color + + - name: Terraform Plan + id: plan + run: terraform plan -no-color + continue-on-error: false + + - name: Terraform Apply + run: terraform apply -auto-approve -input=false \ No newline at end of file diff --git a/terraform/main.tf b/terraform/main.tf index 02b06a6..6919320 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -1,29 +1,31 @@ -resource "cloudflare_access_application" "trilim-notes" { - zone_id = var.cloudflare_access_zone_id - name = "Trilum notes" - domain = "trilium.ninebasetwo.net" - type = "self_hosted" - session_duration = "24h" - auto_redirect_to_identity = false +resource "cloudflare_record" "example" { + zone_id = var.cloudflare_zone_id + name = "argocd" + value = var.dns + type = "CNAME" + ttl = 3600 } +resource "cloudflare_record" "example" { + zone_id = var.cloudflare_zone_id + name = "trilium" + value = var.dns + type = "CNAME" + ttl = 3600 +} -resource "cloudflare_access_policy" "test_policy" { - application_id = "cb029e245cfdd66dc8d2e570d5dd3322" - zone_id = "0da42c8d2132a9ddaf714f9e7c920711" - name = "staging policy" - precedence = "1" - decision = "allow" - - include { - github { - identity_provider_id = "your_identity_provider_id" - name = "your_github_name" - teams = ["team1", "team2"] - } - } +resource "cloudflare_record" "example" { + zone_id = var.cloudflare_zone_id + name = "ollama" + value = var.dns + type = "CNAME" + ttl = 3600 +} - require { - ip = [var.office_ip] - } +resource "cloudflare_record" "example" { + zone_id = var.cloudflare_zone_id + name = "ceph" + value = var.dns + type = "CNAME" + ttl = 3600 } \ No newline at end of file diff --git a/terraform/variables.tf b/terraform/variables.tf index 26c6b8f..f4b83ca 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -1,24 +1,19 @@ variable "email" { - description = "The email address for Cloudflare" - type = string + description = "The email address for Cloudflare" + type = string } variable "cloudflare_api_key" { - description = "The API key for Cloudflare" - type = string -} - -variable "cloudflare_access_account_id" { - description = "value of the account_id field in the Cloudflare Access configuration" + description = "The API key for Cloudflare" type = string } -variable "cloudflare_access_zone_id" { - description = "value of the zone_id field in the Cloudflare Access configuration" +variable "cloudflare_zone_id" { + description = "The zone ID for Cloudflare" type = string } -variable "cloudflare_access_policy_name" { - description = "value of the name field in the Cloudflare Access configuration" +variable "dns" { + description = "value for DNS record" type = string } \ No newline at end of file