diff --git a/deployment/migration-assistant-solution/bin/app.ts b/deployment/migration-assistant-solution/bin/app.ts index 8efbaaf4f..de0cf883b 100644 --- a/deployment/migration-assistant-solution/bin/app.ts +++ b/deployment/migration-assistant-solution/bin/app.ts @@ -34,17 +34,13 @@ const getProps = () => { const app = new App(); const infraProps = getProps() -const baseImportVPCStackName = "Migration-Assistant-Infra-Import-VPC" -const baseCreateVPCStackName = "Migration-Assistant-Infra-Create-VPC" -new SolutionsInfrastructureStack(app, baseImportVPCStackName, { +new SolutionsInfrastructureStack(app, "Migration-Assistant-Infra-Import-VPC", { synthesizer: new DefaultStackSynthesizer(), createVPC: false, - stackName: infraProps.stackNameSuffix ? `${baseImportVPCStackName}-${infraProps.stackNameSuffix}` : baseImportVPCStackName, ...infraProps }); -new SolutionsInfrastructureStack(app, baseCreateVPCStackName, { +new SolutionsInfrastructureStack(app, "Migration-Assistant-Infra-Create-VPC", { synthesizer: new DefaultStackSynthesizer(), createVPC: true, - stackName: infraProps.stackNameSuffix ? `${baseCreateVPCStackName}-${infraProps.stackNameSuffix}` : baseCreateVPCStackName, ...infraProps }); diff --git a/deployment/migration-assistant-solution/lib/solutions-stack.ts b/deployment/migration-assistant-solution/lib/solutions-stack.ts index 71b64a7e7..257e31693 100644 --- a/deployment/migration-assistant-solution/lib/solutions-stack.ts +++ b/deployment/migration-assistant-solution/lib/solutions-stack.ts @@ -38,6 +38,7 @@ export interface SolutionsInfrastructureStackProps extends StackProps { readonly solutionVersion: string; readonly codeBucket: string; readonly createVPC: boolean; + readonly stackNameSuffix?: string; } interface ParameterLabel { @@ -113,7 +114,8 @@ function getVpcEndpointForEFS(stack: Stack): InterfaceVpcEndpointAwsService { export class SolutionsInfrastructureStack extends Stack { constructor(scope: Construct, id: string, props: SolutionsInfrastructureStackProps) { - super(scope, id, props); + const finalId = props.stackNameSuffix ? `${id}-${props.stackNameSuffix}` : id + super(scope, finalId, props); this.templateOptions.templateFormatVersion = '2010-09-09'; new CfnMapping(this, 'Solution', { mapping: { @@ -189,7 +191,7 @@ export class SolutionsInfrastructureStack extends Stack { }); const serviceEndpoints = [ - // Logs and disk usage scales based on total data transfer + // Logs and disk usage scales based on total data transfer InterfaceVpcEndpointAwsService.CLOUDWATCH_LOGS, getVpcEndpointForEFS(this), @@ -197,7 +199,7 @@ export class SolutionsInfrastructureStack extends Stack { InterfaceVpcEndpointAwsService.ECR, InterfaceVpcEndpointAwsService.ECR_DOCKER, ]; - + serviceEndpoints.forEach(service => { new InterfaceVpcEndpoint(this, `${service.shortName}VpcEndpoint`, { service, diff --git a/vars/solutionsCFNTest.groovy b/vars/solutionsCFNTest.groovy index 2001cc81d..8fa61d64c 100644 --- a/vars/solutionsCFNTest.groovy +++ b/vars/solutionsCFNTest.groovy @@ -34,7 +34,7 @@ def call(Map config = [:]) { sh "sudo npm install" withCredentials([string(credentialsId: 'migrations-test-account-id', variable: 'MIGRATIONS_TEST_ACCOUNT_ID')]) { withAWS(role: 'JenkinsDeploymentRole', roleAccount: "${MIGRATIONS_TEST_ACCOUNT_ID}", region: "us-east-1", duration: 3600, roleSessionName: 'jenkins-session') { - sh "sudo --preserve-env cdk deploy 'Migration-Assistant-Infra-Create-VPC' --parameters Stage=${stage} --require-approval never --concurrency 3" + sh "sudo --preserve-env cdk deploy Migration-Assistant-Infra-Create-VPC-${env.STACK_NAME_SUFFIX} --parameters Stage=${stage} --require-approval never --concurrency 3" } } // Wait for instance to be ready to accept SSM commands @@ -84,7 +84,7 @@ def call(Map config = [:]) { script { withCredentials([string(credentialsId: 'migrations-test-account-id', variable: 'MIGRATIONS_TEST_ACCOUNT_ID')]) { withAWS(role: 'JenkinsDeploymentRole', roleAccount: "${MIGRATIONS_TEST_ACCOUNT_ID}", region: "us-east-1", duration: 3600, roleSessionName: 'jenkins-session') { - sh "sudo --preserve-env cdk destroy 'Migration-Assistant-Infra-Create-VPC' --force" + sh "sudo --preserve-env cdk destroy Migration-Assistant-Infra-Create-VPC-${env.STACK_NAME_SUFFIX} --force" } } }