Skip to content

Commit

Permalink
corrected imports in service
Browse files Browse the repository at this point in the history
  • Loading branch information
clopca committed Jul 3, 2024
1 parent 7a44d4d commit aaa2ef4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
7 changes: 3 additions & 4 deletions src/listener.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IResource } from 'aws-cdk-lib';
import { RemovalPolicy, Resource } from 'aws-cdk-lib';
import type { IResource, RemovalPolicy } from 'aws-cdk-lib';
import { Resource } from 'aws-cdk-lib';
import * as generated from 'aws-cdk-lib/aws-vpclattice';
import type { Construct } from 'constructs';
import type { RuleConditions } from './matches';
Expand Down Expand Up @@ -235,7 +235,7 @@ export class Listener extends Resource implements IListener {

protected validateListenerName(name: string) {
const errors: string[] = [];
const pattern = /^(?!listener-)(?![-])(?!.*[-]$)(?!.*[-]{2})[a-z0-9-]+$/;
const pattern = /^(?!listener-)(?!-)(?!.*-$)(?!.*--)[a-z0-9-]+$/;
const validationSucceeded = name.length >= 3 && name.length <= 63 && pattern.test(name);
if (!validationSucceeded) {
errors.push(`Invalid Listener Name: ${name} (must be between 3-63 characters, and must be a valid name)`);
Expand Down Expand Up @@ -355,5 +355,4 @@ export class Listener extends Resource implements IListener {
}
}

// 186-188,190-191,216-219,231-232,237-244,247-253,270-294,297-317,339-351
// 231-232,241-242,274-298,306-308,312-316
30 changes: 16 additions & 14 deletions src/service.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { EOL } from 'os';
import { aws_iam as iam, aws_ram as ram, RemovalPolicy, Resource, Aspects, Arn, Stack } from 'aws-cdk-lib';
import type { IResource } from 'aws-cdk-lib';
import { EOL } from 'node:os';
import { aws_iam as iam, aws_ram as ram, Resource, Aspects, Arn, Stack } from 'aws-cdk-lib';
import type { IResource, RemovalPolicy } from 'aws-cdk-lib';
import * as generated from 'aws-cdk-lib/aws-vpclattice';
import { Construct, IConstruct } from 'constructs';
import { Listener, ListenerConfig } from './listener';
import { LoggingDestination } from './logging';
import { IServiceNetwork } from './service-network';
import type { Construct, IConstruct } from 'constructs';
import { Listener } from './listener';
import type { ListenerConfig } from './listener';
import type { LoggingDestination } from './logging';
import type { IServiceNetwork } from './service-network';
import { ServiceNetworkAssociation } from './service-network-association';
import { AuthType } from './util';

Expand Down Expand Up @@ -313,9 +314,12 @@ export class Service extends ServiceBase {
// ------------------------------------------------------
if (this.loggingDestinations.length) {
this.node.addValidation({ validate: () => this.validateLoggingDestinations(this.loggingDestinations) });
this.loggingDestinations.forEach(destination => {
for (const destination of this.loggingDestinations) {
this.addLoggingDestination(destination);
});
}
for (const destination of this.loggingDestinations) {
this.addLoggingDestination(destination);
}
}

// ------------------------------------------------------
Expand All @@ -326,9 +330,9 @@ export class Service extends ServiceBase {
}

if (props.authStatements) {
props.authStatements.forEach(propStatement => {
for (const propStatement of props.authStatements) {
this.authPolicy.addStatements(propStatement);
});
}
}

if (!this.authPolicy.isEmpty) {
Expand Down Expand Up @@ -371,7 +375,6 @@ export class Service extends ServiceBase {

if (errors.length > 0) {
errors.unshift(`Invalid service name (value: ${name})`);
// throw new Error(`Invalid service name (value: ${name})${EOL}${errors.join(EOL)}`);
}
return errors;
}
Expand All @@ -385,7 +388,6 @@ export class Service extends ServiceBase {
const destinationTypes = loggingDestinations.map(destination => destination.destinationType);
if (new Set(destinationTypes).size !== destinationTypes.length) {
errors.push('A service can only have one logging destination per destination type.');
// throw new Error('A service can only have one logging destination per destination type.');
}
}
return errors;
Expand Down Expand Up @@ -461,7 +463,7 @@ export class Service extends ServiceBase {
* @param principals a list of IAM principals to grant access.
*/
public grantAccess(principals: iam.IPrincipal[]): void {
let policyStatement: iam.PolicyStatement = new iam.PolicyStatement({
const policyStatement: iam.PolicyStatement = new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: ['vpc-lattice-svcs:Invoke'],
resources: ['*'],
Expand Down

0 comments on commit aaa2ef4

Please sign in to comment.