-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e895cb9
Showing
6 changed files
with
270 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
terraform/terraform.tfstate.d/ | ||
terraform/.* | ||
terraform/terraform.tfstate | ||
terraform/terraform.tfstate.backup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# Definition of the digitalocean_app resource named "dev" | ||
resource "digitalocean_app" "dev" { | ||
|
||
# Configuration specific to the resource | ||
spec { | ||
# Application name, provided as an external variable | ||
name = var.spec_name | ||
|
||
# Region where the application will be deployed, provided as an external variable | ||
region = var.spec_region | ||
|
||
# Configuration of alerts for various events | ||
alert { | ||
disabled = false | ||
rule = "DEPLOYMENT_FAILED" | ||
} | ||
alert { | ||
disabled = false | ||
rule = "DEPLOYMENT_LIVE" | ||
} | ||
alert { | ||
disabled = false | ||
rule = "DOMAIN_FAILED" | ||
} | ||
alert { | ||
disabled = false | ||
rule = "DOMAIN_LIVE" | ||
} | ||
|
||
# Configuration of environment variables for the application | ||
env { | ||
key = var.env_key_globa_1 | ||
value = var.env_value_global_1 | ||
} | ||
|
||
# Configuration of ingress rules for the application | ||
ingress { | ||
rule { | ||
component { | ||
# Component name, provided as an external variable | ||
name = var.component_micro_1 | ||
|
||
# Configuration to preserve the path prefix | ||
preserve_path_prefix = false | ||
} | ||
match { | ||
path { | ||
# Path prefix for matching, provided as an external variable | ||
prefix = var.component_micro_1_prefix | ||
} | ||
} | ||
} | ||
} | ||
|
||
# Configuration of the application service | ||
service { | ||
# Path to the Dockerfile | ||
dockerfile_path = "Dockerfile" | ||
|
||
# HTTP port the service will listen on, provided as an external variable | ||
http_port = var.service_http_port_micro_1 | ||
|
||
# Number of instances for the service | ||
instance_count = var.service_instance_count_micro_1 | ||
|
||
# Instance size, provided as an external variable | ||
instance_size_slug = var.service_instance_size_slug_micro_1 | ||
|
||
# Internal ports of the Docker container (none in this case) | ||
internal_ports = [] | ||
|
||
# Service name, provided as an external variable | ||
name = var.service_name_micro_1 | ||
|
||
# Configuration of alerts for the service | ||
alert { | ||
disabled = false | ||
operator = "GREATER_THAN" | ||
rule = "CPU_UTILIZATION" | ||
value = 85 | ||
window = "FIVE_MINUTES" | ||
} | ||
alert { | ||
disabled = false | ||
operator = "GREATER_THAN" | ||
rule = "MEM_UTILIZATION" | ||
value = 85 | ||
window = "FIVE_MINUTES" | ||
} | ||
alert { | ||
disabled = false | ||
operator = "GREATER_THAN" | ||
rule = "RESTART_COUNT" | ||
value = 5 | ||
window = "FIVE_MINUTES" | ||
} | ||
|
||
# Configuration of environment variables for the service | ||
env { | ||
key = var.service_env_key_micro_1_1 | ||
value = var.service_env_value_micro_1_1 | ||
} | ||
|
||
# Configuration of GitHub integration | ||
github { | ||
branch = var.github_micro_1_branch | ||
deploy_on_push = var.github_deploy_on_push | ||
repo = var.github_micro_1_repo | ||
} | ||
|
||
# Configuration of health check for the service | ||
health_check { | ||
failure_threshold = 0 | ||
initial_delay_seconds = 0 | ||
period_seconds = 0 | ||
success_threshold = 0 | ||
timeout_seconds = 0 | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Output: Retrieve the ID of the created digitalocean_app resource | ||
output "app_id" { | ||
# Description of the output, explaining its purpose | ||
description = "ID of the created DigitalOcean App resource." | ||
|
||
# Value attribute specifies the value to be exposed as an output | ||
value = digitalocean_app.dev.id | ||
} | ||
|
||
# Output: Retrieve information about the default ingress rules | ||
output "default_ingress" { | ||
# Description of the output, explaining its purpose | ||
description = "Default ingress rules for the DigitalOcean App." | ||
|
||
# Value attribute specifies the value to be exposed as an output | ||
# Note: This assumes 'default_ingress' is a valid attribute within the digitalocean_app.dev structure. | ||
# However, since 'default_ingress' is not a standard attribute, you may need to adjust this based on your actual data structure. | ||
value = digitalocean_app.dev.default_ingress | ||
} | ||
|
||
# Output: Retrieve the live URL of the created digitalocean_app resource | ||
output "live_url" { | ||
# Description of the output, explaining its purpose | ||
description = "Live URL of the created DigitalOcean App resource." | ||
|
||
# Value attribute specifies the value to be exposed as an output | ||
value = digitalocean_app.dev.live_url | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Terraform Configuration for DigitalOcean Provider | ||
|
||
# Specify the required providers and versions | ||
terraform { | ||
required_providers { | ||
digitalocean = { | ||
source = "digitalocean/digitalocean" | ||
version = "~> 2.30" | ||
} | ||
} | ||
} | ||
|
||
# Configure the DigitalOcean provider | ||
provider "digitalocean" { | ||
# DigitalOcean API token for authentication, provided as a variable | ||
token = var.do_token | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Configuration for DigitalOcean App Deployment | ||
|
||
# Application Specification | ||
spec_name = "danieljsaldana" # Name of the application | ||
spec_region = "fra" # Region where the application will be deployed | ||
|
||
# Environment Variables for the Application | ||
env_key_globa_1 = "ENV" # Global environment variable key | ||
env_value_global_1 = "production" # Global environment variable value | ||
|
||
# Ingress Configuration for the Application | ||
component_micro_1 = "danieljsaldana" # Name of the application component | ||
component_micro_1_prefix= "/" # Path prefix for the application component | ||
|
||
# Service Configuration for the Application | ||
service_http_port_micro_1 = "3000" # HTTP port for the service | ||
service_instance_count_micro_1 = "1" # Number of instances for the service | ||
service_instance_size_slug_micro_1= "basic-xxs" # Size of the service instances | ||
service_name_micro_1 = "danieljsaldana" # Name of the service | ||
|
||
# Environment Variables for the Service | ||
service_env_key_micro_1_1 = "log" # Service environment variable key 1 | ||
service_env_value_micro_1_1= "error" # Service environment variable value 1 | ||
|
||
# GitHub Integration Configuration for the Service | ||
github_micro_1_branch = "production" # GitHub branch to deploy from | ||
github_deploy_on_push = "false" # Automatic deployment on push (true/false) | ||
github_micro_1_repo = "danieljsaldana/danieljsaldana-portfolio" # GitHub repository URL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Terraform Variables for DigitalOcean App Deployment | ||
|
||
# DigitalOcean API Token | ||
variable "do_token" { | ||
description = "DigitalOcean API token used for authentication." | ||
} | ||
|
||
# Application Specification | ||
variable "spec_name" { | ||
description = "Name of the application." | ||
} | ||
|
||
variable "spec_region" { | ||
description = "Region where the application will be deployed." | ||
} | ||
|
||
# Global Environment Variables for the Application | ||
variable "env_key_globa_1" { | ||
description = "Key for the global environment variable." | ||
} | ||
|
||
variable "env_value_global_1" { | ||
description = "Value for the global environment variable." | ||
} | ||
|
||
# Ingress Configuration for the Application | ||
variable "component_micro_1" { | ||
description = "Name of the application component for ingress configuration." | ||
} | ||
|
||
variable "component_micro_1_prefix" { | ||
description = "Path prefix for the application component in the ingress configuration." | ||
} | ||
|
||
# Service Configuration for the Application | ||
variable "service_http_port_micro_1" { | ||
description = "HTTP port on which the service will listen." | ||
} | ||
|
||
variable "service_instance_count_micro_1" { | ||
description = "Number of instances for the service." | ||
} | ||
|
||
variable "service_instance_size_slug_micro_1" { | ||
description = "Size of the instances for the service." | ||
} | ||
|
||
variable "service_name_micro_1" { | ||
description = "Name of the service in the application." | ||
} | ||
|
||
# Environment Variables for the Service | ||
variable "service_env_key_micro_1_1" { | ||
description = "Key for the first environment variable of the service." | ||
} | ||
|
||
variable "service_env_value_micro_1_1" { | ||
description = "Value for the first environment variable of the service." | ||
} | ||
|
||
# GitHub Integration Configuration for the Service | ||
variable "github_micro_1_branch" { | ||
description = "GitHub branch from which the service will be deployed." | ||
} | ||
|
||
variable "github_deploy_on_push" { | ||
description = "Flag indicating whether automatic deployment should occur on push to the GitHub repository." | ||
} | ||
|
||
variable "github_micro_1_repo" { | ||
description = "GitHub repository URL for the service." | ||
} |