@@ -35,6 +35,7 @@ import {
35
35
TransitGatewayRouteConfig ,
36
36
VpcConfig ,
37
37
VpcFlowLogsDestinationConfig ,
38
+ createLzaVpcName ,
38
39
} from './asea-config' ;
39
40
import { loadAseaConfig } from './asea-config/load' ;
40
41
import * as WriteToSourcesTypes from './common//utils/types/writeToSourcesTypes' ;
@@ -539,9 +540,9 @@ export class ConvertAseaConfig {
539
540
name : createNetworkFirewallName ( firewallConfigName , this . aseaPrefix ) ,
540
541
subnetChangeProtection : false ,
541
542
tags : [ ] ,
542
- vpc : createVpcName ( lzaVpcName ?? vpcConfig . name ) ,
543
+ vpc : lzaVpcName ! ,
543
544
subnets : this . getAzSubnets ( vpcConfig , networkFirewallConfig . subnet . name ) . map ( ( subnet ) =>
544
- createSubnetName ( lzaVpcName ?? vpcConfig . name , subnet . subnetName , subnet . az ) ,
545
+ createSubnetName ( vpcConfig . name , subnet . subnetName , subnet . az ) ,
545
546
) ,
546
547
} ) ;
547
548
}
@@ -1776,7 +1777,7 @@ export class ConvertAseaConfig {
1776
1777
name : instanceNameWithAz ,
1777
1778
account,
1778
1779
launchTemplate,
1779
- vpc : ` ${ vpcName } _vpc` ,
1780
+ vpc : firewallScopedVpcConfig ?. lzaVpcName ! ,
1780
1781
terminationProtection,
1781
1782
detailedMonitoring,
1782
1783
tags,
@@ -2432,7 +2433,7 @@ export class ConvertAseaConfig {
2432
2433
const setConfigRulesConfig = async ( ) => {
2433
2434
if ( ! globalOptions [ 'aws-config' ] ) return ;
2434
2435
// TODO: Consider account regions for deploymentTargets
2435
- const currentNodeRuntime = 'nodejs18 .x' ;
2436
+ const currentNodeRuntime = 'nodejs20 .x' ;
2436
2437
const rulesWithTarget : ( AwsConfigRule & {
2437
2438
deployTo ?: string [ ] ;
2438
2439
excludedAccounts ?: string [ ] ;
@@ -2800,7 +2801,7 @@ export class ConvertAseaConfig {
2800
2801
if ( route [ 'target-vpc' ] ) {
2801
2802
return {
2802
2803
account : this . getAccountKeyforLza ( globalOptions , route [ 'target-account' ] || accountKey ) ,
2803
- vpcName : createVpcName ( route [ 'target-vpc' ] ) ,
2804
+ vpcName : this . getLzaVpcName ( route [ 'target-vpc' ] ) ,
2804
2805
} ;
2805
2806
} else if ( route [ 'target-vpn' ] ) {
2806
2807
return {
@@ -2967,27 +2968,27 @@ export class ConvertAseaConfig {
2967
2968
sources : [ ] ,
2968
2969
} ;
2969
2970
for ( const source of rule . source ) {
2970
- let sourceVpcAccountKey : string | undefined = undefined ;
2971
+ let sourceVpcConfig : ResolvedVpcConfig | undefined ;
2971
2972
if ( SubnetSourceConfig . is ( source ) ) {
2972
- sourceVpcAccountKey = this . vpcConfigs . find ( ( { vpcConfig } ) => vpcConfig . name === source . vpc ) ?. accountKey ;
2973
+ sourceVpcConfig = this . vpcConfigs . find ( ( { vpcConfig } ) => vpcConfig . name === source . vpc ) ;
2973
2974
}
2974
2975
if ( SecurityGroupSourceConfig . is ( source ) ) {
2975
- lzaRule . sources . push ( {
2976
+ lzaRule . sources . push ( {
2976
2977
securityGroups : source [ 'security-group' ] . map ( securityGroupName ) ,
2977
2978
} ) ;
2978
2979
} else if ( SubnetSourceConfig . is ( source ) ) {
2979
2980
lzaRule . sources . push ( {
2980
2981
//account: this.getAccountKeyforLza(globalOptions, source.account || accountKey || ''),
2981
2982
account : this . getAccountKeyforLza (
2982
2983
globalOptions ,
2983
- sourceVpcAccountKey || source . account || accountKey || '' ,
2984
+ sourceVpcConfig ?. accountKey || source . account || accountKey || '' ,
2984
2985
) ,
2985
2986
subnets : source . subnet . flatMap ( ( sourceSubnet ) =>
2986
2987
aseaConfig
2987
- . getAzSubnets ( sourceVpcAccountKey || source . account || accountKey || '' , source . vpc , sourceSubnet )
2988
+ . getAzSubnets ( sourceVpcConfig ?. accountKey || source . account || accountKey || '' , source . vpc , sourceSubnet )
2988
2989
. map ( ( s ) => createSubnetName ( source . vpc , s . subnetName , s . az ) ) ,
2989
2990
) ,
2990
- vpc : createVpcName ( source . vpc ) ,
2991
+ vpc : sourceVpcConfig ?. lzaVpcName ?? source . vpc ,
2991
2992
} ) ;
2992
2993
} else {
2993
2994
lzaRule . sources . push ( source ) ;
@@ -3011,7 +3012,6 @@ export class ConvertAseaConfig {
3011
3012
rules : NaclConfig [ ] ,
3012
3013
vpcConfig : VpcConfig ,
3013
3014
accountKey ?: string ,
3014
- lzaVpcName ?: string ,
3015
3015
) => {
3016
3016
const lzaRules : ( ConvertConfigTypes . LzaNaclInboundRuleType | ConvertConfigTypes . LzaNaclOutboundRuleType ) [ ] = [ ] ;
3017
3017
for ( const rule of rules ) {
@@ -3055,18 +3055,17 @@ export class ConvertAseaConfig {
3055
3055
} ) ;
3056
3056
} else {
3057
3057
// determine which vpc the nacl rule references
3058
- // use the lzaVpcName when the config is from ou
3059
3058
let destination : string ;
3060
3059
if ( dest . vpc === vpcConfig . name ) {
3061
- destination = createVpcName ( lzaVpcName ?? vpcConfig . name ) ;
3060
+ destination = vpcConfig . name ;
3062
3061
} else {
3063
- destination = createVpcName ( dest . vpc ) ;
3062
+ destination = dest . vpc ;
3064
3063
}
3064
+ const destinationAccountKey = destinationVpcKey ? this . getAccountKeyforLza ( globalOptions , destinationVpcKey ) : undefined ;
3065
3065
target = {
3066
- account : destinationVpcKey ? this . getAccountKeyforLza ( globalOptions , destinationVpcKey ) : undefined ,
3066
+ account : destinationAccountKey ,
3067
3067
subnet : createSubnetName ( dest . vpc , ruleSubnet . subnetName , ruleSubnet . az ) ,
3068
- //vpc: createVpcName(dest.vpc),
3069
- vpc : destination ,
3068
+ vpc : createLzaVpcName ( destination , destinationAccountKey ! , vpcConfig . region ) ,
3070
3069
region : targetRegion ,
3071
3070
} ;
3072
3071
}
@@ -3086,7 +3085,7 @@ export class ConvertAseaConfig {
3086
3085
}
3087
3086
return lzaRules ;
3088
3087
} ;
3089
- const prepareNaclConfig = ( vpcConfig : VpcConfig , accountKey ?: string , lzaVpcName ?: string ) => {
3088
+ const prepareNaclConfig = ( vpcConfig : VpcConfig , accountKey ?: string ) => {
3090
3089
const naclSubnetConfigs = vpcConfig . subnets ?. filter ( ( s ) => ! ! s . nacls ) ;
3091
3090
if ( ! naclSubnetConfigs ) return ;
3092
3091
const nacls = [ ] ;
@@ -3100,8 +3099,8 @@ export class ConvertAseaConfig {
3100
3099
subnetAssociations : this . getAzSubnets ( vpcConfig , subnetConfig . name ) . map ( ( s ) =>
3101
3100
createSubnetName ( vpcConfig . name , s . subnetName , s . az ) ,
3102
3101
) ,
3103
- inboundRules : prepareNaclRules ( inboundRules , vpcConfig , accountKey , lzaVpcName ) ,
3104
- outboundRules : prepareNaclRules ( outboundRules , vpcConfig , accountKey , lzaVpcName ) ,
3102
+ inboundRules : prepareNaclRules ( inboundRules , vpcConfig , accountKey ) ,
3103
+ outboundRules : prepareNaclRules ( outboundRules , vpcConfig , accountKey ) ,
3105
3104
} ) ;
3106
3105
}
3107
3106
return nacls ;
@@ -3205,14 +3204,15 @@ export class ConvertAseaConfig {
3205
3204
vpcConfig : VpcConfig ,
3206
3205
lzaEndpointsConfig : ConvertConfigTypes . ResolverEndpointsType [ ] ,
3207
3206
lzaEndpointsRulesConfig : ConvertConfigTypes . ResolverEndpointRulesType [ ] ,
3207
+ accountKey : string | undefined ,
3208
3208
) : ConvertConfigTypes . ResolverEndpointsType [ ] => {
3209
3209
let inboundResolver = vpcConfig . resolvers ! . inbound ;
3210
3210
let outboundResolver = vpcConfig . resolvers ! . outbound ;
3211
3211
if ( vpcConfig . resolvers ) {
3212
3212
if ( inboundResolver ) {
3213
3213
lzaEndpointsConfig . push ( {
3214
3214
name : `${ vpcConfig . name } InboundEndpoint` ,
3215
- vpc : createVpcName ( vpcConfig . lzaVpcName ?? vpcConfig . name ) ,
3215
+ vpc : createLzaVpcName ( vpcConfig . name , accountKey ! , vpcConfig . region ) ,
3216
3216
subnets :
3217
3217
vpcConfig . subnets
3218
3218
?. find ( ( subnetItem ) => subnetItem . name === vpcConfig . resolvers ?. subnet )
@@ -3226,7 +3226,7 @@ export class ConvertAseaConfig {
3226
3226
if ( outboundResolver ) {
3227
3227
lzaEndpointsConfig . push ( {
3228
3228
name : `${ vpcConfig . name } OutboundEndpoint` ,
3229
- vpc : createVpcName ( vpcConfig . lzaVpcName ?? vpcConfig . name ) ,
3229
+ vpc : createLzaVpcName ( vpcConfig . name , accountKey ! , vpcConfig . region ) ,
3230
3230
subnets :
3231
3231
vpcConfig . subnets
3232
3232
?. find ( ( subnetItem ) => subnetItem . name === vpcConfig . resolvers ?. subnet )
@@ -3262,7 +3262,7 @@ export class ConvertAseaConfig {
3262
3262
return lzaEndpointsRulesConfig ;
3263
3263
} ;
3264
3264
3265
- const prepareResolverConfig = ( vpcConfig : VpcConfig ) => {
3265
+ const prepareResolverConfig = ( vpcConfig : VpcConfig , accountKey : string | undefined ) => {
3266
3266
let lzaResolverConfig : {
3267
3267
endpoints : ConvertConfigTypes . ResolverEndpointsType [ ] | undefined ;
3268
3268
queryLogs : { name : string ; destinations : string [ ] } | undefined ;
@@ -3274,7 +3274,7 @@ export class ConvertAseaConfig {
3274
3274
let endpoints : any [ ] = [ ] ;
3275
3275
if ( vpcConfig . resolvers ) {
3276
3276
rules = prepareRulesConfig ( vpcConfig , lzaEndpointsRulesConfig ) ;
3277
- endpoints = prepareEndpointsConfig ( vpcConfig , lzaEndpointsConfig , rules ! ) ;
3277
+ endpoints = prepareEndpointsConfig ( vpcConfig , lzaEndpointsConfig , rules ! , accountKey ) ;
3278
3278
}
3279
3279
3280
3280
lzaResolverConfig = {
@@ -3419,7 +3419,7 @@ export class ConvertAseaConfig {
3419
3419
3420
3420
const prepareVpcConfig = ( { accountKey, ouKey, vpcConfig, excludeAccounts, lzaVpcName } : ResolvedVpcConfig ) => {
3421
3421
return {
3422
- name : createVpcName ( lzaVpcName ?? vpcConfig . name ) ,
3422
+ name : lzaVpcName ?? createVpcName ( vpcConfig . name ) ,
3423
3423
account : accountKey ? this . getAccountKeyforLza ( globalOptions , accountKey ) : undefined ,
3424
3424
deploymentTargets : ! accountKey
3425
3425
? {
@@ -3458,13 +3458,13 @@ export class ConvertAseaConfig {
3458
3458
useCentralEndpoints : vpcConfig [ 'use-central-endpoints' ] ,
3459
3459
natGateways : prepareNatGatewayConfig ( vpcConfig ) ,
3460
3460
securityGroups : prepareSecurityGroupsConfig ( vpcConfig , accountKey ) ,
3461
- networkAcls : prepareNaclConfig ( vpcConfig , accountKey , lzaVpcName ) ,
3461
+ networkAcls : prepareNaclConfig ( vpcConfig , accountKey ) ,
3462
3462
vpcFlowLogs : prepareVpcFlowLogs ( vpcConfig [ 'flow-logs' ] ) ,
3463
3463
subnets : prepareSubnetConfig ( vpcConfig , ouKey , accountKey ) ,
3464
3464
transitGatewayAttachments : prepareTgwAttachConfig ( vpcConfig ) ,
3465
3465
virtualPrivateGateway : vpcConfig . vgw ,
3466
3466
routeTables : prepareRouteTableConfig ( vpcConfig , accountKey ) ,
3467
- vpcRoute53Resolver : prepareResolverConfig ( vpcConfig ) ,
3467
+ vpcRoute53Resolver : prepareResolverConfig ( vpcConfig , accountKey ) ,
3468
3468
} ;
3469
3469
} ;
3470
3470
@@ -3493,7 +3493,7 @@ export class ConvertAseaConfig {
3493
3493
. filter ( ( { vpcConfig } ) => ! ! vpcConfig . pcx )
3494
3494
. map ( ( { vpcConfig } ) => ( {
3495
3495
name : peeringConnectionName ( vpcConfig . name , vpcConfig . pcx ! [ 'source-vpc' ] ) ,
3496
- vpcs : [ createVpcName ( vpcConfig . lzaVpcName ?? vpcConfig . name ) , createVpcName ( vpcConfig . pcx ! [ 'source-vpc' ] ) ] ,
3496
+ vpcs : [ this . getLzaVpcName ( vpcConfig . name ) , this . getLzaVpcName ( vpcConfig . pcx ! [ 'source-vpc' ] ) ] ,
3497
3497
} ) ) ;
3498
3498
} ;
3499
3499
await setCertificatesConfig ( ) ;
@@ -3660,6 +3660,10 @@ export class ConvertAseaConfig {
3660
3660
) ;
3661
3661
}
3662
3662
3663
+ private getLzaVpcName ( vpcName : string ) : string {
3664
+ return this . vpcConfigs . find ( ( vc ) => vc . vpcConfig . name === vpcName ) ?. lzaVpcName !
3665
+ }
3666
+
3663
3667
private getVpcCidr ( { accountKey, vpcConfig, ouKey } : { accountKey ?: string ; vpcConfig : VpcConfig ; ouKey ?: string } ) {
3664
3668
const cidrs : string [ ] = [ ] ;
3665
3669
if ( vpcConfig [ 'cidr-src' ] === 'provided' ) {
0 commit comments