Skip to content

Commit

Permalink
feat: Fix insides of the service block and typos (#16)
Browse files Browse the repository at this point in the history
* Remove spare lines

Signed-off-by: Yurii Liaskovets <yurii.liaskovets@gmail.com>

* Remove duplicated dynamic block for env

Signed-off-by: Yurii Liaskovets <yurii.liaskovets@gmail.com>

* Set proper lookup value for service content block

Signed-off-by: Yurii Liaskovets <yurii.liaskovets@gmail.com>

* Correct typos and punctuation

Signed-off-by: Yurii Liaskovets <yurii.liaskovets@gmail.com>

* Add missing features parameter

Signed-off-by: Yurii Liaskovets <yurii.liaskovets@gmail.com>

* Add missing alert policy parameter

Signed-off-by: Yurii Liaskovets <yurii.liaskovets@gmail.com>

---------

Signed-off-by: Yurii Liaskovets <yurii.liaskovets@gmail.com>
  • Loading branch information
delaskoff committed May 26, 2024
1 parent 362d780 commit 7cf3f49
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 54 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- This file was automatically generated by the `geine`. Make all changes to `README.yaml` and run `make readme` to rebuild this file. -->
<!-- This file was automatically generated by the `genie`. Make all changes to `README.yaml` and run `make readme` to rebuild this file. -->

<p align="center"> <img src="https://user-images.githubusercontent.com/50652676/62349836-882fef80-b51e-11e9-99e3-7b974309c7e3.png" width="100" height="100"></p>

Expand All @@ -7,9 +7,9 @@
Terraform Digitalocean App
</h1>

<p align="center" style="font-size: 1.2rem;">
<p align="center" style="font-size: 1.2rem;">
Terraform module to create Digitalocean app service resource on Digitalocean.
</p>
</p>

<p align="center">

Expand All @@ -19,7 +19,7 @@
<a href="https://github.com/terraform-do-modules/terraform-digitalocean-app/actions/workflows/tfsec.yml">
<img src="https://github.com/terraform-do-modules/terraform-digitalocean-app/actions/workflows/tfsec.yml/badge.svg" alt="tfsec">
</a>
<a href="LICENSE.md">
<a href="LICENSE">
<img src="https://img.shields.io/badge/License-APACHE-blue.svg" alt="Licence">
</a>

Expand All @@ -43,9 +43,9 @@

We eat, drink, sleep and most importantly love **DevOps**. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy <b>Bigger problems are always solved by breaking them into smaller manageable problems</b>. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller <b>connected yet manageable pieces</b> within the infrastructure.

This module is basically combination of [Terraform open source](https://www.terraform.io/) and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself.
This module is basically combination of [Terraform open source](https://www.terraform.io/) and includes automation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself.

We have [*fifty plus terraform modules*][terraform_modules]. A few of them are comepleted and are available for open source usage while a few others are in progress.
We have [*fifty plus terraform modules*][terraform_modules]. A few of them are completed and are available for open source usage while a few others are in progress.



Expand All @@ -70,9 +70,9 @@ This module has a few dependencies:
Here are some examples of how you can use this module in your inventory structure:
## basic example
```hcl
module "domain" {
module "app" {
source = "terraform-do-modules/app/digitalocean"
version = "1.0.0"
version = "1.0.2"
spec = [{
name = "test"
region = "nyc"
Expand Down Expand Up @@ -105,12 +105,12 @@ module "domain" {
}
}]
}
```
```
## complete example
```hcl
module "domain" {
module "app" {
source = "terraform-do-modules/app/digitalocean"
version = "1.0.0"
version = "1.0.2"
spec = [{
name = "test"
region = "nyc"
Expand All @@ -137,7 +137,7 @@ module "domain" {
}
}]
}
```
```



Expand Down Expand Up @@ -166,17 +166,17 @@ module "domain" {


## Testing
In this module testing is performed with [terratest](https://github.com/gruntwork-io/terratest) and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a [GO environment](https://golang.org/doc/install) in your system.
In this module testing is performed with [terratest](https://github.com/gruntwork-io/terratest), and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a [GO environment](https://golang.org/doc/install) in your system.

You need to run the following command in the testing folder:
```hcl
```shell
go test -run Test
```



## Feedback
If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/terraform-do-modules/terraform-digitalocean-app/issues), or feel free to drop us an email at [hello@clouddrove.com](mailto:hello@clouddrove.com).
## Feedback
If you come across a bug or have any feedback, please log it in our [issue tracker](https://github.com/terraform-do-modules/terraform-digitalocean-app/issues), or feel free to drop us an email at [hello@clouddrove.com](mailto:hello@clouddrove.com).

If you have found it worth your time, go ahead and give us a ★ on [our GitHub](https://github.com/terraform-do-modules/terraform-digitalocean-app)!

Expand Down
12 changes: 6 additions & 6 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ usage: |-
Here are some examples of how you can use this module in your inventory structure:
## basic example
```hcl
module "domain" {
module "app" {
source = "terraform-do-modules/app/digitalocean"
version = "1.0.0"
version = "1.0.2"
spec = [{
name = "test"
region = "nyc"
Expand Down Expand Up @@ -90,12 +90,12 @@ usage: |-
}
}]
}
```
```
## complete example
```hcl
module "domain" {
module "app" {
source = "terraform-do-modules/app/digitalocean"
version = "1.0.0"
version = "1.0.2"
spec = [{
name = "test"
region = "nyc"
Expand All @@ -122,4 +122,4 @@ usage: |-
}
}]
}
```
```
54 changes: 22 additions & 32 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ resource "digitalocean_app" "this" {
dynamic "spec" {
for_each = try(jsondecode(var.spec), var.spec)
content {
name = spec.value.name
region = spec.value.region
name = spec.value.name
region = spec.value.region
features = lookup(spec.value, "features", [])
dynamic "domain" {
for_each = length(keys(lookup(spec.value, "domain", {}))) == 0 ? [] : [lookup(spec.value, "domain", {})]
content {
Expand All @@ -27,6 +28,7 @@ resource "digitalocean_app" "this" {
type = env.value.type
}
}

dynamic "database" {
for_each = length(keys(lookup(spec.value, "database", {}))) == 0 ? [] : [lookup(spec.value, "database", {})]
content {
Expand Down Expand Up @@ -73,9 +75,7 @@ resource "digitalocean_app" "this" {
port = redirect.value.port
scheme = redirect.value.scheme
redirect_code = redirect.value.redirect_code

}

}
dynamic "cors" {
for_each = length(keys(lookup(ingress.value, "cors", {}))) == 0 ? [] : [lookup(ingress.value, "cors", {})]
Expand All @@ -91,18 +91,14 @@ resource "digitalocean_app" "this" {
prefix = allow_origins.value.prefix
regex = allow_origins.value.regex
}

}
}
}

}

}
}
}


dynamic "function" {
for_each = length(keys(lookup(spec.value, "function", {}))) == 0 ? [] : [lookup(spec.value, "function", {})]
content {
Expand Down Expand Up @@ -174,12 +170,9 @@ resource "digitalocean_app" "this" {
content {
token = lookup(log_destination.value, "token", null)
}

}

}
}

}
}

Expand Down Expand Up @@ -249,33 +242,22 @@ resource "digitalocean_app" "this" {
allow_credentials = lookup(cors.value, "allow_credentials", null)
}
}

dynamic "env" {
for_each = lookup(static_site.value, "env", [])
content {
key = env.value.key
value = env.value.value
scope = lookup(env.value, "scope", "RUN_AND_BUILD_TIME")
type = env.value.type
}
}
}
}


dynamic "service" {
for_each = length(keys(lookup(spec.value, "service", {}))) == 0 ? [] : [lookup(spec.value, "service", {})]
content {
name = spec.value.name
build_command = lookup(spec.value, "build_command", null)
dockerfile_path = lookup(spec.value, "dockerfile_path", null)
source_dir = lookup(spec.value, "source_dir", null)
run_command = lookup(spec.value, "run_command", null)
environment_slug = lookup(spec.value, "environment_slug", null)
instance_size_slug = lookup(spec.value, "instance_size_slug", "basic-xxs")
instance_count = lookup(spec.value, "instance_count", 1)
http_port = lookup(spec.value, "http_port", 80)
internal_ports = lookup(spec.value, "internal_ports", null)
name = lookup(service.value, "name", spec.value.name)
build_command = lookup(service.value, "build_command", null)
dockerfile_path = lookup(service.value, "dockerfile_path", null)
source_dir = lookup(service.value, "source_dir", null)
run_command = lookup(service.value, "run_command", null)
environment_slug = lookup(service.value, "environment_slug", null)
instance_size_slug = lookup(service.value, "instance_size_slug", "basic-xxs")
instance_count = lookup(service.value, "instance_count", 1)
http_port = lookup(service.value, "http_port", 80)
internal_ports = lookup(service.value, "internal_ports", null)

dynamic "image" {
for_each = length(keys(lookup(service.value, "image", {}))) == 0 ? [] : [lookup(service.value, "image", {})]
Expand Down Expand Up @@ -370,6 +352,14 @@ resource "digitalocean_app" "this" {
}
}
}

dynamic "alert" {
for_each = length(keys(lookup(spec.value, "alert", {}))) == 0 ? [] : [lookup(spec.value, "alert", {})]
content {
rule = lookup(alert.value, "rule", null)
disabled = lookup(alert.value, "disabled", false)
}
}
}
}
}

0 comments on commit 7cf3f49

Please sign in to comment.