Skip to content

Commit

Permalink
feat(static): new app support (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
miton18 authored Nov 2, 2023
1 parent 2a0c664 commit 08a5137
Show file tree
Hide file tree
Showing 10 changed files with 573 additions and 1 deletion.
132 changes: 132 additions & 0 deletions docs/resources/static.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "clevercloud_static Resource - terraform-provider-clevercloud"
subcategory: ""
description: |-
Manage Static applications.
See Static product https://www.clever-cloud.com/doc/deploy/application/static/static/ specification.
Example usage
Basic
terraform
resource "clevercloud_static" "myapp" {
name = "tf-myapp"
region = "par"
min_instance_count = 1
max_instance_count = 2
smallest_flavor = "XS"
biggest_flavor = "M"
}
Advanced
terraform
resource "clevercloud_static" "myapp" {
name = "tf-myapp"
region = "par"
min_instance_count = 1
max_instance_count = 2
smallest_flavor = "XS"
biggest_flavor = "M"
dependencies = [
"addon_bcc1d486-90f2-4e89-892d-38dbd8f7bc32"
]
deployment {
repository = "https://github.com/..."
}
}
---

# clevercloud_static (Resource)

# Manage Static applications.

See [Static product](https://www.clever-cloud.com/doc/deploy/application/static/static/) specification.

## Example usage

### Basic

```terraform
resource "clevercloud_static" "myapp" {
name = "tf-myapp"
region = "par"
min_instance_count = 1
max_instance_count = 2
smallest_flavor = "XS"
biggest_flavor = "M"
}
```

### Advanced

```terraform
resource "clevercloud_static" "myapp" {
name = "tf-myapp"
region = "par"
min_instance_count = 1
max_instance_count = 2
smallest_flavor = "XS"
biggest_flavor = "M"
dependencies = [
"addon_bcc1d486-90f2-4e89-892d-38dbd8f7bc32"
]
deployment {
repository = "https://github.com/..."
}
}
```



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `biggest_flavor` (String) Biggest intance flavor, if different from smallest, enable autoscaling
- `max_instance_count` (Number) Maximum instance count, if different from min value, enable autoscaling
- `min_instance_count` (Number) Minimum instance count
- `name` (String) Application name
- `region` (String) Geographical region where the app will be deployed
- `smallest_flavor` (String) Smallest instance flavor

### Optional

- `additional_vhosts` (List of String) Add custom hostname in addition to the default one, see [documentation](https://www.clever-cloud.com/doc/administrate/domain-names/)
- `app_folder` (String) Folder in which the application is located (inside the git repository)
- `build_flavor` (String) Use dedicated instance with given flavor for build step
- `dependencies` (Set of String) A list of application or addons requires to run this application.
Can be either app_xxx or postgres_yyy ID format
- `deployment` (Block, Optional) (see [below for nested schema](#nestedblock--deployment))
- `description` (String) Application description
- `environment` (Map of String, Sensitive) Environment variables injected into the application
- `hooks` (Block, Optional) (see [below for nested schema](#nestedblock--hooks))
- `redirect_https` (Boolean) Redirect client from plain to TLS port
- `sticky_sessions` (Boolean) Enable sticky sessions, use it when your client sessions are instances scoped

### Read-Only

- `deploy_url` (String) Git URL used to push source code
- `id` (String) Unique identifier generated during application creation
- `vhost` (String) Default vhost to access your app

<a id="nestedblock--deployment"></a>
### Nested Schema for `deployment`

Optional:

- `commit` (String) Deploy application on the given commit/tag
- `repository` (String)


<a id="nestedblock--hooks"></a>
### Nested Schema for `hooks`

Optional:

- `post_build` (String) [CC_POST_BUILD_HOOK](https://www.clever-cloud.com/doc/develop/build-hooks/#post-build-cc_post_build_hook)
- `pre_build` (String) [CC_PRE_BUILD_HOOK](https://www.clever-cloud.com/doc/develop/build-hooks/#pre-build-cc_pre_build_hook)
- `pre_run` (String) [CC_PRE_RUN_HOOK](https://www.clever-cloud.com/doc/develop/build-hooks/#pre-run-cc_pre_run_hook)
- `run_failed` (String) [CC_RUN_FAILED_HOOK](https://www.clever-cloud.com/doc/develop/build-hooks/#run-succeeded-cc_run_succeeded_hook-or-failed-cc_run_failed_hook)
- `run_succeed` (String) [CC_RUN_SUCCEEDED_HOOK](https://www.clever-cloud.com/doc/develop/build-hooks/#run-succeeded-cc_run_succeeded_hook-or-failed-cc_run_failed_hook)


2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.clever-cloud.com/terraform-provider

go 1.18
go 1.21

require (
github.com/go-git/go-billy/v5 v5.4.1
Expand Down
2 changes: 2 additions & 0 deletions pkg/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"go.clever-cloud.com/terraform-provider/pkg/resources/php"
"go.clever-cloud.com/terraform-provider/pkg/resources/postgresql"
"go.clever-cloud.com/terraform-provider/pkg/resources/scala"
"go.clever-cloud.com/terraform-provider/pkg/resources/static"
)

var Datasources = []func() datasource.DataSource{}
Expand All @@ -22,4 +23,5 @@ var Resources = []func() resource.Resource{
postgresql.NewResourcePostgreSQL,
java.NewResourceJava("war"),
scala.NewResourceScala(),
static.NewResourceStatic(),
}
3 changes: 3 additions & 0 deletions pkg/resources/static/provider_test_block.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "clevercloud" {
organisation = "%s"
}
23 changes: 23 additions & 0 deletions pkg/resources/static/resource_static.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package static

import (
"context"

"github.com/hashicorp/terraform-plugin-framework/resource"
"go.clever-cloud.dev/client"
)

type ResourceStatic struct {
cc *client.Client
org string
}

func NewResourceStatic() func() resource.Resource {
return func() resource.Resource {
return &ResourceStatic{}
}
}

func (r *ResourceStatic) Metadata(ctx context.Context, req resource.MetadataRequest, res *resource.MetadataResponse) {
res.TypeName = req.ProviderTypeName + "_static"
}
37 changes: 37 additions & 0 deletions pkg/resources/static/resource_static.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Manage Static applications.

See [Static product](https://www.clever-cloud.com/doc/deploy/application/static/static/) specification.

## Example usage

### Basic

```terraform
resource "clevercloud_static" "myapp" {
name = "tf-myapp"
region = "par"
min_instance_count = 1
max_instance_count = 2
smallest_flavor = "XS"
biggest_flavor = "M"
}
```

### Advanced

```terraform
resource "clevercloud_static" "myapp" {
name = "tf-myapp"
region = "par"
min_instance_count = 1
max_instance_count = 2
smallest_flavor = "XS"
biggest_flavor = "M"
dependencies = [
"addon_bcc1d486-90f2-4e89-892d-38dbd8f7bc32"
]
deployment {
repository = "https://github.com/..."
}
}
```
Loading

0 comments on commit 08a5137

Please sign in to comment.