Skip to content

Conversation

@FaureAlexis
Copy link

🎯 Scope

Add full support for Coolify applications in the Terraform provider, enabling creation and management of applications via IaC.
Requested in #51

I have tested and deployed an infra with 7 differents applications(laravel, nodejs, nuxtjs) + 2 services (valkey, mysql) using theses changes.

✨ Features

  • 6 supported source types:

    • public - Public Git repository
    • private-github-app - Private Git repository via GitHub App
    • private-deploy-key - Private Git repository via Deploy Key
    • dockerfile - Application with custom Dockerfile
    • dockerimage - Docker image from a registry
    • dockercompose - Docker Compose application
  • Full CRUD operations: Create, Read, Update, Delete

  • Import: Import existing applications by UUID

  • Conditional validation: Required fields depend on source_type

  • Sensitive data management: Secrets are automatically marked as sensitive

📝 Usage example

resource "coolify_application" "my_app" {
  source_type = "public"
  
  project_uuid     = "xxx"
  server_uuid      = "xxx"
  environment_name = "production"
  
  git_repository = "https://github.com/user/repo"
  git_branch     = "main"
  build_pack     = "nixpacks"
  ports_exposes  = "80"
  
  name = "My Application"
}

📦 Added files

  • internal/service/application_model.go - Terraform model and schema
  • internal/service/application_resource.go - CRUD implementation
  • internal/service/application_resource_test.go - Unit tests
  • internal/service/application_resource_acceptance_test.go - Acceptance tests
  • examples/resources/coolify_application/* - Examples for each type
  • FEATURES_APPLICATION.md - Complete documentation
  • USAGE_LOCAL.md - Local usage guide
  • scripts/install-local-provider.sh - Installation script (local testing)

🔧 Modified files

  • tools/tfplugingen-openapi.yml - Configuration to generate the resource
  • internal/provider/provider.go - Resource registration

✅ Tests

  • Schema unit tests
  • Acceptance tests (create/read/update/delete)
  • Compilation without errors
  • Conditional validation functional

📚 Documentation

  • Examples for each source type in examples/resources/coolify_application/

🚀 How to test

# Install the provider locally
./scripts/install-local-provider.sh

# In your Terraform project (remove .terraform and lock if needed)
terraform init
terraform plan
terraform apply

Add StringOrNil function that returns nil for null, unknown, or empty strings.
This is useful for API fields that should be omitted when empty rather than
sending empty strings.
Use StringOrNil instead of ValueStringPointer for DestinationUuid to prevent
sending empty strings to the API when the field is not set.
The Coolify API only accepts key, value, is_preview, and is_literal during
creation. Other fields (is_build_time, is_multiline, is_shown_once) must be
updated via a bulk update after creation.
Implement coolify_application resource supporting multiple application types:
- Public Git repositories
- Private Git repositories with deploy keys
- GitHub App deployments
- Dockerfile-based deployments
- Docker Image deployments
- Docker Compose deployments

Includes comprehensive model mapping, plan modifiers, unit tests, acceptance
tests, and example Terraform configurations for each application type.
@FaureAlexis
Copy link
Author

Also fixed a bug with applications env : is_build_time is not supported by the API, so if passed as an argument it will not be passed in the Create but will update env var after

Add utility script for installing the provider locally for development
and testing purposes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant