@@ -35,7 +35,6 @@ import {
3535 TransitGatewayRouteConfig ,
3636 VpcConfig ,
3737 VpcFlowLogsDestinationConfig ,
38- createLzaVpcName ,
3938} from './asea-config' ;
4039import { loadAseaConfig } from './asea-config/load' ;
4140import * as WriteToSourcesTypes from './common//utils/types/writeToSourcesTypes' ;
@@ -540,9 +539,9 @@ export class ConvertAseaConfig {
540539 name : createNetworkFirewallName ( firewallConfigName , this . aseaPrefix ) ,
541540 subnetChangeProtection : false ,
542541 tags : [ ] ,
543- vpc : lzaVpcName ! ,
542+ vpc : createVpcName ( lzaVpcName ?? vpcConfig . name ) ,
544543 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 ) ,
546545 ) ,
547546 } ) ;
548547 }
@@ -1777,7 +1776,7 @@ export class ConvertAseaConfig {
17771776 name : instanceNameWithAz ,
17781777 account,
17791778 launchTemplate,
1780- vpc : firewallScopedVpcConfig ?. lzaVpcName ! ,
1779+ vpc : ` ${ vpcName } _vpc` ,
17811780 terminationProtection,
17821781 detailedMonitoring,
17831782 tags,
@@ -2433,7 +2432,7 @@ export class ConvertAseaConfig {
24332432 const setConfigRulesConfig = async ( ) => {
24342433 if ( ! globalOptions [ 'aws-config' ] ) return ;
24352434 // TODO: Consider account regions for deploymentTargets
2436- const currentNodeRuntime = 'nodejs20 .x' ;
2435+ const currentNodeRuntime = 'nodejs18 .x' ;
24372436 const rulesWithTarget : ( AwsConfigRule & {
24382437 deployTo ?: string [ ] ;
24392438 excludedAccounts ?: string [ ] ;
@@ -2801,7 +2800,7 @@ export class ConvertAseaConfig {
28012800 if ( route [ 'target-vpc' ] ) {
28022801 return {
28032802 account : this . getAccountKeyforLza ( globalOptions , route [ 'target-account' ] || accountKey ) ,
2804- vpcName : this . getLzaVpcName ( route [ 'target-vpc' ] ) ,
2803+ vpcName : createVpcName ( route [ 'target-vpc' ] ) ,
28052804 } ;
28062805 } else if ( route [ 'target-vpn' ] ) {
28072806 return {
@@ -2968,9 +2967,9 @@ export class ConvertAseaConfig {
29682967 sources : [ ] ,
29692968 } ;
29702969 for ( const source of rule . source ) {
2971- let sourceVpcConfig : ResolvedVpcConfig | undefined ;
2970+ let sourceVpcAccountKey : string | undefined = undefined ;
29722971 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 ;
29742973 }
29752974 if ( SecurityGroupSourceConfig . is ( source ) ) {
29762975 lzaRule . sources . push ( {
@@ -2981,14 +2980,14 @@ export class ConvertAseaConfig {
29812980 //account: this.getAccountKeyforLza(globalOptions, source.account || accountKey || ''),
29822981 account : this . getAccountKeyforLza (
29832982 globalOptions ,
2984- sourceVpcConfig ?. accountKey || source . account || accountKey || '' ,
2983+ sourceVpcAccountKey || source . account || accountKey || '' ,
29852984 ) ,
29862985 subnets : source . subnet . flatMap ( ( sourceSubnet ) =>
29872986 aseaConfig
2988- . getAzSubnets ( sourceVpcConfig ?. accountKey || source . account || accountKey || '' , source . vpc , sourceSubnet )
2987+ . getAzSubnets ( sourceVpcAccountKey || source . account || accountKey || '' , source . vpc , sourceSubnet )
29892988 . map ( ( s ) => createSubnetName ( source . vpc , s . subnetName , s . az ) ) ,
29902989 ) ,
2991- vpc : sourceVpcConfig ?. lzaVpcName ?? source . vpc ,
2990+ vpc : createVpcName ( source . vpc ) ,
29922991 } ) ;
29932992 } else {
29942993 lzaRule . sources . push ( source ) ;
@@ -3012,6 +3011,7 @@ export class ConvertAseaConfig {
30123011 rules : NaclConfig [ ] ,
30133012 vpcConfig : VpcConfig ,
30143013 accountKey ?: string ,
3014+ lzaVpcName ?: string ,
30153015 ) => {
30163016 const lzaRules : ( ConvertConfigTypes . LzaNaclInboundRuleType | ConvertConfigTypes . LzaNaclOutboundRuleType ) [ ] = [ ] ;
30173017 for ( const rule of rules ) {
@@ -3055,17 +3055,18 @@ export class ConvertAseaConfig {
30553055 } ) ;
30563056 } else {
30573057 // determine which vpc the nacl rule references
3058+ // use the lzaVpcName when the config is from ou
30583059 let destination : string ;
30593060 if ( dest . vpc === vpcConfig . name ) {
3060- destination = vpcConfig . name ;
3061+ destination = createVpcName ( lzaVpcName ?? vpcConfig . name ) ;
30613062 } else {
3062- destination = dest . vpc ;
3063+ destination = createVpcName ( dest . vpc ) ;
30633064 }
3064- const destinationAccountKey = destinationVpcKey ? this . getAccountKeyforLza ( globalOptions , destinationVpcKey ) : undefined ;
30653065 target = {
3066- account : destinationAccountKey ,
3066+ account : destinationVpcKey ? this . getAccountKeyforLza ( globalOptions , destinationVpcKey ) : undefined ,
30673067 subnet : createSubnetName ( dest . vpc , ruleSubnet . subnetName , ruleSubnet . az ) ,
3068- vpc : createLzaVpcName ( destination , destinationAccountKey ! , vpcConfig . region ) ,
3068+ //vpc: createVpcName(dest.vpc),
3069+ vpc : destination ,
30693070 region : targetRegion ,
30703071 } ;
30713072 }
@@ -3085,7 +3086,7 @@ export class ConvertAseaConfig {
30853086 }
30863087 return lzaRules ;
30873088 } ;
3088- const prepareNaclConfig = ( vpcConfig : VpcConfig , accountKey ?: string ) => {
3089+ const prepareNaclConfig = ( vpcConfig : VpcConfig , accountKey ?: string , lzaVpcName ?: string ) => {
30893090 const naclSubnetConfigs = vpcConfig . subnets ?. filter ( ( s ) => ! ! s . nacls ) ;
30903091 if ( ! naclSubnetConfigs ) return ;
30913092 const nacls = [ ] ;
@@ -3099,8 +3100,8 @@ export class ConvertAseaConfig {
30993100 subnetAssociations : this . getAzSubnets ( vpcConfig , subnetConfig . name ) . map ( ( s ) =>
31003101 createSubnetName ( vpcConfig . name , s . subnetName , s . az ) ,
31013102 ) ,
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 ) ,
31043105 } ) ;
31053106 }
31063107 return nacls ;
@@ -3204,15 +3205,14 @@ export class ConvertAseaConfig {
32043205 vpcConfig : VpcConfig ,
32053206 lzaEndpointsConfig : ConvertConfigTypes . ResolverEndpointsType [ ] ,
32063207 lzaEndpointsRulesConfig : ConvertConfigTypes . ResolverEndpointRulesType [ ] ,
3207- accountKey : string | undefined ,
32083208 ) : ConvertConfigTypes . ResolverEndpointsType [ ] => {
32093209 let inboundResolver = vpcConfig . resolvers ! . inbound ;
32103210 let outboundResolver = vpcConfig . resolvers ! . outbound ;
32113211 if ( vpcConfig . resolvers ) {
32123212 if ( inboundResolver ) {
32133213 lzaEndpointsConfig . push ( {
32143214 name : `${ vpcConfig . name } InboundEndpoint` ,
3215- vpc : createLzaVpcName ( vpcConfig . name , accountKey ! , vpcConfig . region ) ,
3215+ vpc : createVpcName ( vpcConfig . lzaVpcName ?? vpcConfig . name ) ,
32163216 subnets :
32173217 vpcConfig . subnets
32183218 ?. find ( ( subnetItem ) => subnetItem . name === vpcConfig . resolvers ?. subnet )
@@ -3226,7 +3226,7 @@ export class ConvertAseaConfig {
32263226 if ( outboundResolver ) {
32273227 lzaEndpointsConfig . push ( {
32283228 name : `${ vpcConfig . name } OutboundEndpoint` ,
3229- vpc : createLzaVpcName ( vpcConfig . name , accountKey ! , vpcConfig . region ) ,
3229+ vpc : createVpcName ( vpcConfig . lzaVpcName ?? vpcConfig . name ) ,
32303230 subnets :
32313231 vpcConfig . subnets
32323232 ?. find ( ( subnetItem ) => subnetItem . name === vpcConfig . resolvers ?. subnet )
@@ -3262,7 +3262,7 @@ export class ConvertAseaConfig {
32623262 return lzaEndpointsRulesConfig ;
32633263 } ;
32643264
3265- const prepareResolverConfig = ( vpcConfig : VpcConfig , accountKey : string | undefined ) => {
3265+ const prepareResolverConfig = ( vpcConfig : VpcConfig ) => {
32663266 let lzaResolverConfig : {
32673267 endpoints : ConvertConfigTypes . ResolverEndpointsType [ ] | undefined ;
32683268 queryLogs : { name : string ; destinations : string [ ] } | undefined ;
@@ -3274,7 +3274,7 @@ export class ConvertAseaConfig {
32743274 let endpoints : any [ ] = [ ] ;
32753275 if ( vpcConfig . resolvers ) {
32763276 rules = prepareRulesConfig ( vpcConfig , lzaEndpointsRulesConfig ) ;
3277- endpoints = prepareEndpointsConfig ( vpcConfig , lzaEndpointsConfig , rules ! , accountKey ) ;
3277+ endpoints = prepareEndpointsConfig ( vpcConfig , lzaEndpointsConfig , rules ! ) ;
32783278 }
32793279
32803280 lzaResolverConfig = {
@@ -3419,7 +3419,7 @@ export class ConvertAseaConfig {
34193419
34203420 const prepareVpcConfig = ( { accountKey, ouKey, vpcConfig, excludeAccounts, lzaVpcName } : ResolvedVpcConfig ) => {
34213421 return {
3422- name : lzaVpcName ?? createVpcName ( vpcConfig . name ) ,
3422+ name : createVpcName ( lzaVpcName ?? vpcConfig . name ) ,
34233423 account : accountKey ? this . getAccountKeyforLza ( globalOptions , accountKey ) : undefined ,
34243424 deploymentTargets : ! accountKey
34253425 ? {
@@ -3458,13 +3458,13 @@ export class ConvertAseaConfig {
34583458 useCentralEndpoints : vpcConfig [ 'use-central-endpoints' ] ,
34593459 natGateways : prepareNatGatewayConfig ( vpcConfig ) ,
34603460 securityGroups : prepareSecurityGroupsConfig ( vpcConfig , accountKey ) ,
3461- networkAcls : prepareNaclConfig ( vpcConfig , accountKey ) ,
3461+ networkAcls : prepareNaclConfig ( vpcConfig , accountKey , lzaVpcName ) ,
34623462 vpcFlowLogs : prepareVpcFlowLogs ( vpcConfig [ 'flow-logs' ] ) ,
34633463 subnets : prepareSubnetConfig ( vpcConfig , ouKey , accountKey ) ,
34643464 transitGatewayAttachments : prepareTgwAttachConfig ( vpcConfig ) ,
34653465 virtualPrivateGateway : vpcConfig . vgw ,
34663466 routeTables : prepareRouteTableConfig ( vpcConfig , accountKey ) ,
3467- vpcRoute53Resolver : prepareResolverConfig ( vpcConfig , accountKey ) ,
3467+ vpcRoute53Resolver : prepareResolverConfig ( vpcConfig ) ,
34683468 } ;
34693469 } ;
34703470
@@ -3493,7 +3493,7 @@ export class ConvertAseaConfig {
34933493 . filter ( ( { vpcConfig } ) => ! ! vpcConfig . pcx )
34943494 . map ( ( { vpcConfig } ) => ( {
34953495 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' ] ) ] ,
34973497 } ) ) ;
34983498 } ;
34993499 await setCertificatesConfig ( ) ;
@@ -3660,10 +3660,6 @@ export class ConvertAseaConfig {
36603660 ) ;
36613661 }
36623662
3663- private getLzaVpcName ( vpcName : string ) : string {
3664- return this . vpcConfigs . find ( ( vc ) => vc . vpcConfig . name === vpcName ) ?. lzaVpcName !
3665- }
3666-
36673663 private getVpcCidr ( { accountKey, vpcConfig, ouKey } : { accountKey ?: string ; vpcConfig : VpcConfig ; ouKey ?: string } ) {
36683664 const cidrs : string [ ] = [ ] ;
36693665 if ( vpcConfig [ 'cidr-src' ] === 'provided' ) {
0 commit comments