This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jest.mock('aws-sdk', () => { | |
return { | |
SSM: jest.fn(() => ({ | |
getParameter: jest.fn(() => ({ | |
promise: jest.fn().mockResolvedValue({ Parameter: { Value: 'SECRET-KEY' } }), | |
})), | |
})), | |
SQS: jest.fn(() => ({})), | |
S3: jest.fn(() => ({})), | |
SNS: jest.fn(() => ({})), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('Run method', () => { | |
const event: CloudWatchLogsEvent = { | |
awslogs: { | |
data: '', | |
}, | |
} | |
it('should confirm shipments where emitted', async () => { | |
expect.assertions(2) | |
await service.run(event) | |
expect(sendBatchJSONMessages).toHaveBeenCalledTimes(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { soap } from "strong-soap" | |
abstract class OrderDynamicsClient { | |
protected isAuthenticated: Boolean = false | |
protected soapClient: any | |
protected url: any | |
abstract authenticate(): Promise<void> | |
createClient(options: any) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
DOCKER_IMAGE=node:12.18.0 | |
docker kill lamda-builder 2>/dev/null | |
docker rm lamda-builder 2>/dev/null | |
rm -rf build && rm -rf dist | |
mkdir -p build && mkdir -p ../dist | |
cp -r index.js package.json yarn.lock src deps build 2>/dev/null || : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: "2010-09-09" | |
Description: Budget alerts for various AWS services | |
Parameters: | |
Environment: | |
Type: String | |
Description: Deployment environment for the budget checks | |
GlueDevEndpointDPUHours: | |
Type: Number | |
Description: Number of Glue dev endpoint DPU hours we budget for in the period |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: "2010-09-09" | |
Description: CloudFormation for creating Python Glue Jobs and schedule it's execution | |
Parameters: | |
ServiceName: | |
Type: String | |
Description: Name of the service | |
ArtifactBucket: | |
Type: String | |
Description: A bucket to get artefacts from |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import random | |
loop = asyncio.get_event_loop() | |
async def execute_task(): | |
time_out = random.uniform(0.5, 5) | |
print("Starting {:1.2f}..".format(time_out)) | |
await asyncio.sleep(time_out) | |
print("Stoping {:1.2f}..".format(time_out)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Description: | | |
AWS CloudFormation template for Mock WebSocket API Gateway. When deploying this stack please remember to check the option: | |
- I acknowledge that AWS CloudFormation might create IAM resources. | |
This template can help you to solve issues like: | |
- CloudWatch Logs role ARN must be set in account settings to enable logging | |
- Execution failed due to configuration error: statusCode should be an integer which defined in request template | |
- This custom domain name cannot map to WEBSOCKET protocol APIs | |
- Error during WebSocket handshake: Unexpected response code: 500 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Javascript Promises Timeout | |
// | |
// A way to implement timeouts in jS promises using : | |
// - setTimeout(): | |
// sets up a function to be called after a specified delay in milliseconds. | |
// - Promise.race(): | |
// Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected. | |
// | |
// Run 'seq 10 | xargs -Iz node promise_timeout.js' on the command line to see the results flapping between 'Done' and 'TimeOut' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const BATCH_SIZE = 10 | |
const buildParamforSqsBatch = (products, queueUrl) => { | |
const entries = products.map(product => toOutputMessage(product)) | |
return { | |
Entries: entries, | |
QueueUrl: queueUrl | |
} | |
} | |
const emitUpdateEvent = (params) => { |