@@ -4,14 +4,14 @@ import { ActionContext, EventTypes, ServerlessIac } from '../types';
44import * as fc from '@alicloud/ros-cdk-fc3' ;
55import * as ram from '@alicloud/ros-cdk-ram' ;
66import * as agw from '@alicloud/ros-cdk-apigateway' ;
7- import { replaceVars , resolveCode } from '../common' ;
7+ import { replaceReference , resolveCode } from '../common' ;
88
99export class IacStack extends ros . Stack {
1010 constructor ( scope : ros . Construct , iac : ServerlessIac , context : ActionContext ) {
1111 super ( scope , iac . service , {
1212 stackName : context . stackName ,
1313 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 ) ;
1515 return acc ;
1616 } , { } ) ,
1717 } ) ;
@@ -26,25 +26,25 @@ export class IacStack extends ros.Stack {
2626 ) ;
2727
2828 // 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 ) } ) ;
3030
3131 new ros . RosInfo (
3232 this ,
3333 ros . RosInfo . description ,
34- replaceVars ( `${ iac . service } stack` , context . stage ) ,
34+ replaceReference ( `${ iac . service } stack` , context . stage ) ,
3535 ) ;
3636
3737 iac . functions . forEach ( ( fnc ) => {
3838 new fc . RosFunction (
3939 this ,
4040 fnc . key ,
4141 {
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 ) ,
4848 code : {
4949 zipFile : resolveCode ( fnc . code ) ,
5050 } ,
@@ -57,10 +57,10 @@ export class IacStack extends ros.Stack {
5757 if ( apiGateway ?. length ) {
5858 const gatewayAccessRole = new ram . RosRole (
5959 this ,
60- replaceVars ( `${ iac . service } _role` , context . stage ) ,
60+ replaceReference ( `${ iac . service } _role` , context . stage ) ,
6161 {
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 ) ,
6464 assumeRolePolicyDocument : {
6565 version : '1' ,
6666 statement : [
@@ -75,7 +75,7 @@ export class IacStack extends ros.Stack {
7575 } ,
7676 policies : [
7777 {
78- policyName : replaceVars ( `${ iac . service } -policy` , context . stage ) ,
78+ policyName : replaceReference ( `${ iac . service } -policy` , context . stage ) ,
7979 policyDocument : {
8080 version : '1' ,
8181 statement : [
@@ -95,10 +95,10 @@ export class IacStack extends ros.Stack {
9595
9696 const apiGatewayGroup = new agw . RosGroup (
9797 this ,
98- replaceVars ( `${ iac . service } _apigroup` , context . stage ) ,
98+ replaceReference ( `${ iac . service } _apigroup` , context . stage ) ,
9999 {
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 ) ,
102102 } ,
103103 true ,
104104 ) ;
@@ -122,29 +122,29 @@ export class IacStack extends ros.Stack {
122122
123123 const api = new agw . RosApi (
124124 this ,
125- replaceVars ( `${ event . key } _api_${ key } ` , context . stage ) ,
125+ replaceReference ( `${ event . key } _api_${ key } ` , context . stage ) ,
126126 {
127- apiName : replaceVars ( `${ event . name } _api_${ key } ` , context . stage ) ,
127+ apiName : replaceReference ( `${ event . name } _api_${ key } ` , context . stage ) ,
128128 groupId : apiGatewayGroup . attrGroupId ,
129129 visibility : 'PRIVATE' ,
130130 requestConfig : {
131131 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 ) ,
134134 requestMode : 'PASSTHROUGH' ,
135135 } ,
136136 serviceConfig : {
137137 serviceProtocol : 'FunctionCompute' ,
138138 functionComputeConfig : {
139139 fcRegionId : context . region ,
140- functionName : trigger . backend ,
140+ functionName : replaceReference ( trigger . backend , trigger . backend ) ,
141141 roleArn : gatewayAccessRole . attrArn ,
142142 fcVersion : '3.0' ,
143143 } ,
144144 } ,
145145 resultSample : 'ServerlessInsight resultSample' ,
146146 resultType : 'JSON' ,
147- tags : replaceVars ( iac . tags , context . stage ) ,
147+ tags : replaceReference ( iac . tags , context . stage ) ,
148148 } ,
149149 true ,
150150 ) ;
0 commit comments