|
1 | 1 | import * as apigwv2 from '../../../aws-apigatewayv2'; |
2 | 2 | import * as ec2 from '../../../aws-ec2'; |
3 | 3 | import * as elbv2 from '../../../aws-elasticloadbalancingv2'; |
4 | | -import { Names, Token } from '../../../core'; |
| 4 | +import { Token } from '../../../core'; |
5 | 5 | import { ValidationError } from '../../../core/lib/errors'; |
6 | 6 | import { ConnectionType, Integration, IntegrationConfig, IntegrationOptions, IntegrationType } from '../integration'; |
7 | 7 | import { Method } from '../method'; |
@@ -39,8 +39,7 @@ export interface AlbIntegrationProps { |
39 | 39 | /** |
40 | 40 | * Integration options, such as request/response mapping, content handling, etc. |
41 | 41 | * |
42 | | - * Note: `vpcLinkV2` and `integrationTarget` options are automatically configured |
43 | | - * and should not be specified here. |
| 42 | + * `vpcLinkV2` and `integrationTarget` options are automatically configured and should not be specified here. |
44 | 43 | * |
45 | 44 | * @default - No additional options |
46 | 45 | */ |
@@ -70,9 +69,9 @@ export class AlbIntegration extends Integration { |
70 | 69 |
|
71 | 70 | super({ |
72 | 71 | type: proxy ? IntegrationType.HTTP_PROXY : IntegrationType.HTTP, |
73 | | - // integrationHttpMethod will be set in bind() if not provided |
| 72 | + // integrationHttpMethod will be updated in bind() if not provided |
74 | 73 | integrationHttpMethod: props.httpMethod ?? 'ANY', |
75 | | - // uri is required for HTTP integrations, will be set in bind() |
| 74 | + // uri is required for HTTP integrations, will be updated in bind() |
76 | 75 | uri: 'http://placeholder.internal', |
77 | 76 | options: props.options, |
78 | 77 | }); |
@@ -131,12 +130,14 @@ export class AlbIntegration extends Integration { |
131 | 130 | } |
132 | 131 |
|
133 | 132 | /** |
134 | | - * Creates a new VPC Link for the ALB's VPC. |
| 133 | + * Creates a new VPC Link for the VPC, or returns an existing one if already created. |
| 134 | + * |
| 135 | + * VPC Links are shared per VPC, similar to the API Gateway V2 implementation. |
135 | 136 | */ |
136 | 137 | private createVpcLink(method: Method, vpc: ec2.IVpc): apigwv2.VpcLink { |
137 | | - const id = `VpcLink-${Names.nodeUniqueId(this.alb.node)}`; |
| 138 | + const id = `VpcLink-${vpc.node.id}`; |
138 | 139 |
|
139 | | - // Check if a VPC link already exists in the API's scope |
| 140 | + // Check if a VPC link already exists in the API's scope for this VPC |
140 | 141 | const existingVpcLink = method.api.node.tryFindChild(id) as apigwv2.VpcLink | undefined; |
141 | 142 | if (existingVpcLink) { |
142 | 143 | return existingVpcLink; |
|
0 commit comments