init
This commit is contained in:
commit
51c743fb2b
17 changed files with 2387 additions and 0 deletions
136
examples/complete/main.tf
Normal file
136
examples/complete/main.tf
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
edge-connect = {
|
||||
source = "DevFW-CICD/edge-connect"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "edge-connect" {
|
||||
base_url = "https://edp.buildth.ing"
|
||||
token = var.edge_connect_token
|
||||
}
|
||||
|
||||
variable "edge_connect_token" {
|
||||
description = "Edge Connect API token"
|
||||
type = string
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
# Create a web application
|
||||
resource "edge-connect_app" "web_app" {
|
||||
region = "EU"
|
||||
organization = "acme-corp"
|
||||
name = "web-frontend"
|
||||
version = "1.0.0"
|
||||
|
||||
image_type = "Docker"
|
||||
image_path = "nginx:alpine"
|
||||
deployment = "kubernetes"
|
||||
default_flavor = "EU.small"
|
||||
access_ports = "tcp:80,tcp:443"
|
||||
|
||||
# Optional Kubernetes deployment manifest
|
||||
deployment_manifest = <<-EOT
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: web-frontend
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: web-frontend
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: web-frontend
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx:alpine
|
||||
ports:
|
||||
- containerPort: 80
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: web-frontend
|
||||
spec:
|
||||
selector:
|
||||
app: web-frontend
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 80
|
||||
targetPort: 80
|
||||
type: LoadBalancer
|
||||
EOT
|
||||
|
||||
annotations = "team=platform,env=production"
|
||||
}
|
||||
|
||||
# Create an API backend application
|
||||
resource "edge-connect_app" "api_backend" {
|
||||
region = "EU"
|
||||
organization = "acme-corp"
|
||||
name = "api-backend"
|
||||
version = "2.3.1"
|
||||
|
||||
image_type = "Docker"
|
||||
image_path = "acme/api-server:2.3.1"
|
||||
deployment = "kubernetes"
|
||||
default_flavor = "EU.medium"
|
||||
access_ports = "tcp:8080"
|
||||
annotations = "team=backend,env=production"
|
||||
}
|
||||
|
||||
# Deploy the web app to edge cloudlet
|
||||
resource "edge-connect_appinst" "web_instance" {
|
||||
region = "EU"
|
||||
|
||||
app_organization = edge-connect_app.web_app.organization
|
||||
app_name = edge-connect_app.web_app.name
|
||||
app_version = edge-connect_app.web_app.version
|
||||
|
||||
cloudlet_organization = "edge-provider"
|
||||
cloudlet_name = "eu-west-1"
|
||||
cluster_organization = "acme-corp"
|
||||
|
||||
flavor = "EU.medium"
|
||||
}
|
||||
|
||||
# Deploy the API backend to edge cloudlet
|
||||
resource "edge-connect_appinst" "api_instance" {
|
||||
region = "EU"
|
||||
|
||||
app_organization = edge-connect_app.api_backend.organization
|
||||
app_name = edge-connect_app.api_backend.name
|
||||
app_version = edge-connect_app.api_backend.version
|
||||
|
||||
cloudlet_organization = "edge-provider"
|
||||
cloudlet_name = "eu-west-1"
|
||||
cluster_organization = "acme-corp"
|
||||
|
||||
flavor = "EU.large"
|
||||
}
|
||||
|
||||
# Outputs
|
||||
output "web_app_uri" {
|
||||
description = "URI to access the web application"
|
||||
value = edge-connect_appinst.web_instance.uri
|
||||
}
|
||||
|
||||
output "web_app_state" {
|
||||
description = "Current state of the web application instance"
|
||||
value = edge-connect_appinst.web_instance.state
|
||||
}
|
||||
|
||||
output "api_backend_uri" {
|
||||
description = "URI to access the API backend"
|
||||
value = edge-connect_appinst.api_instance.uri
|
||||
}
|
||||
|
||||
output "api_backend_state" {
|
||||
description = "Current state of the API backend instance"
|
||||
value = edge-connect_appinst.api_instance.state
|
||||
}
|
||||
92
examples/main.tf
Normal file
92
examples/main.tf
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue