Skip to content

Commit

Permalink
Merge pull request #316 from serverless-operations/feature/fixed_time…
Browse files Browse the repository at this point in the history
…out_alarm

fix: incorrect alarm time for ExecutionsTimedOut
  • Loading branch information
theburningmonk authored Feb 27, 2020
2 parents cf15702 + ac55d43 commit 726616c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ stepFunctions:
alarm: arn:aws:sns:us-east-1:1234567890:NotifyMe
insufficientData: arn:aws:sns:us-east-1:1234567890:NotifyMe
metrics:
- executionsTimeOut
- executionsTimedOut
- executionsFailed
- executionsAborted
- metric: executionThrottled
Expand Down Expand Up @@ -235,7 +235,7 @@ stepFunctions:
alarm: arn:aws:sns:us-east-1:1234567890:NotifyMe
insufficientData: arn:aws:sns:us-east-1:1234567890:NotifyMe
metrics:
- executionsTimeOut
- executionsTimedOut
- executionsFailed
- executionsAborted
- executionThrottled
Expand All @@ -257,7 +257,7 @@ The generated CloudWatch alarms would have the following configurations:

```yaml
namespace: 'AWS/States'
metric: <ExecutionsTimeOut | ExecutionsFailed | ExecutionsAborted | ExecutionThrottled>
metric: <ExecutionsTimedOut | ExecutionsFailed | ExecutionsAborted | ExecutionThrottled>
threshold: 1
period: 60
evaluationPeriods: 1
Expand All @@ -278,7 +278,7 @@ alarms:
alarm: arn:aws:sns:us-east-1:1234567890:NotifyMe
insufficientData: arn:aws:sns:us-east-1:1234567890:NotifyMe
metrics:
- executionsTimeOut
- executionsTimedOut
- executionsFailed
- executionsAborted
- metric: executionThrottled
Expand Down Expand Up @@ -1079,7 +1079,7 @@ stepFunctions:
definition:
```

It is also possible to use the [CloudFormation intrinsic functions](https://docs.aws.amazon.com/en_en/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html) to reference resources from elsewhere. This allows for an IAM role to be created, and applied to the state machines all within the serverless file.
It is also possible to use the [CloudFormation intrinsic functions](https://docs.aws.amazon.com/en_en/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html) to reference resources from elsewhere. This allows for an IAM role to be created, and applied to the state machines all within the serverless file.

The below example shows the policy needed if your step function needs the ability to send a message to an sqs queue. To apply the role either the RoleName can be used as a reference in the state machine, or the role ARN can be used like in the example above. It is important to note that if you want to store your state machine role at a certain path, this must be specified on the `Path` property on the new role.

Expand Down
4 changes: 2 additions & 2 deletions lib/deploy/stepFunctions/compileAlarms.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ const Joi = require('@hapi/joi');
const schema = require('./compileAlarms.schema');

const cloudWatchMetricNames = {
executionsTimeOut: 'ExecutionsTimeOut',
executionsTimedOut: 'ExecutionsTimedOut',
executionsFailed: 'ExecutionsFailed',
executionsAborted: 'ExecutionsAborted',
executionThrottled: 'ExecutionThrottled',
};

const alarmDescriptions = {
executionsTimeOut: 'executions timed out',
executionsTimedOut: 'executions timed out',
executionsFailed: 'executions failed',
executionsAborted: 'executions were aborted',
executionThrottled: 'execution were throttled',
Expand Down
2 changes: 1 addition & 1 deletion lib/deploy/stepFunctions/compileAlarms.schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const treatMissingData = Joi.string()
.default('missing');

const simpleMetric = Joi.string()
.allow('executionsTimeOut', 'executionsFailed', 'executionsAborted', 'executionThrottled');
.allow('executionsTimedOut', 'executionsFailed', 'executionsAborted', 'executionThrottled');

const complexMetric = Joi.object().keys({
metric: simpleMetric.required(),
Expand Down
26 changes: 13 additions & 13 deletions lib/deploy/stepFunctions/compileAlarms.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('#compileAlarms', () => {
insufficientData: '${self:service}-${opt:stage}-alerts-missing',
},
metrics: [
'executionsTimeOut',
'executionsTimedOut',
'executionsFailed',
'executionsAborted',
'executionThrottled',
Expand All @@ -74,16 +74,16 @@ describe('#compileAlarms', () => {
serverlessStepFunctions.compileAlarms();
const resources = serverlessStepFunctions.serverless.service
.provider.compiledCloudFormationTemplate.Resources;
expect(resources).to.have.property('StateMachineBeta1ExecutionsTimeOutAlarm');
validateCloudWatchAlarm(resources.StateMachineBeta1ExecutionsTimeOutAlarm);
expect(resources).to.have.property('StateMachineBeta1ExecutionsTimedOutAlarm');
validateCloudWatchAlarm(resources.StateMachineBeta1ExecutionsTimedOutAlarm);
expect(resources).to.have.property('StateMachineBeta1ExecutionsFailedAlarm');
validateCloudWatchAlarm(resources.StateMachineBeta1ExecutionsFailedAlarm);
expect(resources).to.have.property('StateMachineBeta1ExecutionsAbortedAlarm');
validateCloudWatchAlarm(resources.StateMachineBeta1ExecutionsAbortedAlarm);
expect(resources).to.have.property('StateMachineBeta1ExecutionThrottledAlarm');
validateCloudWatchAlarm(resources.StateMachineBeta1ExecutionThrottledAlarm);
expect(resources).to.have.property('StateMachineBeta2ExecutionsTimeOutAlarm');
validateCloudWatchAlarm(resources.StateMachineBeta2ExecutionsTimeOutAlarm);
expect(resources).to.have.property('StateMachineBeta2ExecutionsTimedOutAlarm');
validateCloudWatchAlarm(resources.StateMachineBeta2ExecutionsTimedOutAlarm);
expect(resources).to.have.property('StateMachineBeta2ExecutionsFailedAlarm');
validateCloudWatchAlarm(resources.StateMachineBeta2ExecutionsFailedAlarm);
expect(resources).to.have.property('StateMachineBeta2ExecutionsAbortedAlarm');
Expand Down Expand Up @@ -137,7 +137,7 @@ describe('#compileAlarms', () => {
},
alarms: {
metrics: [
'executionsTimeOut',
'executionsTimedOut',
],
},
});
Expand Down Expand Up @@ -172,7 +172,7 @@ describe('#compileAlarms', () => {
alarms: {
topics: {},
metrics: [
'executionsTimeOut',
'executionsTimedOut',
],
},
});
Expand Down Expand Up @@ -288,7 +288,7 @@ describe('#compileAlarms', () => {
insufficientData: '${self:service}-${opt:stage}-alerts-missing',
},
metrics: [
'executionsTimeOut',
'executionsTimedOut',
'executionsFailed',
'executionsAborted',
'executionThrottled',
Expand All @@ -313,11 +313,11 @@ describe('#compileAlarms', () => {
expect(resources[resourceName].Properties.TreatMissingData).to.equal('ignore');
};

verify('StateMachineBeta1ExecutionsTimeOutAlarm');
verify('StateMachineBeta1ExecutionsTimedOutAlarm');
verify('StateMachineBeta1ExecutionsFailedAlarm');
verify('StateMachineBeta1ExecutionsAbortedAlarm');
verify('StateMachineBeta1ExecutionThrottledAlarm');
verify('StateMachineBeta2ExecutionsTimeOutAlarm');
verify('StateMachineBeta2ExecutionsTimedOutAlarm');
verify('StateMachineBeta2ExecutionsFailedAlarm');
verify('StateMachineBeta2ExecutionsAbortedAlarm');
verify('StateMachineBeta2ExecutionThrottledAlarm');
Expand All @@ -344,7 +344,7 @@ describe('#compileAlarms', () => {
insufficientData: '${self:service}-${opt:stage}-alerts-missing',
},
metrics: [
'executionsTimeOut',
'executionsTimedOut',
{ metric: 'executionsFailed', treatMissingData: 'breaching' },
'executionsAborted',
'executionThrottled',
Expand All @@ -369,11 +369,11 @@ describe('#compileAlarms', () => {
expect(resources[resourceName].Properties.TreatMissingData).to.equal(expectedConfig);
};

verify('StateMachineBeta1ExecutionsTimeOutAlarm');
verify('StateMachineBeta1ExecutionsTimedOutAlarm');
verify('StateMachineBeta1ExecutionsFailedAlarm', 'breaching');
verify('StateMachineBeta1ExecutionsAbortedAlarm');
verify('StateMachineBeta1ExecutionThrottledAlarm');
verify('StateMachineBeta2ExecutionsTimeOutAlarm');
verify('StateMachineBeta2ExecutionsTimedOutAlarm');
verify('StateMachineBeta2ExecutionsFailedAlarm', 'breaching');
verify('StateMachineBeta2ExecutionsAbortedAlarm');
verify('StateMachineBeta2ExecutionThrottledAlarm');
Expand Down

0 comments on commit 726616c

Please sign in to comment.