@@ -4,14 +4,14 @@ import { ActionContext, EventTypes, ServerlessIac } from '../types';
4
4
import * as fc from '@alicloud/ros-cdk-fc3' ;
5
5
import * as ram from '@alicloud/ros-cdk-ram' ;
6
6
import * as agw from '@alicloud/ros-cdk-apigateway' ;
7
- import { replaceVars , resolveCode } from '../common' ;
7
+ import { replaceReference , resolveCode } from '../common' ;
8
8
9
9
export class IacStack extends ros . Stack {
10
10
constructor ( scope : ros . Construct , iac : ServerlessIac , context : ActionContext ) {
11
11
super ( scope , iac . service , {
12
12
stackName : context . stackName ,
13
13
tags : iac . tags . reduce ( ( acc : { [ key : string ] : string } , tag ) => {
14
- acc [ tag . key ] = replaceVars ( tag . value , context . stage ) ;
14
+ acc [ tag . key ] = replaceReference ( tag . value , context . stage ) ;
15
15
return acc ;
16
16
} , { } ) ,
17
17
} ) ;
@@ -26,25 +26,25 @@ export class IacStack extends ros.Stack {
26
26
) ;
27
27
28
28
// Define Mappings
29
- new ros . RosMapping ( this , 'stages' , { mapping : replaceVars ( iac . stages , context . stage ) } ) ;
29
+ new ros . RosMapping ( this , 'stages' , { mapping : replaceReference ( iac . stages , context . stage ) } ) ;
30
30
31
31
new ros . RosInfo (
32
32
this ,
33
33
ros . RosInfo . description ,
34
- replaceVars ( `${ iac . service } stack` , context . stage ) ,
34
+ replaceReference ( `${ iac . service } stack` , context . stage ) ,
35
35
) ;
36
36
37
37
iac . functions . forEach ( ( fnc ) => {
38
38
new fc . RosFunction (
39
39
this ,
40
40
fnc . key ,
41
41
{
42
- functionName : replaceVars ( fnc . name , context . stage ) ,
43
- handler : replaceVars ( fnc . handler , context . stage ) ,
44
- runtime : replaceVars ( fnc . runtime , context . stage ) ,
45
- memorySize : replaceVars ( fnc . memory , context . stage ) ,
46
- timeout : replaceVars ( fnc . timeout , context . stage ) ,
47
- environmentVariables : replaceVars ( fnc . environment , context . stage ) ,
42
+ functionName : replaceReference ( fnc . name , context . stage ) ,
43
+ handler : replaceReference ( fnc . handler , context . stage ) ,
44
+ runtime : replaceReference ( fnc . runtime , context . stage ) ,
45
+ memorySize : replaceReference ( fnc . memory , context . stage ) ,
46
+ timeout : replaceReference ( fnc . timeout , context . stage ) ,
47
+ environmentVariables : replaceReference ( fnc . environment , context . stage ) ,
48
48
code : {
49
49
zipFile : resolveCode ( fnc . code ) ,
50
50
} ,
@@ -57,10 +57,10 @@ export class IacStack extends ros.Stack {
57
57
if ( apiGateway ?. length ) {
58
58
const gatewayAccessRole = new ram . RosRole (
59
59
this ,
60
- replaceVars ( `${ iac . service } _role` , context . stage ) ,
60
+ replaceReference ( `${ iac . service } _role` , context . stage ) ,
61
61
{
62
- roleName : replaceVars ( `${ iac . service } -gateway-access-role` , context . stage ) ,
63
- description : replaceVars ( `${ iac . service } role` , context . stage ) ,
62
+ roleName : replaceReference ( `${ iac . service } -gateway-access-role` , context . stage ) ,
63
+ description : replaceReference ( `${ iac . service } role` , context . stage ) ,
64
64
assumeRolePolicyDocument : {
65
65
version : '1' ,
66
66
statement : [
@@ -75,7 +75,7 @@ export class IacStack extends ros.Stack {
75
75
} ,
76
76
policies : [
77
77
{
78
- policyName : replaceVars ( `${ iac . service } -policy` , context . stage ) ,
78
+ policyName : replaceReference ( `${ iac . service } -policy` , context . stage ) ,
79
79
policyDocument : {
80
80
version : '1' ,
81
81
statement : [
@@ -95,10 +95,10 @@ export class IacStack extends ros.Stack {
95
95
96
96
const apiGatewayGroup = new agw . RosGroup (
97
97
this ,
98
- replaceVars ( `${ iac . service } _apigroup` , context . stage ) ,
98
+ replaceReference ( `${ iac . service } _apigroup` , context . stage ) ,
99
99
{
100
- groupName : replaceVars ( `${ iac . service } _apigroup` , context . stage ) ,
101
- tags : replaceVars ( iac . tags , context . stage ) ,
100
+ groupName : replaceReference ( `${ iac . service } _apigroup` , context . stage ) ,
101
+ tags : replaceReference ( iac . tags , context . stage ) ,
102
102
} ,
103
103
true ,
104
104
) ;
@@ -122,29 +122,29 @@ export class IacStack extends ros.Stack {
122
122
123
123
const api = new agw . RosApi (
124
124
this ,
125
- replaceVars ( `${ event . key } _api_${ key } ` , context . stage ) ,
125
+ replaceReference ( `${ event . key } _api_${ key } ` , context . stage ) ,
126
126
{
127
- apiName : replaceVars ( `${ event . name } _api_${ key } ` , context . stage ) ,
127
+ apiName : replaceReference ( `${ event . name } _api_${ key } ` , context . stage ) ,
128
128
groupId : apiGatewayGroup . attrGroupId ,
129
129
visibility : 'PRIVATE' ,
130
130
requestConfig : {
131
131
requestProtocol : 'HTTP' ,
132
- requestHttpMethod : replaceVars ( trigger . method , context . stage ) ,
133
- requestPath : replaceVars ( trigger . path , context . stage ) ,
132
+ requestHttpMethod : replaceReference ( trigger . method , context . stage ) ,
133
+ requestPath : replaceReference ( trigger . path , context . stage ) ,
134
134
requestMode : 'PASSTHROUGH' ,
135
135
} ,
136
136
serviceConfig : {
137
137
serviceProtocol : 'FunctionCompute' ,
138
138
functionComputeConfig : {
139
139
fcRegionId : context . region ,
140
- functionName : trigger . backend ,
140
+ functionName : replaceReference ( trigger . backend , trigger . backend ) ,
141
141
roleArn : gatewayAccessRole . attrArn ,
142
142
fcVersion : '3.0' ,
143
143
} ,
144
144
} ,
145
145
resultSample : 'ServerlessInsight resultSample' ,
146
146
resultType : 'JSON' ,
147
- tags : replaceVars ( iac . tags , context . stage ) ,
147
+ tags : replaceReference ( iac . tags , context . stage ) ,
148
148
} ,
149
149
true ,
150
150
) ;
0 commit comments