Skip to content

Commit b7cacb7

Browse files
Merge pull request #204 from horike37/feature/fix_incorrect_ref_match
fix: match for Ref explicitly
2 parents 72a1bcc + c0de94d commit b7cacb7

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

lib/deploy/stepFunctions/compileStateMachines.test.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,4 +742,45 @@ describe('#compileStateMachines', () => {
742742

743743
expect(stateMachine.Properties.DefinitionString).to.not.equal(null);
744744
});
745+
746+
it('should not interpret states starting with "Ref" as intrinsic functions #203', () => {
747+
serverless.service.stepFunctions = {
748+
stateMachines: {
749+
myStateMachine1: {
750+
id: 'Test',
751+
name: 'test',
752+
definition: {
753+
StartAt: 'One',
754+
States: {
755+
One: {
756+
Type: 'Wait',
757+
Seconds: 10,
758+
Next: 'RefreshLead',
759+
},
760+
RefreshLead: {
761+
Type: 'Task',
762+
Resource: 'arn:aws:lambda:us-east-1:12345:function:test-dev-lambda',
763+
TimeoutSeconds: 60,
764+
Next: 'EndState',
765+
},
766+
EndState: {
767+
Type: 'Succeed',
768+
},
769+
},
770+
},
771+
},
772+
},
773+
};
774+
775+
serverlessStepFunctions.compileStateMachines();
776+
const stateMachine = serverlessStepFunctions.serverless.service
777+
.provider.compiledCloudFormationTemplate.Resources
778+
.Test;
779+
780+
expect(stateMachine.Properties.DefinitionString).to.not.haveOwnProperty('Fn::Sub');
781+
const stateMachineObj = JSON.parse(stateMachine.Properties.DefinitionString);
782+
expect(stateMachineObj.States).to.haveOwnProperty('One');
783+
expect(stateMachineObj.States).to.haveOwnProperty('RefreshLead');
784+
expect(stateMachineObj.States).to.haveOwnProperty('EndState');
785+
});
745786
});

lib/utils/aws.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const _ = require('lodash');
22

33
function isIntrinsic(obj) {
44
return _.isObjectLike(obj) &&
5-
Object.keys(obj).some((k) => k.startsWith('Fn::') || k.startsWith('Ref'));
5+
Object.keys(obj).some((k) => k.startsWith('Fn::') || k === 'Ref');
66
}
77

88
module.exports = {

0 commit comments

Comments
 (0)