92 lines
2.2 KiB
HCL
92 lines
2.2 KiB
HCL
terraform {
|
|
required_providers {
|
|
edge-connect = {
|
|
source = "local/edge-connect"
|
|
}
|
|
}
|
|
}
|
|
|
|
provider "edge-connect" {
|
|
endpoint = var.edge_connect_endpoint
|
|
token = var.edge_connect_token
|
|
}
|
|
|
|
# Create an application
|
|
resource "edge-connect_app" "web_app" {
|
|
name = "web-application"
|
|
version = "2.1.0"
|
|
description = "Production web application"
|
|
}
|
|
|
|
# Create an app instance for the application
|
|
resource "edge-connect_app_instance" "web_app_instance" {
|
|
name = "web-app-prod-instance"
|
|
app_id = edge-connect_app.web_app.id
|
|
description = "Production instance of web application"
|
|
config = jsonencode({
|
|
environment = "production"
|
|
replicas = 3
|
|
resources = {
|
|
cpu = "2"
|
|
memory = "4Gi"
|
|
}
|
|
})
|
|
}
|
|
|
|
# Create another app with a different version
|
|
resource "edge-connect_app" "api_app" {
|
|
name = "api-service"
|
|
version = "1.5.0"
|
|
}
|
|
|
|
# Create multiple instances of the API app
|
|
resource "edge-connect_app_instance" "api_instance_east" {
|
|
name = "api-service-east"
|
|
app_id = edge-connect_app.api_app.id
|
|
config = jsonencode({
|
|
region = "us-east-1"
|
|
})
|
|
}
|
|
|
|
resource "edge-connect_app_instance" "api_instance_west" {
|
|
name = "api-service-west"
|
|
app_id = edge-connect_app.api_app.id
|
|
config = jsonencode({
|
|
region = "us-west-2"
|
|
})
|
|
}
|
|
|
|
# Outputs
|
|
output "web_app_id" {
|
|
description = "ID of the web application"
|
|
value = edge-connect_app.web_app.id
|
|
}
|
|
|
|
output "web_app_status" {
|
|
description = "Status of the web application"
|
|
value = edge-connect_app.web_app.status
|
|
}
|
|
|
|
output "web_app_instance_id" {
|
|
description = "ID of the web app instance"
|
|
value = edge-connect_app_instance.web_app_instance.id
|
|
}
|
|
|
|
output "web_app_instance_status" {
|
|
description = "Status of the web app instance"
|
|
value = edge-connect_app_instance.web_app_instance.status
|
|
}
|
|
|
|
output "api_instances" {
|
|
description = "API service instances"
|
|
value = {
|
|
east = {
|
|
id = edge-connect_app_instance.api_instance_east.id
|
|
status = edge-connect_app_instance.api_instance_east.status
|
|
}
|
|
west = {
|
|
id = edge-connect_app_instance.api_instance_west.id
|
|
status = edge-connect_app_instance.api_instance_west.status
|
|
}
|
|
}
|
|
}
|