|
|
||
|---|---|---|
| .github/workflows | ||
| examples | ||
| internal/provider | ||
| .gitignore | ||
| .goreleaser.yaml | ||
| generate-provider-json.sh | ||
| go.mod | ||
| go.sum | ||
| main.go | ||
| Makefile | ||
| README.md | ||
| terraform-registry-manifest.json | ||
Terraform Provider for Edge Connect
This Terraform provider allows you to manage Edge Connect applications and application instances.
Features
- Manage application specifications (
edge-connect_appresource) - Manage application instances (
edge-connect_appinstresource) - Query existing applications and instances (data sources)
- Support for bearer token and basic authentication
- Full CRUD operations for all resources
Requirements
Installation
Using Terraform Registry (Recommended)
terraform {
required_providers {
edge-connect = {
source = "terralist.edp.buildth.ing/edge-connect/edge-connect"
version = ">= 0.0.15"
}
}
}
Terralist
To allow the above downloads, the provider artifact must be published to a private Terraform registry. We use Terralist.
Terralist is deployed on EDP clusters via ArgoCD using the terralist stack. Administration can be performed by logging in via the relevant Forgejo instance (set up during cluster deployment), but no authentication is needed to download published Providers.
Publishing a new instance requires a GPG key, which is stored within the Forgejo Organisation secrets to be available to the release pipeline. It also requires a TERRALIST_API_KEY (stored at the repository level) to be able to push; this can be created within terralist settings: first create a new Authority with Name edge-connect and empty Policy, create a new API Key, then hit the ▽ button and 𓁹 to view the Key.
Next, you must ensure Terraform can download the Provider. To the Authority, add a Signing Key, with Key ID and ASCII Armor copied from the output of the release workflow. Trust Signature can be left empty.
Local Development
-
Clone the repository:
git clone ssh://git@edp.buildth.ing/DevFW-CICD/terraform-provider-edge-connect.git cd terraform-provider-edge-connect -
Generate the binary by running
go install .from the repository root. This installs the provider binary to$HOME/go/binand means thatterraform initis not necessary. Note that you will need$HOME/go/binto be in your$PATHvariable for this to work smoothly. -
You will also need a
~/.terraformrcfile with the following contents.<home>should refer to your$HOMEdirectory. It should contain the following:provider_installation { dev_overrides { "local/edge-connect" = "<home>/go/bin" } # For all other providers, install them directly from their origin provider # registries as normal. If you omit this, Terraform will _only_ use # the dev_overrides block, and so no other providers will be available. direct {} } -
You can then test changes by running the following from the /examples/edgeconnect-config/ repo whenever you update the source code:
go install ../../ && terraform plan- You will of course need credentials in order to execute
terraform plan, as described below.
- You will of course need credentials in order to execute
Usage
Provider Configuration
The provider must be configured with credentials and a URL. This can be done with a token in your code:
provider "edge-connect" {
base_url = "https://edp.buildth.ing"
token = var.edge_connect_token
}
Or with basic authentication:
provider "edge-connect" {
base_url = "https://edp.buildth.ing"
username = var.edge_connect_username
password = var.edge_connect_password
}
Or without code changes, via environment variables:
EDGE_CONNECT_BASE_URLEDGE_CONNECT_TOKENEDGE_CONNECT_USERNAMEEDGE_CONNECT_PASSWORD
Creating an Application
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"
}
Creating an Application Instance
resource "edge-connect_appinst" "example" {
region = "EU"
app_organization = edge-connect_app.example.organization
app_name = edge-connect_app.example.name
app_version = edge-connect_app.example.version
cloudlet_organization = "cloudlet-org"
cloudlet_name = "edge-cloudlet-1"
cluster_organization = "cluster-org"
flavor = "EU.medium"
}
Using Data Sources
data "edge-connect_app" "existing" {
region = "EU"
organization = "myorg"
name = "existing-app"
version = "2.0.0"
}
output "app_image" {
value = data.edge-connect_app.existing.image_path
}
Importing Existing Resources
Both resource types support Terraform's import command to bring existing resources under Terraform management.
Importing an Application
To import an existing application, use the following import ID format:
terraform import edge-connect_app.example organization/name/version/region/cloudlet_org/cloudlet_name/flavor_name
Example:
terraform import edge-connect_app.my_app edp2/my-app/1.0.0/EU/TelekomOP/Munich/EU.small
Note: The import ID requires all 7 fields because the Edge Connect API does not return cloudlet_org, cloudlet_name, or flavor_name when querying an app. These values must be provided in the import ID to satisfy Terraform's schema validation.
Make sure your Terraform configuration includes all required fields:
resource "edge-connect_app" "my_app" {
name = "my-app"
app_version = "1.0.0"
organization = "edp2"
region = "EU"
cloudlet_org = "TelekomOP"
cloudlet_name = "Munich"
flavor_name = "EU.small"
# These will be populated from the API during import:
# - manifest
# - image_path
}
Importing an Application Instance
To import an existing application instance, use the following import ID format:
terraform import edge-connect_app_instance.example organization/name/cloudlet_org/cloudlet_name/region
Example:
terraform import edge-connect_app_instance.my_instance edp2/my-instance/TelekomOP/Munich/EU
All other required fields (app_name, app_version, app_organization, flavor_name, state, power_state) will be automatically populated from the API during the import.
Make sure your Terraform configuration includes the fields from the import ID:
resource "edge-connect_app_instance" "my_instance" {
name = "my-instance"
organization = "edp2"
region = "EU"
cloudlet_org = "TelekomOP"
cloudlet_name = "Munich"
# These will be populated from the API during import:
# - app_name
# - app_version
# - app_organization
# - flavor_name
# - state
# - power_state
}
Resources
edge-connect_app
Manages an Edge Connect application specification.
Arguments
region(Required, Forces new resource) - The region where the app is deployed (e.g., 'EU')organization(Required, Forces new resource) - The organization that owns the appname(Required, Forces new resource) - The name of the applicationversion(Required, Forces new resource) - The version of the applicationimage_type(Required) - The type of image (e.g., 'Docker')image_path(Required) - The path to the container imagedeployment(Required) - The deployment type (e.g., 'kubernetes')default_flavor(Optional) - The default flavor (e.g., 'EU.small', 'EU.medium', 'EU.big', 'EU.large')deployment_manifest(Optional) - The Kubernetes deployment manifest (YAML)access_ports(Optional) - The access ports in format 'protocol:port' (e.g., 'tcp:80,tcp:443')annotations(Optional) - Annotations for the app
Attributes
id- The unique identifier (format: region/organization/name/version)created_at- The timestamp when the app was createdupdated_at- The timestamp when the app was last updated
edge-connect_appinst
Manages an Edge Connect application instance.
Arguments
region(Required, Forces new resource) - The region where the app instance is deployedapp_organization(Required, Forces new resource) - The organization that owns the appapp_name(Required, Forces new resource) - The name of the applicationapp_version(Required, Forces new resource) - The version of the applicationcloudlet_organization(Required, Forces new resource) - The organization that owns the cloudletcloudlet_name(Required, Forces new resource) - The name of the cloudletcluster_organization(Required, Forces new resource) - The organization that owns the clustercloudlet(Optional) - The cloudlet identifierflavor(Optional) - The flavor for the app instance
Attributes
id- The unique identifierreal_cluster_name- The real cluster namestate- The state of the app instanceruntime_info- Runtime information for the app instanceuri- The URI to access the app instanceliveness- The liveness status of the app instancepower_state- The power state of the app instancecreated_at- The timestamp when the app instance was createdupdated_at- The timestamp when the app instance was last updated
Data Sources
data.edge-connect_app
Fetches information about an existing Edge Connect application.
Arguments
region(Required) - The region where the app is deployedorganization(Required) - The organization that owns the appname(Required) - The name of the applicationversion(Required) - The version of the application
data.edge-connect_appinst
Fetches information about an existing Edge Connect application instance.
Arguments
region(Required) - The region where the app instance is deployedapp_organization(Required) - The organization that owns the appapp_name(Required) - The name of the applicationapp_version(Required) - The version of the applicationcloudlet_organization(Required) - The organization that owns the cloudletcloudlet_name(Required) - The name of the cloudletcluster_organization(Required) - The organization that owns the cluster
Examples
See the examples directory for complete usage examples.
Development
Building
go build -o terraform-provider-edge-connect
Testing
go test ./...
Running Example
cd examples
terraform init
terraform plan
terraform apply
Contributing
Contributions are welcome! Please submit pull requests or open issues on the repository.
License
This provider is distributed under the Mozilla Public License 2.0. See LICENSE for more information.
Support
For issues and questions:
- Open an issue on the repository
- Contact the DevFW-CICD team at https://edp.buildth.ing