Skip to content

Commit

Permalink
implement suggested changes from reviewer
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardomourar committed Jun 8, 2020
1 parent 77988c6 commit d686dc8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
7 changes: 6 additions & 1 deletion packages/@aws-cdk/aws-eks/lib/helm-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ export class HelmChart extends Construct {

const provider = props.cluster._kubectlProvider;

const timeout = props.timeout?.toSeconds();
if (timeout && timeout > 900) {
throw new Error('Helm chart timeout cannot be higher than 15 minutes.');
}

new CustomResource(this, 'Resource', {
serviceToken: provider.serviceToken,
resourceType: HelmChart.RESOURCE_TYPE,
Expand All @@ -95,7 +100,7 @@ export class HelmChart extends Construct {
Chart: props.chart,
Version: props.version,
Wait: props.wait || false,
Timeout: props.timeout && props.timeout.toSeconds(),
Timeout: timeout,
Values: (props.values ? stack.toJsonString(props.values) : undefined),
Namespace: props.namespace || 'default',
Repository: props.repository,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
/* istanbul ignore file */
// eslint-disable-next-line import/no-extraneous-dependencies
import * as AWS from 'aws-sdk';
// eslint-disable-next-line import/no-extraneous-dependencies
import { ConfigurationOptions } from 'aws-sdk/lib/config';
import * as https from 'https';
import * as consts from './consts';

// In order to honor the overall maximum timeout set for the target process,
// the default 2 minutes from AWS SDK has to be overriden:
// https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#httpOptions-property
const awsSdkConfig: ConfigurationOptions = {
httpOptions: { timeout: consts.FRAMEWORK_HANDLER_TIMEOUT },
};

async function defaultHttpRequest(options: https.RequestOptions, responseBody: string) {
return new Promise((resolve, reject) => {
try {
Expand All @@ -22,21 +31,17 @@ let lambda: AWS.Lambda;

async function defaultStartExecution(req: AWS.StepFunctions.StartExecutionInput): Promise<AWS.StepFunctions.StartExecutionOutput> {
if (!sfn) {
sfn = new AWS.StepFunctions();
sfn = new AWS.StepFunctions(awsSdkConfig);
}

sfn.config.update({httpOptions: { timeout: consts.FRAMEWORK_HANDLER_TIMEOUT }});

return await sfn.startExecution(req).promise();
}

async function defaultInvokeFunction(req: AWS.Lambda.InvocationRequest): Promise<AWS.Lambda.InvocationResponse> {
if (!lambda) {
lambda = new AWS.Lambda();
lambda = new AWS.Lambda(awsSdkConfig);
}

lambda.config.update({httpOptions: { timeout: consts.FRAMEWORK_HANDLER_TIMEOUT }});

return await lambda.invoke(req).promise();
}

Expand Down

0 comments on commit d686dc8

Please sign in to comment.