11import chalk from 'chalk' ;
2- import fs from 'fs' ;
32import logger from '../../../../logger.js' ;
4- import { dataService } from '../../../../request.js' ;
5- import { AgentConfigTypes , AgentInstallConfig , AgentNames , AgentTypes , AWSRegions , BasePaths , BundleType , GatewayTypes , InstallationFlowMethods , PublicDockerRepoBaseUrl , PublicRepoUrl , TrueFalse , YesNo , YesNoChoices } from '../../../types.js' ;
3+ import { AgentConfigTypes , AgentInstallConfig , AgentNames , AgentTypes , AWSRegions , BasePaths , BundleType , GatewayTypes , InstallationFlowMethods , PublicDockerRepoBaseUrl , TrueFalse , YesNo , YesNoChoices } from '../../../types.js' ;
64import { askInput , askList , validateInputLength , validateRegex } from '../../basic-prompts.js' ;
75import { isWindows , writeTemplates , writeToFile } from '../../utils.js' ;
86import { AWSAgentValues } from '../index.js' ;
97import * as helpers from '../index.js' ;
10- import { Account } from '../../../../../types.js' ;
118
129const debugLog = logger ( 'lib: engage: utils: agents: flows: awsAgents' ) ;
1310const daImage = `${ PublicDockerRepoBaseUrl } ${ BasePaths . DockerAgentPublicRepo } /${ AgentNames . AWS_DA } ` ;
@@ -411,8 +408,6 @@ ${chalk.cyan(
411408${ chalk . cyan (
412409 ` aws ssm put-parameter --type SecureString --name ${ awsAgentValues . cloudFormationConfig . SSMPublicKeyParameter } --value "file://public_key.pem"`
413410) } `;
414- // Cleanup EC2 file
415- fs . unlinkSync ( ConfigFiles . EC2DeployYAML ) ;
416411 break ;
417412 }
418413 case DeploymentTypes . OTHER : {
@@ -423,10 +418,6 @@ ${chalk.cyan(
423418 ( value ) => ( s3ResourcesIncludes += `--include "${ value } " ` )
424419 ) ;
425420
426- // Cleanup EC2 file
427- fs . unlinkSync ( ConfigFiles . EC2DeployYAML ) ;
428- // Cleanup ECS Fargate file
429- fs . unlinkSync ( ConfigFiles . FargateDeployYAML ) ;
430421 const info = `To utilize the agents, pull the latest Docker images and run them using the appropriate supplied environment files, (${ helpers . configFiles . DA_ENV_VARS } & ${ helpers . configFiles . TA_ENV_VARS } ):` ;
431422
432423 dockerEnvConfig = `Wait for the CloudFormation Stack to complete.
@@ -501,8 +492,6 @@ ${chalk.cyan(
501492${ chalk . cyan (
502493 ` aws ssm put-parameter --type SecureString --name ${ awsAgentValues . cloudFormationConfig . SSMPublicKeyParameter } --value "file://public_key.pem"`
503494) } `;
504- // Cleanup Fargate file
505- fs . unlinkSync ( ConfigFiles . FargateDeployYAML ) ;
506495 break ;
507496 }
508497 }
@@ -513,7 +502,13 @@ ${chalk.cyan(
513502 const s3Region = awsAgentValues . region === AWSRegions . US_EAST_1 ? 's3' : `s3.${ awsAgentValues . region } ` ;
514503
515504 return `
516- To complete the install, run the following AWS CLI command:
505+ To complete the install, first download and extract the CloudFormation templates:
506+ - Download the CloudFormation package:
507+ ${ chalk . cyan ( ` curl -O https://repository.axway.com/artifactory/ampc-public-generic-release/aws-agents/aws_apigw_agent_config/latest/${ ConfigFiles . AgentConfigZip } ` ) }
508+ - Extract the package:
509+ ${ chalk . cyan ( ` unzip ${ ConfigFiles . AgentConfigZip } ` ) }
510+
511+ Then run the following AWS CLI commands:
517512 - Create, if necessary, and upload all files to your S3 bucket
518513${ chalk . cyan (
519514 ` aws s3api create-bucket --bucket ${ awsAgentValues . cloudFormationConfig . AgentResourcesBucket } --create-bucket-configuration LocationConstraint=${ awsAgentValues . region } `
@@ -537,55 +532,6 @@ ${chalk.gray(`Additional information about agent features can be found here:\n${
537532` ;
538533} ;
539534
540- // Download latest aws apigw config zip
541- const downloadAPIGWAgentConfigZip = async ( account : Account ) : Promise < string > => {
542- const url = `${ BasePaths . AWSAgents } /aws_apigw_agent_config/latest/${ ConfigFiles . AgentConfigZip } ` ;
543-
544- const service = await dataService ( {
545- account,
546- baseUrl : PublicRepoUrl ,
547- } ) ;
548- try {
549- const token = account . auth ?. tokens ?. access_token ;
550- if ( ! token ) {
551- throw new Error ( 'Invalid/expired account' ) ;
552- }
553- const { stream } = await service . download ( url ) ;
554- await helpers . streamPipeline ( stream , fs . createWriteStream ( ConfigFiles . AgentConfigZip ) ) ;
555- return ConfigFiles . AgentConfigZip ;
556- } catch ( err : any ) {
557- throw new Error ( `Failed to download the agent: ${ err . message } ` ) ;
558- }
559- } ;
560-
561- // Unzip latest aws apigw config zip
562- const unzipAPIGWAgentConfigZip = async ( zipFile : string , log : ( text : string ) => void = ( ) => { } ) : Promise < boolean > => {
563- await helpers . unzip ( zipFile ) ;
564- fs . unlinkSync ( zipFile ) ;
565-
566- const isCloudFormation = fs . existsSync ( ConfigFiles . DeployAllYAML ) ;
567- if ( ! isCloudFormation ) {
568- log ( `${ ConfigFiles . DeployAllYAML } was not extracted from ${ ConfigFiles . AgentConfigZip } ` ) ;
569- return false ;
570- }
571- return true ;
572- } ;
573-
574- export const installPreprocess = async ( installConfig : AgentInstallConfig ) : Promise < AgentInstallConfig > => {
575- // attempt to download the cloud formation files
576- installConfig . log ( chalk . gray ( 'Downloading the latest Cloud formation template...' ) ) ;
577- const account = installConfig . centralConfig . apiServerClient ?. account ;
578- if ( ! account ) {
579- throw new Error ( 'Unable to resolve account for DataService call during AWS agent install preprocess' ) ;
580- }
581- const apigwAgentConfigZipFile = await downloadAPIGWAgentConfigZip ( account ) ;
582- if ( apigwAgentConfigZipFile !== '' ) {
583- installConfig . log ( chalk . gray ( '\nSuccess' ) ) ;
584- }
585- ( installConfig . gatewayConfig as helpers . AWSAgentValues ) . apigwAgentConfigZipFile = apigwAgentConfigZipFile ;
586- return installConfig ;
587- } ;
588-
589535export const completeInstall = async ( installConfig : AgentInstallConfig ) : Promise < void > => {
590536 /**
591537 * Create agent resources
@@ -596,11 +542,7 @@ export const completeInstall = async (installConfig: AgentInstallConfig): Promis
596542 awsAgentValues . centralConfig = installConfig . centralConfig ;
597543 awsAgentValues . traceabilityConfig = installConfig . traceabilityConfig ;
598544
599- const unpackZip = await unzipAPIGWAgentConfigZip ( awsAgentValues . apigwAgentConfigZipFile , installConfig . log ) ;
600- if ( unpackZip ) {
601- installConfig . log ( '\nCreating the agent environment files for AWS...' ) ;
602- }
603-
545+ installConfig . log ( '\nCreating the agent environment files for AWS...' ) ;
604546 installConfig . log ( 'Generating the configuration file(s)...' ) ;
605547
606548 installConfig . log ( 'Generating the cloud formation parameters file...' ) ;
@@ -636,9 +578,12 @@ export const AWSInstallMethods: InstallationFlowMethods = {
636578 GetBundleType : askBundleType ,
637579 GetDeploymentType : askConfigType ,
638580 AskGatewayQuestions : gatewayConnectivity ,
639- InstallPreprocess : installPreprocess ,
640581 FinalizeGatewayInstall : completeInstall ,
641- ConfigFiles : Object . values ( ConfigFiles ) ,
582+ ConfigFiles : [
583+ ConfigFiles . DAEnvVars ,
584+ ConfigFiles . TAEnvVars ,
585+ ConfigFiles . CFProperties ,
586+ ] ,
642587 AgentNameMap : {
643588 [ AgentTypes . da ] : AgentNames . AWS_DA ,
644589 [ AgentTypes . ta ] : AgentNames . AWS_TA ,
0 commit comments