# Terraform Provider for Edge Connect This Terraform provider allows you to manage Edge Connect applications and application instances. ## Features - Manage application specifications (`edge-connect_app` resource) - Manage application instances (`edge-connect_appinst` resource) - Query existing applications and instances (data sources) - Support for bearer token and basic authentication - Full CRUD operations for all resources ## Requirements - [Terraform](https://www.terraform.io/downloads.html) >= 1.0 - [Go](https://golang.org/doc/install) >= 1.21 (for development) - Access to an Edge Connect API endpoint ## Installation ### Using Terraform Registry (Recommended) ```hcl terraform { required_providers { edge-connect = { source = "DevFW-CICD/edge-connect" version = "~> 1.0" } } } ``` ### Local Development 1. Clone the repository: ```bash git clone ssh://git@edp.buildth.ing/DevFW-CICD/terraform-provider-edge-connect.git cd terraform-provider-edge-connect ``` 2. Build the provider: ```bash go build -o terraform-provider-edge-connect ``` 3. Install locally: ```bash mkdir -p ~/.terraform.d/plugins/registry.terraform.io/DevFW-CICD/edge-connect/1.0.0/darwin_arm64 cp terraform-provider-edge-connect ~/.terraform.d/plugins/registry.terraform.io/DevFW-CICD/edge-connect/1.0.0/darwin_arm64/ ``` > Note: Adjust the path based on your OS and architecture (e.g., `linux_amd64`, `darwin_amd64`, etc.) 4. Generate the binary by running `go install .` from the repository root. This installs the provider binary to `$HOME/go/bin` and means that `terraform init` is not necessary. 5. You will also need a `~/.terraformrc` file with the following contents. `` should refer to your `$HOME` directory. ```hcl provider_installation { dev_overrides { "local/edge-connect" = "/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 {} } ``` ## Usage ### Provider Configuration The provider must be configured with credentials and a URL. This can be done with a token in your code: ```hcl provider "edge-connect" { base_url = "https://edp.buildth.ing" token = var.edge_connect_token } ``` Or with basic authentication: ```hcl 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_URL` - `EDGE_CONNECT_TOKEN` - `EDGE_CONNECT_USERNAME` - `EDGE_CONNECT_PASSWORD` ### Creating an Application ```hcl 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 ```hcl 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 ```hcl 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 } ``` ## 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 app - `name` (Required, Forces new resource) - The name of the application - `version` (Required, Forces new resource) - The version of the application - `image_type` (Required) - The type of image (e.g., 'Docker') - `image_path` (Required) - The path to the container image - `deployment` (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 created - `updated_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 deployed - `app_organization` (Required, Forces new resource) - The organization that owns the app - `app_name` (Required, Forces new resource) - The name of the application - `app_version` (Required, Forces new resource) - The version of the application - `cloudlet_organization` (Required, Forces new resource) - The organization that owns the cloudlet - `cloudlet_name` (Required, Forces new resource) - The name of the cloudlet - `cluster_organization` (Required, Forces new resource) - The organization that owns the cluster - `cloudlet` (Optional) - The cloudlet identifier - `flavor` (Optional) - The flavor for the app instance #### Attributes - `id` - The unique identifier - `real_cluster_name` - The real cluster name - `state` - The state of the app instance - `runtime_info` - Runtime information for the app instance - `uri` - The URI to access the app instance - `liveness` - The liveness status of the app instance - `power_state` - The power state of the app instance - `created_at` - The timestamp when the app instance was created - `updated_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 deployed - `organization` (Required) - The organization that owns the app - `name` (Required) - The name of the application - `version` (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 deployed - `app_organization` (Required) - The organization that owns the app - `app_name` (Required) - The name of the application - `app_version` (Required) - The version of the application - `cloudlet_organization` (Required) - The organization that owns the cloudlet - `cloudlet_name` (Required) - The name of the cloudlet - `cluster_organization` (Required) - The organization that owns the cluster ## Examples See the [examples](./examples) directory for complete usage examples. ## Development ### Building ```bash go build -o terraform-provider-edge-connect ``` ### Testing ```bash go test ./... ``` ### Running Example ```bash 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