Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(core): Add warnings about using core functions from outside of Solutions Constructs #917

Merged
merged 5 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deployment/v2/align-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const findVersion = process.argv[2];
const replaceVersion = process.argv[3];

// these versions need to be sourced from a config file
const awsCdkLibVersion = '2.67.0';
const awsCdkLibVersion = '2.68.0';
const constructsVersion = '10.0.0';
const MODULE_EXEMPTIONS = new Set([
'@aws-cdk/cloudformation-diff',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@
* and limitations under the License.
*/

/*
* The functions found here in the core library are for internal use and can be changed
* or removed outside of a major release. We recommend against calling them directly from client code.
*/

import * as elb from "aws-cdk-lib/aws-elasticloadbalancingv2";

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*/
export function DefaultListenerProps(loadBalancer: elb.ApplicationLoadBalancer): elb.ApplicationListenerProps {
return {
loadBalancer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
* and limitations under the License.
*/

/*
* The functions found here in the core library are for internal use and can be changed
* or removed outside of a major release. We recommend against calling them directly from client code.
*/

import * as elb from "aws-cdk-lib/aws-elasticloadbalancingv2";
import { Construct } from "constructs";
import * as ec2 from "aws-cdk-lib/aws-ec2";
Expand All @@ -24,8 +29,12 @@ import { DefaultListenerProps } from "./alb-defaults";
import { createAlbLoggingBucket } from "./s3-bucket-helper";
import { DefaultLoggingBucketProps } from "./s3-bucket-defaults";

// Returns the correct ALB Load Balancer to use in this construct, either an existing
// one provided as an argument or create new one otherwise.
/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*
* Returns the correct ALB Load Balancer to use in this construct, either an existing
* one provided as an argument or create new one otherwise.
*/
export function ObtainAlb(
scope: Construct,
id: string,
Expand Down Expand Up @@ -56,6 +65,9 @@ export function ObtainAlb(
return loadBalancer;
}

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*/
export function AddListener(
scope: Construct,
id: string,
Expand Down Expand Up @@ -111,9 +123,13 @@ export function AddListener(
return listener;
}

// Creates a Target Group for Lambda functions and adds the
// provided functions as a target to that group. Then adds
// the new Target Group to the provided Listener.
/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*
* Creates a Target Group for Lambda functions and adds the
* provided functions as a target to that group. Then adds
* the new Target Group to the provided Listener.
*/
export function AddLambdaTarget(
scope: Construct,
id: string,
Expand All @@ -140,6 +156,9 @@ export function AddLambdaTarget(
return newTargetGroup;
}

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*/
export function AddFargateTarget(
scope: Construct,
id: string,
Expand All @@ -165,9 +184,13 @@ export function AddFargateTarget(
return newTargetGroup;
}

// Looks for the listener associated with Target Groups
// If there is a single listener, this returns it whether it is HTTP or HTTPS
// If there are 2 listeners, it finds the HTTPS listener (we assume the HTTP listener redirects to HTTPS)
/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*
* Looks for the listener associated with Target Groups
* If there is a single listener, this returns it whether it is HTTP or HTTPS
* If there are 2 listeners, it finds the HTTPS listener (we assume the HTTP listener redirects to HTTPS)
*/
export function GetActiveListener(listeners: elb.ApplicationListener[]): elb.ApplicationListener {
let listener: elb.ApplicationListener;

Expand All @@ -182,6 +205,9 @@ export function GetActiveListener(listeners: elb.ApplicationListener[]): elb.App
return listener;
}

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*/
export function CheckAlbProps(props: any) {
let errorMessages = '';
let errorFound = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
* and limitations under the License.
*/

/*
* The functions found here in the core library are for internal use and can be changed
* or removed outside of a major release. We recommend against calling them directly from client code.
*/

import * as api from 'aws-cdk-lib/aws-apigateway';
import { IntegrationResponse } from 'aws-cdk-lib/aws-apigateway';
import * as lambda from 'aws-cdk-lib/aws-lambda';
Expand Down Expand Up @@ -44,6 +49,8 @@ function DefaultRestApiProps(_endpointType: api.EndpointType[], _logGroup: LogGr
}

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*
* Provides the default set of properties for Edge/Global Lambda backed RestApi
* @param scope - the construct to which the RestApi should be attached to.
* @param _endpointType - endpoint type for Api Gateway e.g. Regional, Global, Private
Expand All @@ -60,6 +67,8 @@ export function DefaultGlobalLambdaRestApiProps(_existingLambdaObj: lambda.Funct
}

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*
* Provides the default set of properties for Regional Lambda backed RestApi
* @param scope - the construct to which the RestApi should be attached to.
* @param _endpointType - endpoint type for Api Gateway e.g. Regional, Global, Private
Expand All @@ -76,6 +85,8 @@ export function DefaultRegionalLambdaRestApiProps(_existingLambdaObj: lambda.Fun
}

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*
* Provides the default set of properties for Edge/Global RestApi
* @param _logGroup - CW Log group for Api Gateway access logging
*/
Expand All @@ -84,6 +95,8 @@ export function DefaultGlobalRestApiProps(_logGroup: LogGroup) {
}

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*
* Provides the default set of properties for Regional RestApi
* @param _logGroup - CW Log group for Api Gateway access logging
*/
Expand All @@ -92,6 +105,8 @@ export function DefaultRegionalRestApiProps(_logGroup: LogGroup) {
}

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*
* @returns The set of default integration responses for status codes 200 and 500.
*/
export function DefaultIntegrationResponses(): IntegrationResponse[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
* and limitations under the License.
*/

/*
* The functions found here in the core library are for internal use and can be changed
* or removed outside of a major release. We recommend against calling them directly from client code.
*/

// Imports
import * as logs from 'aws-cdk-lib/aws-logs';
import * as lambda from 'aws-cdk-lib/aws-lambda';
Expand Down Expand Up @@ -180,6 +185,8 @@ export interface GlobalLambdaRestApiResponse {
}

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*
* Builds and returns a global api.RestApi designed to be used with an AWS Lambda function.
* @param scope - the construct to which the RestApi should be attached to.
* @param _existingLambdaObj - an existing AWS Lambda function.
Expand All @@ -202,6 +209,8 @@ export interface RegionalLambdaRestApiResponse {
}

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*
* Builds and returns a regional api.RestApi designed to be used with an AWS Lambda function.
* @param scope - the construct to which the RestApi should be attached to.
* @param existingLambdaObj - an existing AWS Lambda function.
Expand All @@ -224,6 +233,8 @@ export interface GlobalRestApiResponse {
}

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*
* Builds and returns a standard api.RestApi.
* @param scope - the construct to which the RestApi should be attached to.
* @param apiGatewayProps - (optional) user-specified properties to override the default properties.
Expand All @@ -245,6 +256,8 @@ export interface RegionalRestApiResponse {
}

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*
* Builds and returns a Regional api.RestApi.
* @param scope - the construct to which the RestApi should be attached to.
* @param apiGatewayProps - (optional) user-specified properties to override the default properties.
Expand Down Expand Up @@ -276,6 +289,9 @@ export interface AddProxyMethodToApiResourceInputParams {
readonly methodOptions?: apigateway.MethodOptions
}

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*/
export function addProxyMethodToApiResource(params: AddProxyMethodToApiResourceInputParams): apigateway.Method {
// Make sure the user hasn't also specified the application/json content-type in the additionalRequestTemplates optional property
if (params.additionalRequestTemplates && 'application/json' in params.additionalRequestTemplates) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
* and limitations under the License.
*/

/*
* The functions found here in the core library are for internal use and can be changed
* or removed outside of a major release. We recommend against calling them directly from client code.
*/

import * as api from 'aws-cdk-lib/aws-apigateway';
import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
import { FunctionEventType, IOrigin } from 'aws-cdk-lib/aws-cloudfront';
Expand All @@ -20,6 +25,9 @@ import * as s3 from 'aws-cdk-lib/aws-s3';
import * as cdk from 'aws-cdk-lib';
import {BehaviorOptions} from "aws-cdk-lib/aws-cloudfront/lib/distribution";

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*/
export function DefaultCloudFrontWebDistributionForApiGatewayProps(apiEndPoint: api.RestApi,
loggingBucket: s3.Bucket | undefined,
setHttpSecurityHeaders: boolean,
Expand Down Expand Up @@ -47,6 +55,9 @@ export function DefaultCloudFrontWebDistributionForApiGatewayProps(apiEndPoint:
};
}

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*/
export function DefaultCloudFrontWebDistributionForS3Props(
sourceBucket: s3.IBucket,
loggingBucket: s3.Bucket | undefined,
Expand Down Expand Up @@ -80,6 +91,9 @@ export function DefaultCloudFrontWebDistributionForS3Props(
};
}

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*/
export function DefaultCloudFrontDisributionForMediaStoreProps(mediastoreContainer: mediastore.CfnContainer,
loggingBucket: s3.Bucket | undefined,
originRequestPolicy: cloudfront.OriginRequestPolicy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
* and limitations under the License.
*/

/*
* The functions found here in the core library are for internal use and can be changed
* or removed outside of a major release. We recommend against calling them directly from client code.
*/

import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
import * as s3 from 'aws-cdk-lib/aws-s3';
import * as cdk from 'aws-cdk-lib';
Expand Down Expand Up @@ -68,6 +73,9 @@ export interface CloudFrontDistributionForApiGatewayResponse {
readonly loggingBucket?: s3.Bucket
}

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*/
export function CloudFrontDistributionForApiGateway(scope: Construct,
apiEndPoint: api.RestApi,
cloudFrontDistributionProps?: cloudfront.DistributionProps | any,
Expand Down Expand Up @@ -101,6 +109,9 @@ export interface CloudFrontDistributionForS3Response {
readonly cloudfrontFunction?: cloudfront.Function,
}

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*/
export function CloudFrontDistributionForS3(
scope: Construct,
sourceBucket: s3.IBucket,
Expand Down Expand Up @@ -148,6 +159,9 @@ export interface CloudFrontDistributionForMediaStoreResponse {
readonly cloudfrontFunction?: cloudfront.Function
}

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*/
export function CloudFrontDistributionForMediaStore(scope: Construct,
mediaStoreContainer: mediastore.CfnContainer,
cloudFrontDistributionProps?: cloudfront.DistributionProps | any,
Expand Down Expand Up @@ -211,6 +225,9 @@ export function CloudFrontDistributionForMediaStore(scope: Construct,
return { distribution: cfDistribution, loggingBucket, requestPolicy: originRequestPolicy, cloudfrontFunction };
}

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*/
export function CloudFrontOriginAccessIdentity(scope: Construct, comment?: string) {
return new cloudfront.OriginAccessIdentity(scope, 'CloudFrontOriginAccessIdentity', {
comment: comment ? comment : `access-identity-${cdk.Aws.REGION}-${cdk.Aws.STACK_NAME}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@
* and limitations under the License.
*/

/*
* The functions found here in the core library are for internal use and can be changed
* or removed outside of a major release. We recommend against calling them directly from client code.
*/

import * as logs from 'aws-cdk-lib/aws-logs';

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*/
export function DefaultLogGroupProps(): logs.LogGroupProps {

const logGroupProps: logs.LogGroupProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@
* and limitations under the License.
*/

/*
* The functions found here in the core library are for internal use and can be changed
* or removed outside of a major release. We recommend against calling them directly from client code.
*/

import { DefaultLogGroupProps } from './cloudwatch-log-group-defaults';
import * as logs from 'aws-cdk-lib/aws-logs';
import { addCfnSuppressRules, consolidateProps } from './utils';
// Note: To ensure CDKv2 compatibility, keep the import statement for Construct separate
import { Construct } from 'constructs';

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*/
export function buildLogGroup(scope: Construct, logGroupId?: string, logGroupProps?: logs.LogGroupProps): logs.LogGroup {
let _logGroupProps: logs.LogGroupProps;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,19 @@
* and limitations under the License.
*/

/*
* The functions found here in the core library are for internal use and can be changed
* or removed outside of a major release. We recommend against calling them directly from client code.
*/

import * as cognito from 'aws-cdk-lib/aws-cognito';

const DefaultUserPoolProps: cognito.UserPoolProps = {
};

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*/
export function DefaultIdentityPoolProps(userPoolClientId: string, userPoolProviderName: string): cognito.CfnIdentityPoolProps {
return {
allowUnauthenticatedIdentities: false,
Expand All @@ -27,6 +35,9 @@ export function DefaultIdentityPoolProps(userPoolClientId: string, userPoolProvi
} as cognito.CfnIdentityPoolProps;
}

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
*/
export function DefaultUserPoolClientProps(userpool: cognito.UserPool): cognito.UserPoolClientProps {
return {
userPool: userpool
Expand Down
Loading