93 lines
2.1 KiB
Terraform
93 lines
2.1 KiB
Terraform
|
|
terraform {
|
||
|
|
required_providers {
|
||
|
|
edge-connect = {
|
||
|
|
source = "DevFW-CICD/edge-connect"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
provider "edge-connect" {
|
||
|
|
base_url = "https://edp.buildth.ing"
|
||
|
|
token = var.edge_connect_token
|
||
|
|
# Alternatively, use username and password:
|
||
|
|
# username = var.edge_connect_username
|
||
|
|
# password = var.edge_connect_password
|
||
|
|
}
|
||
|
|
|
||
|
|
variable "edge_connect_token" {
|
||
|
|
description = "Edge Connect API token"
|
||
|
|
type = string
|
||
|
|
sensitive = true
|
||
|
|
}
|
||
|
|
|
||
|
|
# Create an application specification
|
||
|
|
resource "edge-connect_app" "example" {
|
||
|
|
region = "EU"
|
||
|
|
organization = "myorg"
|
||
|
|
name = "my-app"
|
||
|
|
version = "1.0.0"
|
||
|
|
|
||
|
|
image_type = "Docker"
|
||
|
|
image_path = "nginx:latest"
|
||
|
|
deployment = "kubernetes"
|
||
|
|
default_flavor = "EU.small"
|
||
|
|
access_ports = "tcp:80,tcp:443"
|
||
|
|
|
||
|
|
annotations = "env=production"
|
||
|
|
}
|
||
|
|
|
||
|
|
# Create an application instance
|
||
|
|
resource "edge-connect_appinst" "example" {
|
||
|
|
region = "EU"
|
||
|
|
|
||
|
|
# Reference to the app
|
||
|
|
app_organization = edge-connect_app.example.organization
|
||
|
|
app_name = edge-connect_app.example.name
|
||
|
|
app_version = edge-connect_app.example.version
|
||
|
|
|
||
|
|
# Cloudlet and cluster configuration
|
||
|
|
cloudlet_organization = "cloudlet-org"
|
||
|
|
cloudlet_name = "edge-cloudlet-1"
|
||
|
|
cluster_organization = "cluster-org"
|
||
|
|
|
||
|
|
# Instance configuration
|
||
|
|
flavor = "EU.medium"
|
||
|
|
}
|
||
|
|
|
||
|
|
# Data source to read an existing app
|
||
|
|
data "edge-connect_app" "existing" {
|
||
|
|
region = "EU"
|
||
|
|
organization = "myorg"
|
||
|
|
name = "existing-app"
|
||
|
|
version = "2.0.0"
|
||
|
|
}
|
||
|
|
|
||
|
|
# Data source to read an existing app instance
|
||
|
|
data "edge-connect_appinst" "existing" {
|
||
|
|
region = "EU"
|
||
|
|
|
||
|
|
app_organization = "myorg"
|
||
|
|
app_name = "existing-app"
|
||
|
|
app_version = "2.0.0"
|
||
|
|
cloudlet_organization = "cloudlet-org"
|
||
|
|
cloudlet_name = "edge-cloudlet-1"
|
||
|
|
cluster_organization = "cluster-org"
|
||
|
|
}
|
||
|
|
|
||
|
|
# Outputs
|
||
|
|
output "app_id" {
|
||
|
|
value = edge-connect_app.example.id
|
||
|
|
}
|
||
|
|
|
||
|
|
output "app_instance_uri" {
|
||
|
|
value = edge-connect_appinst.example.uri
|
||
|
|
}
|
||
|
|
|
||
|
|
output "app_instance_state" {
|
||
|
|
value = edge-connect_appinst.example.state
|
||
|
|
}
|
||
|
|
|
||
|
|
output "existing_app_image" {
|
||
|
|
value = data.edge-connect_app.existing.image_path
|
||
|
|
}
|