Skip to content

Commit

Permalink
Merge 2ceecd0 into d5a679b
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbyoung authored Nov 29, 2023
2 parents d5a679b + 2ceecd0 commit d888634
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ jobs:
# Apply configs
kubectl apply -k ./infrastructure/kubernetes/environments/prod
- name: Terraform DigitalOcean Networking
- name: Terraform DigitalOcean Networking and Monitoring
run: |
terraform -chdir=./infrastructure/terraform plan -target="module.networking" -var="do_access_token=${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}" -var="do_spaces_access_key=${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}" -var="do_spaces_secret_key=${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}" -no-color -input=false
terraform -chdir=./infrastructure/terraform apply -target="module.networking" -var="do_access_token=${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}" -var="do_spaces_access_key=${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}" -var="do_spaces_secret_key=${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}" -no-color -input=false -auto-approve
terraform -chdir=./infrastructure/terraform plan -target="module.networking" -target="module.monitoring" -var="do_access_token=${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}" -var="do_spaces_access_key=${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}" -var="do_spaces_secret_key=${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}" -no-color -input=false
terraform -chdir=./infrastructure/terraform apply -target="module.networking" -target="module.monitoring" -var="do_access_token=${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}" -var="do_spaces_access_key=${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}" -var="do_spaces_secret_key=${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}" -no-color -input=false -auto-approve
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,26 @@ jobs:
run: |
composer global require php-coveralls/php-coveralls
php-coveralls --coverage_clover=./.coverage/clover.xml --json_path=./coveralls-upload.json -v
- name: Set Up Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.6.4
- name: Terraform Plan
id: terraform-plan
run: |
terraform -chdir=./infrastructure/terraform init -backend-config="access_key=${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}" -backend-config="secret_key=${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}"
terraform -chdir=./infrastructure/terraform validate
terraform -chdir=./infrastructure/terraform plan -var="do_access_token=${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}" -var="do_spaces_access_key=${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}" -var="do_spaces_secret_key=${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}" -no-color -input=false
continue-on-error: true # We want the output even if this fails
- name: Comment Terraform Plan
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `## Terraform Plan \`${{ steps.terraform-plan.outputs.stdout }}\``;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
5 changes: 5 additions & 0 deletions infrastructure/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ module "kubernetes" {
do_access_token = var.do_access_token
}

module "monitoring" {
source = "./modules/monitoring"
do_access_token = var.do_access_token
}

module "networking" {
source = "./modules/networking"
do_access_token = var.do_access_token
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/terraform/modules/kubernetes/variables.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
variable "do_access_token" {
description = "DigitalOcean API Token"
description = "DigitalOcean API access token"
type = string
}
22 changes: 22 additions & 0 deletions infrastructure/terraform/modules/monitoring/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = "~> 2.0"
}
}
}

resource "digitalocean_uptime_check" "api" {
name = "API Health Check"
type = "https"
target = "https://api.aphiria.com/health"
regions = ["us_east", "us_west"]
}

resource "digitalocean_uptime_check" "web" {
name = "Web Health Check"
type = "https"
target = "https://www.aphiria.com"
regions = ["us_east", "us_west"]
}
4 changes: 4 additions & 0 deletions infrastructure/terraform/modules/monitoring/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
variable "do_access_token" {
description = "DigitalOcean API access token"
type = string
}
2 changes: 1 addition & 1 deletion infrastructure/terraform/modules/networking/variables.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
variable "do_access_token" {
description = "DigitalOcean API Token"
description = "DigitalOcean API access token"
type = string
}
2 changes: 1 addition & 1 deletion infrastructure/terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
variable "do_access_token" {
description = "DigitalOcean API Token"
description = "DigitalOcean API access token"
type = string
}

Expand Down

0 comments on commit d888634

Please sign in to comment.