@@ -35,7 +35,6 @@ import {
35
35
TransitGatewayRouteConfig ,
36
36
VpcConfig ,
37
37
VpcFlowLogsDestinationConfig ,
38
- createLzaVpcName ,
39
38
} from './asea-config' ;
40
39
import { loadAseaConfig } from './asea-config/load' ;
41
40
import * as WriteToSourcesTypes from './common//utils/types/writeToSourcesTypes' ;
@@ -540,9 +539,9 @@ export class ConvertAseaConfig {
540
539
name : createNetworkFirewallName ( firewallConfigName , this . aseaPrefix ) ,
541
540
subnetChangeProtection : false ,
542
541
tags : [ ] ,
543
- vpc : lzaVpcName ! ,
542
+ vpc : createVpcName ( lzaVpcName ?? vpcConfig . name ) ,
544
543
subnets : this . getAzSubnets ( vpcConfig , networkFirewallConfig . subnet . name ) . map ( ( subnet ) =>
545
- createSubnetName ( vpcConfig . name , subnet . subnetName , subnet . az ) ,
544
+ createSubnetName ( lzaVpcName ?? vpcConfig . name , subnet . subnetName , subnet . az ) ,
546
545
) ,
547
546
} ) ;
548
547
}
@@ -1777,7 +1776,7 @@ export class ConvertAseaConfig {
1777
1776
name : instanceNameWithAz ,
1778
1777
account,
1779
1778
launchTemplate,
1780
- vpc : firewallScopedVpcConfig ?. lzaVpcName ! ,
1779
+ vpc : ` ${ vpcName } _vpc` ,
1781
1780
terminationProtection,
1782
1781
detailedMonitoring,
1783
1782
tags,
@@ -2433,7 +2432,7 @@ export class ConvertAseaConfig {
2433
2432
const setConfigRulesConfig = async ( ) => {
2434
2433
if ( ! globalOptions [ 'aws-config' ] ) return ;
2435
2434
// TODO: Consider account regions for deploymentTargets
2436
- const currentNodeRuntime = 'nodejs20 .x' ;
2435
+ const currentNodeRuntime = 'nodejs18 .x' ;
2437
2436
const rulesWithTarget : ( AwsConfigRule & {
2438
2437
deployTo ?: string [ ] ;
2439
2438
excludedAccounts ?: string [ ] ;
@@ -2801,7 +2800,7 @@ export class ConvertAseaConfig {
2801
2800
if ( route [ 'target-vpc' ] ) {
2802
2801
return {
2803
2802
account : this . getAccountKeyforLza ( globalOptions , route [ 'target-account' ] || accountKey ) ,
2804
- vpcName : this . getLzaVpcName ( route [ 'target-vpc' ] ) ,
2803
+ vpcName : createVpcName ( route [ 'target-vpc' ] ) ,
2805
2804
} ;
2806
2805
} else if ( route [ 'target-vpn' ] ) {
2807
2806
return {
@@ -2968,27 +2967,27 @@ export class ConvertAseaConfig {
2968
2967
sources : [ ] ,
2969
2968
} ;
2970
2969
for ( const source of rule . source ) {
2971
- let sourceVpcConfig : ResolvedVpcConfig | undefined ;
2970
+ let sourceVpcAccountKey : string | undefined = undefined ;
2972
2971
if ( SubnetSourceConfig . is ( source ) ) {
2973
- sourceVpcConfig = this . vpcConfigs . find ( ( { vpcConfig } ) => vpcConfig . name === source . vpc ) ;
2972
+ sourceVpcAccountKey = this . vpcConfigs . find ( ( { vpcConfig } ) => vpcConfig . name === source . vpc ) ?. accountKey ;
2974
2973
}
2975
2974
if ( SecurityGroupSourceConfig . is ( source ) ) {
2976
- lzaRule . sources . push ( {
2975
+ lzaRule . sources . push ( {
2977
2976
securityGroups : source [ 'security-group' ] . map ( securityGroupName ) ,
2978
2977
} ) ;
2979
2978
} else if ( SubnetSourceConfig . is ( source ) ) {
2980
2979
lzaRule . sources . push ( {
2981
2980
//account: this.getAccountKeyforLza(globalOptions, source.account || accountKey || ''),
2982
2981
account : this . getAccountKeyforLza (
2983
2982
globalOptions ,
2984
- sourceVpcConfig ?. accountKey || source . account || accountKey || '' ,
2983
+ sourceVpcAccountKey || source . account || accountKey || '' ,
2985
2984
) ,
2986
2985
subnets : source . subnet . flatMap ( ( sourceSubnet ) =>
2987
2986
aseaConfig
2988
- . getAzSubnets ( sourceVpcConfig ?. accountKey || source . account || accountKey || '' , source . vpc , sourceSubnet )
2987
+ . getAzSubnets ( sourceVpcAccountKey || source . account || accountKey || '' , source . vpc , sourceSubnet )
2989
2988
. map ( ( s ) => createSubnetName ( source . vpc , s . subnetName , s . az ) ) ,
2990
2989
) ,
2991
- vpc : sourceVpcConfig ?. lzaVpcName ?? source . vpc ,
2990
+ vpc : createVpcName ( source . vpc ) ,
2992
2991
} ) ;
2993
2992
} else {
2994
2993
lzaRule . sources . push ( source ) ;
@@ -3012,6 +3011,7 @@ export class ConvertAseaConfig {
3012
3011
rules : NaclConfig [ ] ,
3013
3012
vpcConfig : VpcConfig ,
3014
3013
accountKey ?: string ,
3014
+ lzaVpcName ?: string ,
3015
3015
) => {
3016
3016
const lzaRules : ( ConvertConfigTypes . LzaNaclInboundRuleType | ConvertConfigTypes . LzaNaclOutboundRuleType ) [ ] = [ ] ;
3017
3017
for ( const rule of rules ) {
@@ -3055,17 +3055,18 @@ 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
3058
3059
let destination : string ;
3059
3060
if ( dest . vpc === vpcConfig . name ) {
3060
- destination = vpcConfig . name ;
3061
+ destination = createVpcName ( lzaVpcName ?? vpcConfig . name ) ;
3061
3062
} else {
3062
- destination = dest . vpc ;
3063
+ destination = createVpcName ( dest . vpc ) ;
3063
3064
}
3064
- const destinationAccountKey = destinationVpcKey ? this . getAccountKeyforLza ( globalOptions , destinationVpcKey ) : undefined ;
3065
3065
target = {
3066
- account : destinationAccountKey ,
3066
+ account : destinationVpcKey ? this . getAccountKeyforLza ( globalOptions , destinationVpcKey ) : undefined ,
3067
3067
subnet : createSubnetName ( dest . vpc , ruleSubnet . subnetName , ruleSubnet . az ) ,
3068
- vpc : createLzaVpcName ( destination , destinationAccountKey ! , vpcConfig . region ) ,
3068
+ //vpc: createVpcName(dest.vpc),
3069
+ vpc : destination ,
3069
3070
region : targetRegion ,
3070
3071
} ;
3071
3072
}
@@ -3085,7 +3086,7 @@ export class ConvertAseaConfig {
3085
3086
}
3086
3087
return lzaRules ;
3087
3088
} ;
3088
- const prepareNaclConfig = ( vpcConfig : VpcConfig , accountKey ?: string ) => {
3089
+ const prepareNaclConfig = ( vpcConfig : VpcConfig , accountKey ?: string , lzaVpcName ?: string ) => {
3089
3090
const naclSubnetConfigs = vpcConfig . subnets ?. filter ( ( s ) => ! ! s . nacls ) ;
3090
3091
if ( ! naclSubnetConfigs ) return ;
3091
3092
const nacls = [ ] ;
@@ -3099,8 +3100,8 @@ export class ConvertAseaConfig {
3099
3100
subnetAssociations : this . getAzSubnets ( vpcConfig , subnetConfig . name ) . map ( ( s ) =>
3100
3101
createSubnetName ( vpcConfig . name , s . subnetName , s . az ) ,
3101
3102
) ,
3102
- inboundRules : prepareNaclRules ( inboundRules , vpcConfig , accountKey ) ,
3103
- outboundRules : prepareNaclRules ( outboundRules , vpcConfig , accountKey ) ,
3103
+ inboundRules : prepareNaclRules ( inboundRules , vpcConfig , accountKey , lzaVpcName ) ,
3104
+ outboundRules : prepareNaclRules ( outboundRules , vpcConfig , accountKey , lzaVpcName ) ,
3104
3105
} ) ;
3105
3106
}
3106
3107
return nacls ;
@@ -3204,15 +3205,14 @@ export class ConvertAseaConfig {
3204
3205
vpcConfig : VpcConfig ,
3205
3206
lzaEndpointsConfig : ConvertConfigTypes . ResolverEndpointsType [ ] ,
3206
3207
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 : createLzaVpcName ( vpcConfig . name , accountKey ! , vpcConfig . region ) ,
3215
+ vpc : createVpcName ( vpcConfig . lzaVpcName ?? vpcConfig . name ) ,
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 : createLzaVpcName ( vpcConfig . name , accountKey ! , vpcConfig . region ) ,
3229
+ vpc : createVpcName ( vpcConfig . lzaVpcName ?? vpcConfig . name ) ,
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 , accountKey : string | undefined ) => {
3265
+ const prepareResolverConfig = ( vpcConfig : VpcConfig ) => {
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 ! , accountKey ) ;
3277
+ endpoints = prepareEndpointsConfig ( vpcConfig , lzaEndpointsConfig , rules ! ) ;
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 : lzaVpcName ?? createVpcName ( vpcConfig . name ) ,
3422
+ name : createVpcName ( lzaVpcName ?? 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 ) ,
3461
+ networkAcls : prepareNaclConfig ( vpcConfig , accountKey , lzaVpcName ) ,
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 , accountKey ) ,
3467
+ vpcRoute53Resolver : prepareResolverConfig ( vpcConfig ) ,
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 : [ this . getLzaVpcName ( vpcConfig . name ) , this . getLzaVpcName ( vpcConfig . pcx ! [ 'source-vpc' ] ) ] ,
3496
+ vpcs : [ createVpcName ( vpcConfig . lzaVpcName ?? vpcConfig . name ) , createVpcName ( vpcConfig . pcx ! [ 'source-vpc' ] ) ] ,
3497
3497
} ) ) ;
3498
3498
} ;
3499
3499
await setCertificatesConfig ( ) ;
@@ -3660,10 +3660,6 @@ 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
-
3667
3663
private getVpcCidr ( { accountKey, vpcConfig, ouKey } : { accountKey ?: string ; vpcConfig : VpcConfig ; ouKey ?: string } ) {
3668
3664
const cidrs : string [ ] = [ ] ;
3669
3665
if ( vpcConfig [ 'cidr-src' ] === 'provided' ) {
0 commit comments