Skip to content

Commit da5edab

Browse files
committed
feat: support x-ray
1 parent 4c6fb92 commit da5edab

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

lib/deploy/stepFunctions/compileStateMachines.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ module.exports = {
9999
let RoleArn;
100100
let DependsOn = [];
101101
let LoggingConfiguration;
102+
let TracingConfiguration;
102103
let Tags;
103104
if (stateMachineObj.inheritGlobalTags === false) {
104105
Tags = [];
@@ -204,6 +205,11 @@ module.exports = {
204205
};
205206
}
206207

208+
if (value.tracingConfig) {
209+
TracingConfiguration = {
210+
Enabled: value.tracingConfig.enabled,
211+
};
212+
}
207213

208214
const stateMachineOutputLogicalId = this
209215
.getStateMachineOutputLogicalId(stateMachineName, stateMachineObj);
@@ -215,6 +221,7 @@ module.exports = {
215221
RoleArn,
216222
StateMachineType: stateMachineObj.type,
217223
LoggingConfiguration,
224+
TracingConfiguration,
218225
},
219226
DependsOn,
220227
};

lib/deploy/stepFunctions/compileStateMachines.schema.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ const loggingConfig = Joi.object().keys({
3434
destinations: Joi.array().items(arn),
3535
});
3636

37+
const tracingConfig = Joi.object().keys({
38+
enabled: Joi.boolean().default(false),
39+
});
40+
3741
const id = Joi.string();
3842
const tags = Joi.object();
3943
const name = Joi.string();
@@ -58,6 +62,7 @@ const schema = Joi.object().keys({
5862
type,
5963
retain,
6064
loggingConfig,
65+
tracingConfig,
6166
inheritGlobalTags,
6267
});
6368

lib/deploy/stepFunctions/compileStateMachines.test.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,42 @@ describe('#compileStateMachines', () => {
14341434
});
14351435
});
14361436

1437+
it('should compile tracing configuration', () => {
1438+
serverless.service.stepFunctions = {
1439+
stateMachines: {
1440+
myStateMachine1: {
1441+
name: 'stateMachineBeta1',
1442+
tracingConfig: {
1443+
enabled: true,
1444+
},
1445+
definition: {
1446+
StartAt: 'A',
1447+
States: {
1448+
A: {
1449+
Type: 'Task',
1450+
Resource: 'arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:hello',
1451+
End: true,
1452+
},
1453+
},
1454+
},
1455+
},
1456+
},
1457+
};
1458+
1459+
serverlessStepFunctions.compileStateMachines();
1460+
const actual = serverlessStepFunctions
1461+
.serverless
1462+
.service
1463+
.provider
1464+
.compiledCloudFormationTemplate
1465+
.Resources
1466+
.StateMachineBeta1
1467+
.Properties;
1468+
1469+
expect(actual).to.haveOwnProperty('TracingConfiguration');
1470+
expect(actual.TracingConfiguration.Enabled).to.equal(true);
1471+
});
1472+
14371473
it('should output cloudformation outputs section', () => {
14381474
serverless.service.stepFunctions = {
14391475
stateMachines: {

0 commit comments

Comments
 (0)