File tree Expand file tree Collapse file tree 2 files changed +50
-1
lines changed
Expand file tree Collapse file tree 2 files changed +50
-1
lines changed Original file line number Diff line number Diff line change 1+ import { ActionContext , FunctionDomain } from '../../types' ;
2+
3+ const fgsApplication = ( context : ActionContext , service : string ) => `
4+ resource "huaweicloud_fgs_application" "${ service } _app" {
5+ name = "${ service } -app"
6+ description = "${ service } application"
7+ package_type = "event"
8+ }
9+ ` ;
10+
11+ const fgsFunction = ( fn : FunctionDomain , context : ActionContext , service : string ) => `
12+ resource "huaweicloud_fgs_function" "${ fn . key } " {
13+ function_name = "${ fn . name } "
14+ handler = "${ fn . handler } "
15+ runtime = "${ fn . runtime } "
16+ memory_size = ${ fn . memory }
17+ timeout = ${ fn . timeout }
18+ environment = ${ JSON . stringify ( fn . environment ) }
19+ code = {
20+ package_type = "inline"
21+ code = <<EOF
22+ ${ fn . code }
23+ EOF
24+ }
25+ application = huaweicloud_fgs_application.${ service } _app.id
26+
27+ }
28+ ` ;
29+
30+ export const resolveFunction = (
31+ functions : Array < FunctionDomain > | undefined ,
32+ context : ActionContext ,
33+ service : string ,
34+ ) => {
35+ if ( ! functions ) {
36+ return undefined ;
37+ }
38+ const app = fgsApplication ( context , service ) ;
39+
40+ return app + '\n' + functions . map ( ( fn ) => fgsFunction ( fn , context , service ) ) . join ( '\n' ) ;
41+ } ;
Original file line number Diff line number Diff line change 11import { ActionContext , ServerlessIac } from '../../types' ;
22
33const provider = ( context : ActionContext ) => `
4+ terraform {
5+ required_providers {
6+ huaweicloud = {
7+ source = "huaweicloud/huaweicloud"
8+ version = ">= 1.71.2"
9+ }
10+ }
11+ }
12+
413provider "huaweicloud" {
5- version = ">= 1.36.0"
614 region = "${ context . region } "
715 access_key = "${ context . accessKeyId } "
816 secret_key = "${ context . accessKeySecret } "
You can’t perform that action at this time.
0 commit comments