terraform-provider-edge-con.../examples
2025-11-11 17:21:46 +01:00
..
edgeconnect-config added edge-connect_app_instance 2025-11-11 17:20:04 +01:00
.gitignore added examples 2025-11-11 15:32:09 +01:00
ENV_VARS.md added username/password or token as env variable 2025-11-11 15:41:07 +01:00
README.md added username/password or token as env variable 2025-11-11 15:41:07 +01:00

Terraform Provider Edge Connect Examples

This directory contains example Terraform configurations demonstrating the usage of the Edge Connect Terraform provider.

Available Examples

Authentication Examples (authentication/)

Dedicated examples showing both authentication methods with detailed documentation.

Features:

  • Token-based authentication example
  • Username/password authentication example
  • Validation rules and error messages
  • Best practices and recommendations

See: authentication/README.md for detailed authentication documentation.

1. Basic Example (basic/)

The simplest example showing how to create a single application.

Features:

  • Provider configuration
  • Creating a basic app resource
  • Output values

Usage:

cd basic
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your credentials
terraform init
terraform plan
terraform apply

2. Complete Example (complete/)

A comprehensive example demonstrating multiple resources and realistic scenarios.

Features:

  • Creating multiple applications
  • Creating multiple app instances
  • Configuring app instances with JSON config
  • Deploying instances across different regions
  • Multiple output values

Usage:

cd complete
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your credentials
terraform init
terraform plan
terraform apply

3. Data Sources Example (data-sources/)

Demonstrates using data sources to look up existing resources and use them in configurations.

Features:

  • Using edge-connect_app data source
  • Using edge-connect_app_instance data source
  • Creating new resources based on existing data
  • Referencing data source attributes

Usage:

cd data-sources
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your credentials and existing resource IDs
terraform init
terraform plan
terraform apply

Provider Configuration

The provider supports two authentication methods:

Option 1: Token-based Authentication

provider "edge-connect" {
  endpoint = "https://api.edge-connect.example.com"
  token    = var.edge_connect_token
}

Option 2: Username/Password Authentication

provider "edge-connect" {
  endpoint = "https://api.edge-connect.example.com"
  username = var.edge_connect_username
  password = var.edge_connect_password
}

Configuration Options

  • endpoint (optional): The Edge Connect API endpoint URL. Can also be set via EDGE_CONNECT_ENDPOINT environment variable.
  • token (optional, sensitive): Authentication token for the Edge Connect API. Required if username/password are not provided. Can also be set via EDGE_CONNECT_TOKEN environment variable.
  • username (optional): Username for the Edge Connect API. Required if token is not provided. Can also be set via EDGE_CONNECT_USERNAME environment variable.
  • password (optional, sensitive): Password for the Edge Connect API. Required if token is not provided. Can also be set via EDGE_CONNECT_PASSWORD environment variable.

Important: You must use either token authentication OR username/password authentication, but not both.

Environment Variables

All provider configuration can be set via environment variables:

Environment Variable Description
EDGE_CONNECT_ENDPOINT API endpoint URL
EDGE_CONNECT_TOKEN API token (for token auth)
EDGE_CONNECT_USERNAME Username (for username/password auth)
EDGE_CONNECT_PASSWORD Password (for username/password auth)

Example using environment variables:

export EDGE_CONNECT_ENDPOINT="https://api.edge-connect.example.com"
export EDGE_CONNECT_TOKEN="your-token"
terraform init
terraform apply

See authentication/README.md for detailed information about environment variable usage.

Resources

edge-connect_app

Manages an Edge Connect application.

Arguments:

  • name (required): Application name
  • version (optional): Application version
  • description (optional): Application description

Attributes:

  • id: Application identifier
  • status: Application status

Example:

resource "edge-connect_app" "example" {
  name        = "my-app"
  version     = "1.0.0"
  description = "My application"
}

edge-connect_app_instance

Manages an Edge Connect application instance.

Arguments:

  • name (required): Instance name
  • app_id (required): Associated application ID
  • description (optional): Instance description
  • config (optional): Instance configuration (JSON string)

Attributes:

  • id: Instance identifier
  • status: Instance status

Example:

resource "edge-connect_app_instance" "example" {
  name   = "my-app-instance"
  app_id = edge-connect_app.example.id
  config = jsonencode({
    environment = "production"
    replicas    = 3
  })
}

Data Sources

edge-connect_app

Retrieves information about an existing application.

Arguments:

  • id (required): Application identifier

Attributes:

  • name: Application name
  • version: Application version
  • description: Application description
  • status: Application status

edge-connect_app_instance

Retrieves information about an existing application instance.

Arguments:

  • id (required): Instance identifier

Attributes:

  • name: Instance name
  • app_id: Associated application ID
  • description: Instance description
  • config: Instance configuration
  • status: Instance status

Prerequisites

  1. Terraform >= 1.0
  2. Valid Edge Connect API credentials
  3. Access to an Edge Connect API endpoint

Getting Started

Option 1: Using Configuration Files

  1. Choose an example that fits your use case
  2. Navigate to the example directory
  3. Copy terraform.tfvars.example to terraform.tfvars
  4. Edit terraform.tfvars with your actual credentials
  5. Run terraform init to initialize the provider
  6. Run terraform plan to see what will be created
  7. Run terraform apply to create the resources
  1. Choose an example that fits your use case
  2. Navigate to the example directory
  3. Set environment variables:
    export EDGE_CONNECT_ENDPOINT="https://api.edge-connect.example.com"
    export EDGE_CONNECT_TOKEN="your-token"
    
  4. Run terraform init to initialize the provider
  5. Run terraform plan to see what will be created
  6. Run terraform apply to create the resources

Cleanup

To destroy the resources created by these examples:

terraform destroy

Notes

  • Keep your terraform.tfvars file secure as it contains sensitive credentials
  • The terraform.tfvars file is gitignored by default
  • Always review the plan output before applying changes
  • Some resources may take time to provision
  • Recommended: Use environment variables for credentials in production and CI/CD environments
  • Environment variables take precedence when both are provided
  • Consider using tools like direnv for automatic environment variable management per directory

Support

For issues or questions about the provider, please refer to the main provider documentation.