65 lines
2.1 KiB
HCL
65 lines
2.1 KiB
HCL
terraform {
|
|
required_providers {
|
|
edge-connect = {
|
|
source = "local/edge-connect"
|
|
}
|
|
}
|
|
}
|
|
|
|
# Provider configuration with token authentication
|
|
provider "edge-connect" {
|
|
endpoint = var.edge_connect_endpoint
|
|
token = var.edge_connect_token
|
|
}
|
|
|
|
# Alternative: Username/password authentication (uncomment to use)
|
|
# provider "edge-connect" {
|
|
# endpoint = var.edge_connect_endpoint
|
|
# username = var.edge_connect_username
|
|
# password = var.edge_connect_password
|
|
# }
|
|
|
|
# Data source: Look up an existing app by ID
|
|
data "edge-connect_app" "existing_app" {
|
|
id = var.app_id
|
|
}
|
|
|
|
# Data source: Look up an existing app instance by ID
|
|
data "edge-connect_app_instance" "existing_instance" {
|
|
id = var.app_instance_id
|
|
}
|
|
|
|
# You can use data from data sources to create new resources
|
|
resource "edge-connect_app_instance" "new_instance" {
|
|
name = "new-instance-based-on-existing"
|
|
app_id = data.edge-connect_app.existing_app.name
|
|
description = "New instance created based on existing app: ${data.edge-connect_app.existing_app.name}"
|
|
}
|
|
|
|
# Outputs showing data source information
|
|
output "existing_app_info" {
|
|
description = "Information about the existing app"
|
|
value = {
|
|
id = data.edge-connect_app.existing_app.id
|
|
name = data.edge-connect_app.existing_app.name
|
|
version = data.edge-connect_app.existing_app.version
|
|
description = data.edge-connect_app.existing_app.description
|
|
status = data.edge-connect_app.existing_app.status
|
|
}
|
|
}
|
|
|
|
output "existing_instance_info" {
|
|
description = "Information about the existing app instance"
|
|
value = {
|
|
id = data.edge-connect_app_instance.existing_instance.id
|
|
name = data.edge-connect_app_instance.existing_instance.name
|
|
app_id = data.edge-connect_app_instance.existing_instance.app_id
|
|
description = data.edge-connect_app_instance.existing_instance.description
|
|
status = data.edge-connect_app_instance.existing_instance.status
|
|
}
|
|
}
|
|
|
|
output "new_instance_id" {
|
|
description = "ID of the newly created instance"
|
|
value = edge-connect_app_instance.new_instance.id
|
|
}
|