Skip to content

Commit

Permalink
Add function header comments
Browse files Browse the repository at this point in the history
  • Loading branch information
biffgaut committed Mar 8, 2023
1 parent ae1fb35 commit 7fc9c4f
Show file tree
Hide file tree
Showing 62 changed files with 445 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
*/

/*
* The functions found here in the core library are for internal use and can be changed
* 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
39 changes: 30 additions & 9 deletions source/patterns/@aws-solutions-constructs/core/lib/alb-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

/*
* The functions found here in the core library are for internal use and can be changed
* 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.
*/

Expand All @@ -29,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 @@ -61,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 @@ -116,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 @@ -145,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 @@ -170,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 @@ -187,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 @@ -12,7 +12,7 @@
*/

/*
* The functions found here in the core library are for internal use and can be changed
* 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.
*/

Expand Down Expand Up @@ -49,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 @@ -65,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 @@ -81,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 @@ -89,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 @@ -97,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 @@ -12,7 +12,7 @@
*/

/*
* The functions found here in the core library are for internal use and can be changed
* 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.
*/

Expand Down Expand Up @@ -185,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 @@ -207,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 @@ -229,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 @@ -250,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 @@ -281,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 @@ -12,7 +12,7 @@
*/

/*
* The functions found here in the core library are for internal use and can be changed
* 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.
*/

Expand All @@ -25,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 @@ -52,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 @@ -85,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 @@ -12,7 +12,7 @@
*/

/*
* The functions found here in the core library are for internal use and can be changed
* 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.
*/

Expand Down Expand Up @@ -73,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 @@ -106,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 @@ -153,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 @@ -216,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 @@ -12,12 +12,15 @@
*/

/*
* The functions found here in the core library are for internal use and can be changed
* 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 @@ -12,7 +12,7 @@
*/

/*
* The functions found here in the core library are for internal use and can be changed
* 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.
*/

Expand All @@ -22,6 +22,9 @@ 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 @@ -12,7 +12,7 @@
*/

/*
* The functions found here in the core library are for internal use and can be changed
* 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.
*/

Expand All @@ -21,6 +21,9 @@ 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 @@ -32,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

0 comments on commit 7fc9c4f

Please sign in to comment.