Skip to content

Commit

Permalink
refactor: make logic more concise with optional chaining and nullish …
Browse files Browse the repository at this point in the history
…coalescing operators (#12277)

This is an unnecessary refactor that shrinks logic across CDK, mostly by replacing phrases like:

```ts
const var = props.property !== undefined ? props.property : 'defaultValue';
const var2 = props.property === undefined ? 'defaultValue' : props.property;
const var3 = props.property ? props.property.subproperty : 'defaultValue';
```

with:

```ts
const var = props.property ?? 'defaultValue';
const var2 = props.property ?? 'defaultValue';
const var3 = props.property?.subproperty ?? 'defaultValue';
```

It's a slightly more concise way of writing the logic which takes advantage of TS native operators. I basically did a regex search and replaced obvious logic.

There are a couple modules where the logic itself was unnecessarily redundant, which I replaced. For example:
https://github.com/aws/aws-cdk/blob/31132caec4565735d2ccc32b43f078d634a5ca43/packages/%40aws-cdk/aws-ecs/lib/base/base-service.ts#L217-L218

Can be replaced by:
```ts
const port = props.port ?? (protocol === elbv2.ApplicationProtocol.HTTPS ? 443 : 80);
```

Because the check for ```protocol === undefined``` setting the default of port 80 can be rolled into the check for ```protocol === elbv2.ApplicationProtocol.HTTPS```

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
flemjame-at-amazon committed Feb 5, 2021
1 parent 32c0de7 commit 98ab292
Show file tree
Hide file tree
Showing 88 changed files with 193 additions and 229 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assert/lib/assertions/have-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class HaveResourceAssertion extends JestFriendlyAssertion<StackInspector>
properties === undefined ? anything() :
allowValueExtension ? deepObjectLike(properties) :
objectLike(properties);
this.part = part !== undefined ? part : ResourcePart.Properties;
this.part = part ?? ResourcePart.Properties;
}

public assertUsing(inspector: StackInspector): boolean {
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-amplify/lib/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ export class App extends Resource implements IApp, iam.IGrantable {
basicAuthConfig: props.autoBranchCreation.basicAuth && props.autoBranchCreation.basicAuth.bind(this, 'BranchBasicAuth'),
buildSpec: props.autoBranchCreation.buildSpec && props.autoBranchCreation.buildSpec.toBuildSpec(),
enableAutoBranchCreation: true,
enableAutoBuild: props.autoBranchCreation.autoBuild === undefined ? true : props.autoBranchCreation.autoBuild,
enableAutoBuild: props.autoBranchCreation.autoBuild ?? true,
environmentVariables: Lazy.any({ produce: () => renderEnvironmentVariables(this.autoBranchEnvironmentVariables ) }, { omitEmptyArray: true }), // eslint-disable-line max-len
enablePullRequestPreview: props.autoBranchCreation.pullRequestPreview === undefined ? true : props.autoBranchCreation.pullRequestPreview,
enablePullRequestPreview: props.autoBranchCreation.pullRequestPreview ?? true,
pullRequestEnvironmentName: props.autoBranchCreation.pullRequestEnvironmentName,
stage: props.autoBranchCreation.stage,
},
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-amplify/lib/branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ export class Branch extends Resource implements IBranch {
branchName,
buildSpec: props.buildSpec && props.buildSpec.toBuildSpec(),
description: props.description,
enableAutoBuild: props.autoBuild === undefined ? true : props.autoBuild,
enablePullRequestPreview: props.pullRequestPreview === undefined ? true : props.pullRequestPreview,
enableAutoBuild: props.autoBuild ?? true,
enablePullRequestPreview: props.pullRequestPreview ?? true,
environmentVariables: Lazy.any({ produce: () => renderEnvironmentVariables(this.environmentVariables) }, { omitEmptyArray: true }),
pullRequestEnvironmentName: props.pullRequestEnvironmentName,
stage: props.stage,
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-amplify/lib/domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class Domain extends Resource {
private renderSubDomainSettings() {
return this.subDomains.map(s => ({
branchName: s.branch.branchName,
prefix: s.prefix === undefined ? s.branch.branchName : s.prefix,
prefix: s.prefix ?? s.branch.branchName,
}));
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/integrations/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface HttpIntegrationProps {
*/
export class HttpIntegration extends Integration {
constructor(url: string, props: HttpIntegrationProps = { }) {
const proxy = props.proxy !== undefined ? props.proxy : true;
const proxy = props.proxy ?? true;
const method = props.httpMethod || 'GET';
super({
type: proxy ? IntegrationType.HTTP_PROXY : IntegrationType.HTTP,
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-apigateway/lib/integrations/lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class LambdaIntegration extends AwsIntegration {
private readonly enableTest: boolean;

constructor(handler: lambda.IFunction, options: LambdaIntegrationOptions = { }) {
const proxy = options.proxy === undefined ? true : options.proxy;
const proxy = options.proxy ?? true;

super({
proxy,
Expand All @@ -51,7 +51,7 @@ export class LambdaIntegration extends AwsIntegration {
});

this.handler = handler;
this.enableTest = options.allowTestInvoke === undefined ? true : options.allowTestInvoke;
this.enableTest = options.allowTestInvoke ?? true;
}

public bind(method: Method): IntegrationConfig {
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-apigateway/lib/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export abstract class ResourceBase extends ResourceConstruct implements IResourc
//
// statusCode

const statusCode = options.statusCode !== undefined ? options.statusCode : 204;
const statusCode = options.statusCode ?? 204;

//
// prepare responseParams
Expand Down Expand Up @@ -522,7 +522,7 @@ export class ProxyResource extends Resource {
defaultMethodOptions: props.defaultMethodOptions,
});

const anyMethod = props.anyMethod !== undefined ? props.anyMethod : true;
const anyMethod = props.anyMethod ?? true;
if (anyMethod) {
this.anyMethod = this.addMethod('ANY');
}
Expand Down
10 changes: 5 additions & 5 deletions packages/@aws-cdk/aws-apigateway/lib/restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ export abstract class RestApiBase extends Resource implements IRestApi {
}

protected configureDeployment(props: RestApiOptions) {
const deploy = props.deploy === undefined ? true : props.deploy;
const deploy = props.deploy ?? true;
if (deploy) {

this._latestDeployment = new Deployment(this, 'Deployment', {
Expand Down Expand Up @@ -593,7 +593,7 @@ export class SpecRestApi extends RestApiBase {
name: this.restApiName,
policy: props.policy,
failOnWarnings: props.failOnWarnings,
body: apiDefConfig.inlineDefinition ? apiDefConfig.inlineDefinition : undefined,
body: apiDefConfig.inlineDefinition ?? undefined,
bodyS3Location: apiDefConfig.inlineDefinition ? undefined : apiDefConfig.s3Location,
endpointConfiguration: this._configureEndpoints(props),
parameters: props.parameters,
Expand All @@ -608,7 +608,7 @@ export class SpecRestApi extends RestApiBase {
this.addDomainName('CustomDomain', props.domainName);
}

const cloudWatchRole = props.cloudWatchRole !== undefined ? props.cloudWatchRole : true;
const cloudWatchRole = props.cloudWatchRole ?? true;
if (cloudWatchRole) {
this.configureCloudWatchRole(resource);
}
Expand Down Expand Up @@ -700,13 +700,13 @@ export class RestApi extends RestApiBase {
binaryMediaTypes: props.binaryMediaTypes,
endpointConfiguration: this._configureEndpoints(props),
apiKeySourceType: props.apiKeySourceType,
cloneFrom: props.cloneFrom ? props.cloneFrom.restApiId : undefined,
cloneFrom: props.cloneFrom?.restApiId,
parameters: props.parameters,
});
this.node.defaultChild = resource;
this.restApiId = resource.ref;

const cloudWatchRole = props.cloudWatchRole !== undefined ? props.cloudWatchRole : true;
const cloudWatchRole = props.cloudWatchRole ?? true;
if (cloudWatchRole) {
this.configureCloudWatchRole(resource);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export abstract class BaseScalableAttribute extends CoreConstruct {
scalableDimension: this.props.dimension,
resourceId: this.props.resourceId,
role: this.props.role,
minCapacity: props.minCapacity !== undefined ? props.minCapacity : 1,
minCapacity: props.minCapacity ?? 1,
maxCapacity: props.maxCapacity,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function orderAndCompleteIntervals(intervals: ScalingInterval[]): CompleteScalin
intervals = intervals.map(x => ({ ...x }));

// Sort by whatever number we have for each interval
intervals.sort(comparatorFromKey((x: ScalingInterval) => x.lower !== undefined ? x.lower : x.upper));
intervals.sort(comparatorFromKey((x: ScalingInterval) => x.lower ?? x.upper));

// Propagate boundaries until no more change
while (propagateBounds(intervals)) { /* Repeat */ }
Expand Down
9 changes: 4 additions & 5 deletions packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -957,9 +957,8 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements

// desiredCapacity just reflects what the user has supplied.
const desiredCapacity = props.desiredCapacity;
const minCapacity = props.minCapacity !== undefined ? props.minCapacity : 1;
const maxCapacity = props.maxCapacity !== undefined ? props.maxCapacity :
desiredCapacity !== undefined ? desiredCapacity : Math.max(minCapacity, 1);
const minCapacity = props.minCapacity ?? 1;
const maxCapacity = props.maxCapacity ?? desiredCapacity ?? Math.max(minCapacity, 1);

withResolved(minCapacity, maxCapacity, (min, max) => {
if (min > max) {
Expand Down Expand Up @@ -1009,7 +1008,7 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements
const { subnetIds, hasPublic } = props.vpc.selectSubnets(props.vpcSubnets);
const asgProps: CfnAutoScalingGroupProps = {
autoScalingGroupName: this.physicalName,
cooldown: props.cooldown !== undefined ? props.cooldown.toSeconds().toString() : undefined,
cooldown: props.cooldown?.toSeconds().toString(),
minSize: Tokenization.stringifyNumber(minCapacity),
maxSize: Tokenization.stringifyNumber(maxCapacity),
desiredCapacity: desiredCapacity !== undefined ? Tokenization.stringifyNumber(desiredCapacity) : undefined,
Expand Down Expand Up @@ -1509,7 +1508,7 @@ enum HealthCheckType {
* Render the rolling update configuration into the appropriate object
*/
function renderRollingUpdateConfig(config: RollingUpdateConfiguration = {}): CfnAutoScalingRollingUpdate {
const waitOnResourceSignals = config.minSuccessfulInstancesPercent !== undefined ? true : false;
const waitOnResourceSignals = config.minSuccessfulInstancesPercent !== undefined;
const pauseTime = config.pauseTime || (waitOnResourceSignals ? Duration.minutes(5) : Duration.seconds(0));

return {
Expand Down
9 changes: 4 additions & 5 deletions packages/@aws-cdk/aws-batch/lib/compute-environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ export class ComputeEnvironment extends Resource implements IComputeEnvironment
minvCpus: props.computeResources.minvCpus || 0,
placementGroup: props.computeResources.placementGroup,
securityGroupIds: this.buildSecurityGroupIds(props.computeResources.vpc, props.computeResources.securityGroups),
spotIamFleetRole: spotFleetRole ? spotFleetRole.roleArn : undefined,
spotIamFleetRole: spotFleetRole?.roleArn,
subnets: props.computeResources.vpc.selectSubnets(props.computeResources.vpcSubnets).subnetIds,
tags: props.computeResources.computeResourcesTags,
type: props.computeResources.type || ComputeResourceType.ON_DEMAND,
Expand All @@ -384,9 +384,8 @@ export class ComputeEnvironment extends Resource implements IComputeEnvironment
const computeEnvironment = new CfnComputeEnvironment(this, 'Resource', {
computeEnvironmentName: this.physicalName,
computeResources,
serviceRole: props.serviceRole
? props.serviceRole.roleArn
: new iam.Role(this, 'Resource-Service-Instance-Role', {
serviceRole: props.serviceRole?.roleArn
?? new iam.Role(this, 'Resource-Service-Instance-Role', {
managedPolicies: [
iam.ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSBatchServiceRole'),
],
Expand All @@ -409,7 +408,7 @@ export class ComputeEnvironment extends Resource implements IComputeEnvironment
}

private isManaged(props: ComputeEnvironmentProps): boolean {
return props.managed === undefined ? true : props.managed;
return props.managed ?? true;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudformation/lib/nested-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class NestedStack extends core.NestedStack {
super(scope, id, {
parameters: props.parameters,
timeout: props.timeout,
notificationArns: props.notifications ? props.notifications.map(n => n.topicArn) : undefined,
notificationArns: props.notifications?.map(n => n.topicArn),
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class MyNestedStack extends cfn.NestedStack {
code: lambda.Code.inline('console.error("hi")'),
handler: 'index.handler',
environment: {
TOPIC_ARN: props.siblingTopic ? props.siblingTopic.topicArn : '',
TOPIC_ARN: props.siblingTopic?.topicArn ?? '',
QUEUE_URL: props.subscriber.queueUrl, // nested stack references a resource in the parent
},
});
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-cloudfront/lib/web-distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,10 +771,10 @@ export class CloudFrontWebDistribution extends cdk.Resource implements IDistribu
let distributionConfig: CfnDistribution.DistributionConfigProperty = {
comment: props.comment,
enabled: true,
defaultRootObject: props.defaultRootObject !== undefined ? props.defaultRootObject : 'index.html',
defaultRootObject: props.defaultRootObject ?? 'index.html',
httpVersion: props.httpVersion || HttpVersion.HTTP2,
priceClass: props.priceClass || PriceClass.PRICE_CLASS_100,
ipv6Enabled: (props.enableIpV6 !== undefined) ? props.enableIpV6 : true,
ipv6Enabled: props.enableIpV6 ?? true,
// eslint-disable-next-line max-len
customErrorResponses: props.errorConfigurations, // TODO: validation : https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-distribution-customerrorresponse.html#cfn-cloudfront-distribution-customerrorresponse-errorcachingminttl
webAclId: props.webACLId,
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-cloudwatch/lib/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class AlarmWidget extends ConcreteWidget {
alarms: [this.props.alarm.alarmArn],
},
yAxis: {
left: this.props.leftYAxis !== undefined ? this.props.leftYAxis : undefined,
left: this.props.leftYAxis ?? undefined,
},
},
}];
Expand Down Expand Up @@ -271,8 +271,8 @@ export class GraphWidget extends ConcreteWidget {
metrics: metrics.length > 0 ? metrics : undefined,
annotations: horizontalAnnotations.length > 0 ? { horizontal: horizontalAnnotations } : undefined,
yAxis: {
left: this.props.leftYAxis !== undefined ? this.props.leftYAxis : undefined,
right: this.props.rightYAxis !== undefined ? this.props.rightYAxis : undefined,
left: this.props.leftYAxis ?? undefined,
right: this.props.rightYAxis ?? undefined,
},
legend: this.props.legendPosition !== undefined ? { position: this.props.legendPosition } : undefined,
liveData: this.props.liveData,
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-codebuild/lib/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,14 +515,14 @@ abstract class ThirdPartyGitSource extends GitSource {
super(props);

this.webhook = props.webhook;
this.reportBuildStatus = props.reportBuildStatus === undefined ? true : props.reportBuildStatus;
this.reportBuildStatus = props.reportBuildStatus ?? true;
this.webhookFilters = props.webhookFilters || [];
this.webhookTriggersBatchBuild = props.webhookTriggersBatchBuild;
}

public bind(_scope: CoreConstruct, project: IProject): SourceConfig {
const anyFilterGroupsProvided = this.webhookFilters.length > 0;
const webhook = this.webhook === undefined ? (anyFilterGroupsProvided ? true : undefined) : this.webhook;
const webhook = this.webhook ?? (anyFilterGroupsProvided ? true : undefined);

if (!webhook && anyFilterGroupsProvided) {
throw new Error('`webhookFilters` cannot be used when `webhook` is `false`');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ export class CustomLambdaDeploymentConfig extends Resource implements ILambdaDep
// Generates the name of the deployment config. It's also what you'll see in the AWS console
// The name of the config is <construct unique id>.Lambda<deployment type><percentage>Percent<interval>Minutes
// Unless the user provides an explicit name
this.deploymentConfigName = props.deploymentConfigName !== undefined
? props.deploymentConfigName
: `${Names.uniqueId(this)}.Lambda${props.type}${props.percentage}Percent${props.type === CustomLambdaDeploymentConfigType.LINEAR
this.deploymentConfigName = props.deploymentConfigName
?? `${Names.uniqueId(this)}.Lambda${props.type}${props.percentage}Percent${props.type === CustomLambdaDeploymentConfigType.LINEAR
? 'Every'
: ''}${props.interval.toMinutes()}Minutes`;
this.deploymentConfigArn = arnForDeploymentConfig(this.deploymentConfigName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export class ServerDeploymentGroup extends ServerDeploymentGroupBase {
});

this._autoScalingGroups = props.autoScalingGroups || [];
this.installAgent = props.installAgent === undefined ? true : props.installAgent;
this.installAgent = props.installAgent ?? true;
this.codeDeployBucket = s3.Bucket.fromBucketName(this, 'Bucket', `aws-codedeploy-${cdk.Stack.of(this).region}`);
for (const asg of this._autoScalingGroups) {
this.addCodeDeployAgentInstallUserData(asg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class CustomActionRegistration extends Construct {
entityUrlTemplate: props.entityUrl,
executionUrlTemplate: props.executionUrl,
},
configurationProperties: props.actionProperties === undefined ? undefined : props.actionProperties.map((ap) => {
configurationProperties: props.actionProperties?.map((ap) => {
return {
key: ap.key || false,
secret: ap.secret || false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ export class FullActionDescriptor {
this.owner = actionProperties.owner || 'AWS';
this.provider = actionProperties.provider;
this.version = actionProperties.version || '1';
this.runOrder = actionProperties.runOrder === undefined ? 1 : actionProperties.runOrder;
this.runOrder = actionProperties.runOrder ?? 1;
this.artifactBounds = actionProperties.artifactBounds;
this.namespace = actionProperties.variablesNamespace;
this.inputs = deduplicateArtifacts(actionProperties.inputs);
this.outputs = deduplicateArtifacts(actionProperties.outputs);
this.region = props.actionRegion || actionProperties.region;
this.role = actionProperties.role !== undefined ? actionProperties.role : props.actionRole;
this.role = actionProperties.role ?? props.actionRole;

this.configuration = props.actionConfig.configuration;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cognito/lib/user-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ export class UserPool extends UserPoolBase {
emailSubject: props.userInvitation?.emailSubject,
smsMessage: props.userInvitation?.smsMessage,
};
const selfSignUpEnabled = props.selfSignUpEnabled !== undefined ? props.selfSignUpEnabled : false;
const selfSignUpEnabled = props.selfSignUpEnabled ?? false;
const adminCreateUserConfig: CfnUserPool.AdminCreateUserConfigProperty = {
allowAdminCreateUserOnly: !selfSignUpEnabled,
inviteMessageTemplate: props.userInvitation !== undefined ? inviteMessageTemplate : undefined,
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-dynamodb/lib/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1391,8 +1391,8 @@ export class Table extends TableBase {
}

return {
projectionType: props.projectionType ? props.projectionType : ProjectionType.ALL,
nonKeyAttributes: props.nonKeyAttributes ? props.nonKeyAttributes : undefined,
projectionType: props.projectionType ?? ProjectionType.ALL,
nonKeyAttributes: props.nonKeyAttributes ?? undefined,
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ec2/lib/network-acl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export class NetworkAclEntry extends NetworkAclEntryBase {
new CfnNetworkAclEntry(this, 'Resource', {
networkAclId: this.networkAcl.networkAclId,
ruleNumber: props.ruleNumber,
ruleAction: props.ruleAction !== undefined ? props.ruleAction : Action.ALLOW,
ruleAction: props.ruleAction ?? Action.ALLOW,
egress: props.direction !== undefined ? props.direction === TrafficDirection.EGRESS : undefined,
...props.traffic.toTrafficConfig(),
...props.cidr.toCidrConfig(),
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ec2/lib/user-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class LinuxUserData extends UserData {
}

public render(): string {
const shebang = this.props.shebang !== undefined ? this.props.shebang : '#!/bin/bash';
const shebang = this.props.shebang ?? '#!/bin/bash';
return [shebang, ...(this.renderOnExitLines()), ...this.lines].join('\n');
}

Expand Down
7 changes: 3 additions & 4 deletions packages/@aws-cdk/aws-ec2/lib/vpc-endpoint-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ export class VpcEndpointService extends Resource implements IVpcEndpointService
}

this.vpcEndpointServiceLoadBalancers = props.vpcEndpointServiceLoadBalancers;
this.acceptanceRequired = props.acceptanceRequired !== undefined ? props.acceptanceRequired : true;
this.whitelistedPrincipals = props.whitelistedPrincipals !== undefined ? props.whitelistedPrincipals : [];
this.acceptanceRequired = props.acceptanceRequired ?? true;
this.whitelistedPrincipals = props.whitelistedPrincipals ?? [];

this.endpointService = new CfnVPCEndpointService(this, id, {
networkLoadBalancerArns: this.vpcEndpointServiceLoadBalancers.map(lb => lb.loadBalancerArn),
Expand All @@ -98,8 +98,7 @@ export class VpcEndpointService extends Resource implements IVpcEndpointService

const { region } = Stack.of(this);
const serviceNamePrefix = !Token.isUnresolved(region) ?
RegionInfo.get(region).vpcEndpointServiceNamePrefix ??
Default.VPC_ENDPOINT_SERVICE_NAME_PREFIX :
(RegionInfo.get(region).vpcEndpointServiceNamePrefix ?? Default.VPC_ENDPOINT_SERVICE_NAME_PREFIX) :
Default.VPC_ENDPOINT_SERVICE_NAME_PREFIX;

this.vpcEndpointServiceName = Fn.join('.', [serviceNamePrefix, Aws.REGION, this.vpcEndpointServiceId]);
Expand Down

0 comments on commit 98ab292

Please sign in to comment.