diff --git a/lib/src/wso2/wso2-api/handler/index.test.ts b/lib/src/wso2/wso2-api/handler/index.test.ts index 83f2646..5bbb40a 100644 --- a/lib/src/wso2/wso2-api/handler/index.test.ts +++ b/lib/src/wso2/wso2-api/handler/index.test.ts @@ -520,7 +520,11 @@ describe('wso2 custom resource lambda', () => { return { ...commonEvt, RequestType: 'Create', - ResourceProperties: { ...baseProperties, ServiceToken: 'arn:somelambdatest' }, + ResourceProperties: { + ...baseProperties, + ServiceToken: 'arn:somelambdatest', + disableDeployment: 'false', + }, }; }; const testCFNEventDelete = ( @@ -530,7 +534,11 @@ describe('wso2 custom resource lambda', () => { return { ...commonEvt, RequestType: 'Delete', - ResourceProperties: { ...baseProperties, ServiceToken: 'arn:somelambdatest' }, + ResourceProperties: { + ...baseProperties, + ServiceToken: 'arn:somelambdatest', + disableDeployment: 'false', + }, PhysicalResourceId, }; }; @@ -542,7 +550,11 @@ describe('wso2 custom resource lambda', () => { return { ...commonEvt, RequestType: 'Update', - ResourceProperties: { ...baseProperties, ServiceToken: 'arn:somelambdatest' }, + ResourceProperties: { + ...baseProperties, + ServiceToken: 'arn:somelambdatest', + disableDeployment: 'false', + }, PhysicalResourceId, OldResourceProperties: oldResourceProperties, }; diff --git a/lib/src/wso2/wso2-api/handler/index.ts b/lib/src/wso2/wso2-api/handler/index.ts index eaa5b21..7ed43c3 100644 --- a/lib/src/wso2/wso2-api/handler/index.ts +++ b/lib/src/wso2/wso2-api/handler/index.ts @@ -14,7 +14,9 @@ import { } from './wso2-v1'; export type Wso2ApiCustomResourceEvent = CdkCustomResourceEvent & { - ResourceProperties: Wso2ApiCustomResourceProperties; + ResourceProperties: Omit & { + disableDeployment: 'false' | 'true'; + }; }; export type Wso2ApiCustomResourceResponse = CdkCustomResourceResponse & { @@ -47,6 +49,12 @@ export const handler = async ( LogicalResourceId: event.LogicalResourceId, }; + if (event.ResourceProperties.disableDeployment === 'true') { + console.log(`>>> WSO2 API deployment disabled...`); + response.Status = 'SUCCESS'; + return response; + } + try { console.log('>>> Prepare WSO2 API client...'); const wso2Axios = await prepareAxiosForWso2Calls(event.ResourceProperties.wso2Config); diff --git a/lib/src/wso2/wso2-api/types.ts b/lib/src/wso2/wso2-api/types.ts index 93a6bfd..059d5fa 100644 --- a/lib/src/wso2/wso2-api/types.ts +++ b/lib/src/wso2/wso2-api/types.ts @@ -24,4 +24,8 @@ export type Wso2ApiProps = Wso2BaseProperties & { * as the workflow might take a long time to complete. */ lifecycleStatus?: 'CREATED' | 'PUBLISHED' | 'DEPRECATED' | 'BLOCKED' | 'RETIRED' | 'PROTOTYPED'; + /** + * Flag to either enable or disable deployment for the WSO2 API. + */ + disableDeployment?: boolean; }; diff --git a/lib/src/wso2/wso2-api/wso2-api.ts b/lib/src/wso2/wso2-api/wso2-api.ts index 7fa0523..e373a33 100644 --- a/lib/src/wso2/wso2-api/wso2-api.ts +++ b/lib/src/wso2/wso2-api/wso2-api.ts @@ -59,6 +59,7 @@ export class Wso2Api extends Construct { openapiDocument: props.openapiDocument, retryOptions: props.retryOptions, lifecycleStatus: props.lifecycleStatus, + disableDeployment: props.disableDeployment ?? false, } satisfies Wso2ApiCustomResourceProperties, resourceType: 'Custom::Wso2Api', removalPolicy: props.removalPolicy ?? RemovalPolicy.RETAIN,