Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## 1.0.0 (March 24, 2022)
- Project Initialization[GH-1](https://github.com/terraform-alicloud-modules/terraform-alicloud-serverless-workflow/pull/1)
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,53 @@
# terraform-alicloud-serverless-workflow
Terraform Module for creating Serverless Workflow resources on Alibaba Cloud.

These types of resources are supported:

* [alicloud_fnf_flow](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/fnf_flow)
* [alicloud_fnf_execution](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/fnf_execution)
* [alicloud_fnf_schedule](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/fnf_schedule)

## Usage

```hcl
module "example" {
source = "terraform-alicloud-modules/serverless-workflow/alicloud"
description = "your_description"
name = "your_name"
type = "DEFAULT"

execution_name = "your_execution_name"
flow_name = "your_flow_name"
input = "your_input"
status = "your_status"

cron_expression = "your_cron_expression"
schedule_name = "your_schedule_name"
payload = "your_payload"
}
```

## Examples

* [complete example](https://github.com/terraform-alicloud-modules/serverless-workflow/tree/main/examples/complete)

## Terraform versions

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
| <a name="requirement_alicloud"></a> [alicloud](#requirement\_alicloud) | >= 1.149.0 |

Authors
-------
Created and maintained by Alibaba Cloud Terraform Team(terraform@alibabacloud.com)

License
----
Apache 2 Licensed. See LICENSE for full details.

Reference
---------
* [Terraform-Provider-Alicloud Github](https://github.com/terraform-providers/terraform-provider-alicloud)
* [Terraform-Provider-Alicloud Release](https://releases.hashicorp.com/terraform-provider-alicloud/)
* [Terraform-Provider-Alicloud Docs](https://www.terraform.io/docs/providers/alicloud/index.html)
21 changes: 21 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module "fnf" {
source = "../.."
# alicloud_fnf_flow
create_flow = true
flow_type = var.flow_type
flow_name = "flow_name"
flow_description = var.flow_description
definition = var.definition

#alicloud_fnf_schedule
create_schedule = true
cron_expression = var.cron_expression
schedule_name = "module_schedule_name"
payload = var.payload
schedule_description = var.schedule_description

# alicloud_fnf_execution
create_execution = true
execution_name = "module_execution_name"
input = jsonencode({ "wait" = 10 })
}
47 changes: 47 additions & 0 deletions examples/complete/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
variable "flow_type" {
type = string
description = "The type of the flow. Valid values are FDL or DEFAULT."
default = "FDL"
}

variable "flow_description" {
type = string
description = "The description of the flow."
default = "flow_description_test"
}

variable "definition" {
type = string
description = "The definition of the flow. It must comply with the Flow Definition Language (FDL) syntax."
default = "version: v1beta1\ntype: flow\nsteps:\n - type: pass\n name: helloworld"
}



variable "cron_expression" {
type = string
description = "The CRON expression of the time-based schedule to be created."
default = "30 9 * * * *"
}


variable "payload" {
type = string
description = "The trigger message of the time-based schedule to be created. It must be in JSON object format."
default = "{\"tf-testchange\": \"test success\"}"
}


variable "schedule_description" {
type = string
description = "The description of the time-based schedule to be created."
default = "module_schedule_description"
}

variable "config_rule_ids" {
type = list(object({
config_rule_id = string
}))
description = ""
default = []
}
30 changes: 30 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
locals {
flow_name = var.flow_name != "" ? var.flow_name : concat(alicloud_fnf_flow.flow.*.name, [""])[0]
}


resource "alicloud_fnf_flow" "flow" {
count = var.create_flow ? 1 : 0
definition = var.definition
description = var.flow_description
name = var.flow_name
type = var.flow_type
}

resource "alicloud_fnf_execution" "execution" {
count = var.create_execution ? 1 : 0
execution_name = var.execution_name
flow_name = local.flow_name
input = var.input
status = var.execution_status
}

resource "alicloud_fnf_schedule" "schedule" {
count = var.create_schedule ? 1 : 0
cron_expression = var.cron_expression
flow_name = local.flow_name
schedule_name = var.schedule_name
description = var.schedule_description
payload = var.payload
enable = var.schedule_enable
}
16 changes: 16 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
output "flow_id" {
description = "The Flow ID"
value = concat(alicloud_fnf_flow.flow.*.id, [""])[0]
}

output "execution_id" {
description = "The Execution ID"
value = concat(alicloud_fnf_execution.execution.*.id, [""])[0]
}

output "alicloud_fnf_schedule" {
description = "The Schedule ID"
value = concat(alicloud_fnf_schedule.schedule.*.id, [""])[0]
}


102 changes: 102 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
variable "create_flow" {
type = bool
description = "Whether to create the alicloud_fnf_flow"
default = false
}

variable "create_execution" {
type = bool
description = "Whether to create the alicloud_fnf_execution"
default = false
}

variable "create_schedule" {
type = bool
description = "Whether to create the alicloud_fnf_schedule"
default = false
}

#alicloud_fnf_flow
variable "definition" {
type = string
description = "The definition of the flow. It must comply with the Flow Definition Language (FDL) syntax."
default = ""
}

variable "flow_description" {
type = string
description = "The description of the flow."
default = ""
}

variable "flow_name" {
type = string
description = "The name of the flow. The name must be unique in an Alibaba Cloud account."
default = ""
}

variable "flow_type" {
type = string
description = "The type of the flow. Valid values are FDL or DEFAULT."
default = "DEFAULT"
}

variable "role_arn" {
type = string
description = "The ARN of the specified RAM role that Serverless Workflow uses to assume the role when Serverless Workflow executes a flow."
default = ""
}

#alicloud_fnf_execution

variable "execution_name" {
type = string
description = "The name of the execution."
default = ""
}

variable "input" {
type = string
description = "The Input information for this execution."
default = ""
}

variable "execution_status" {
type = string
description = "TThe status of the resource. Valid values: `Stopped`"
default = null
}


#alicloud_fnf_schedule
variable "cron_expression" {
type = string
description = "The CRON expression of the time-based schedule to be created."
default = ""
}

variable "schedule_name" {
type = string
description = "The name of the time-based schedule to be created."
default = ""
}

variable "schedule_description" {
type = string
description = "The description of the time-based schedule to be created."
default = ""
}

variable "schedule_enable" {
type = bool
description = "Specifies whether to enable the time-based schedule you want to create. Valid values: false, true."
default = null
}

variable "payload" {
type = string
description = "The trigger message of the time-based schedule to be created. It must be in JSON object format."
default = ""
}