Skip to content

Commit

Permalink
fix(aws-cloudformation): move AwsSdkCall inside custom resource provider
Browse files Browse the repository at this point in the history
  • Loading branch information
julienlepine committed Jun 13, 2019
1 parent 6e60018 commit dcadcc0
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 62 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* An AWS SDK call.
*/
export interface AwsSdkCall {
/**
* The service to call
*
* @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/index.html
*/
readonly service: string;

/**
* The service action to call
*
* @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/index.html
*/
readonly action: string;

/**
* The parameters for the service action
*
* @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/index.html
*/
readonly parameters?: any;

/**
* The path to the data in the API call response to use as the physical
* resource id. Either `physicalResourceId` or `physicalResourceIdPath`
* must be specified for onCreate or onUpdate calls.
*
* @default no path
*/
readonly physicalResourceIdPath?: string;

/**
* The physical resource id of the custom resource for this call. Either
* `physicalResourceId` or `physicalResourceIdPath` must be specified for
* onCreate or onUpdate calls.
*
* @default no physical resource id
*/
readonly physicalResourceId?: string;

/**
* The regex pattern to use to catch API errors. The `code` property of the
* `Error` object will be tested against this pattern. If there is a match an
* error will not be thrown.
*
* @default do not catch errors
*/
readonly catchErrorPattern?: string;

/**
* API version to use for the service
*
* @see https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/locking-api-versions.html
* @default use latest available API version
*/
readonly apiVersion?: string;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// tslint:disable:no-console
import AWS = require('aws-sdk');
import { AwsSdkCall } from '../aws-custom-resource';
import { AwsSdkCall } from './aws-sdk-call';

/**
* Flattens a nested object
Expand Down
62 changes: 1 addition & 61 deletions packages/@aws-cdk/aws-cloudformation/lib/aws-custom-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import lambda = require('@aws-cdk/aws-lambda');
import cdk = require('@aws-cdk/cdk');
import metadata = require('aws-sdk/apis/metadata.json');
import path = require('path');
import { AwsSdkCall } from './aws-custom-resource-provider/aws-sdk-call';
import { CustomResource, CustomResourceProvider } from './custom-resource';

/**
Expand All @@ -12,67 +13,6 @@ export type AwsSdkMetadata = {[key: string]: any};

const awsSdkMetadata: AwsSdkMetadata = metadata;

/**
* An AWS SDK call.
*/
export interface AwsSdkCall {
/**
* The service to call
*
* @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/index.html
*/
readonly service: string;

/**
* The service action to call
*
* @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/index.html
*/
readonly action: string;

/**
* The parameters for the service action
*
* @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/index.html
*/
readonly parameters?: any;

/**
* The path to the data in the API call response to use as the physical
* resource id. Either `physicalResourceId` or `physicalResourceIdPath`
* must be specified for onCreate or onUpdate calls.
*
* @default no path
*/
readonly physicalResourceIdPath?: string;

/**
* The physical resource id of the custom resource for this call. Either
* `physicalResourceId` or `physicalResourceIdPath` must be specified for
* onCreate or onUpdate calls.
*
* @default no physical resource id
*/
readonly physicalResourceId?: string;

/**
* The regex pattern to use to catch API errors. The `code` property of the
* `Error` object will be tested against this pattern. If there is a match an
* error will not be thrown.
*
* @default do not catch errors
*/
readonly catchErrorPattern?: string;

/**
* API version to use for the service
*
* @see https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/locking-api-versions.html
* @default use latest available API version
*/
readonly apiVersion?: string;
}

export interface AwsCustomResourceProps {
/**
* The AWS SDK call to make when the resource is created.
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-cloudformation/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './cloud-formation-capabilities';
export * from './custom-resource';
export * from './aws-custom-resource';
export * from './aws-custom-resource-provider/aws-sdk-call';

// AWS::CloudFormation CloudFormation Resources:
export * from './cloudformation.generated';

0 comments on commit dcadcc0

Please sign in to comment.