Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion deployment/migration-assistant-solution/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ This project is writen in TypeScript and uses the cloud developer tookit (CDK) t

* Install Node 18+ & Npm 10+ https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
* Build the project `npm run build`
* Creat the deployment artifacts `npm run snyth`
* Test the project `npm run build`
* Create the deployment artifacts `npm run synth`
* Deploy with the default AWS credentials to the default region `npm run deploy`
38 changes: 38 additions & 0 deletions deployment/migration-assistant-solution/bin/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'source-map-support/register';
import { App, DefaultStackSynthesizer } from 'aws-cdk-lib';
import { SolutionsInfrastructureStack } from '../lib/solutions-stack';

const getProps = () => {
const { CODE_BUCKET, SOLUTION_NAME, CODE_VERSION } = process.env;
if (typeof CODE_BUCKET !== 'string' || CODE_BUCKET.trim() === '') {
console.warn(`Missing environment variable CODE_BUCKET, using a default value`);
}

if (typeof SOLUTION_NAME !== 'string' || SOLUTION_NAME.trim() === '') {
console.warn(`Missing environment variable SOLUTION_NAME, using a default value`);
}

if (typeof CODE_VERSION !== 'string' || CODE_VERSION.trim() === '') {
console.warn(`Missing environment variable CODE_VERSION, using a default value`);
}

const codeBucket = CODE_BUCKET ?? "Unknown";
const solutionVersion = CODE_VERSION ?? "Unknown";
const solutionName = SOLUTION_NAME ?? "MigrationAssistant";
const solutionId = 'SO0290';
const description = `(${solutionId}) - The AWS CloudFormation template for deployment of the ${solutionName}. Version ${solutionVersion}`;
return {
codeBucket,
solutionVersion,
solutionId,
solutionName,
description
};
};

const app = new App();
const infraProps = getProps()
new SolutionsInfrastructureStack(app, 'OSMigrations-Bootstrap', {
synthesizer: new DefaultStackSynthesizer(),
...infraProps
});
8 changes: 6 additions & 2 deletions deployment/migration-assistant-solution/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ export default tseslint.config(
...tseslint.configs.stylistic,
{
ignores: ['**/*.js'],
"env": {
"jest": true
},
{
languageOptions: {
globals: {
jest: true
}
}
}
);
14 changes: 7 additions & 7 deletions deployment/migration-assistant-solution/lib/solutions-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ export class SolutionsInfrastructureStack extends Stack {
type: 'String',
description: 'Specify the stage identifier which will be used in naming resources, e.g. dev,gamma,wave1',
default: 'dev',
noEcho: false
});

const appRegistryAppARN = applyAppRegistry(this, stageParameter.valueAsString, props)
const stackMarker = `${stageParameter.valueAsString}-${Aws.REGION}`;
const appRegistryAppARN = applyAppRegistry(this, stackMarker, props)
const vpc = new Vpc(this, 'Vpc', {});

new CfnDocument(this, "BootstrapShellDoc", {
name: `SSM-${stageParameter.valueAsString}-BootstrapShell`,
name: `BootstrapShellDoc-${stackMarker}`,
documentType: "Session",
content: {
"schemaVersion": "1.0",
Expand Down Expand Up @@ -128,13 +128,13 @@ export class SolutionsInfrastructureStack extends Stack {
bootstrapRole.addManagedPolicy(ManagedPolicy.fromAwsManagedPolicyName('AdministratorAccess'))

new InstanceProfile(this, 'BootstrapInstanceProfile', {
instanceProfileName: `bootstrap-${stageParameter.valueAsString}-instance-profile`,
instanceProfileName: `bootstrap-instance-profile-${stackMarker}`,
role: bootstrapRole
})

new Instance(this, 'BootstrapEC2Instance', {
vpc: vpc,
instanceName: `bootstrap-${stageParameter.valueAsString}-instance`,
instanceName: `bootstrap-instance-${stackMarker}`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not opposed to changing this naming pattern, but this definitely requires an update to our Solutions documentation which expect the previous naming pattern so just putting on your radar

instanceType: InstanceType.of(InstanceClass.T3, InstanceSize.LARGE),
machineImage: MachineImage.latestAmazonLinux2023(),
role: bootstrapRole,
Expand All @@ -147,7 +147,6 @@ export class SolutionsInfrastructureStack extends Stack {
init: CloudFormationInit.fromElements(...cfnInitConfig),
initOptions: {
printLog: true,
ignoreFailures: true,
},
});

Expand All @@ -156,8 +155,9 @@ export class SolutionsInfrastructureStack extends Stack {
.filter(c => (c as CfnParameter).type === "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>")
.pop() as CfnParameter;
if (dynamicEc2ImageParameter) {
dynamicEc2ImageParameter.description = "Latest Amazon Linux Image Id for the build machine"
dynamicEc2ImageParameter.description = "Latest Amazon Linux Image Id for the build machine";
dynamicEc2ImageParameter.overrideLogicalId("LastedAmazonLinuxImageId");
dynamicEc2ImageParameter.noEcho = true;
}

const parameterGroups = [];
Expand Down
52 changes: 46 additions & 6 deletions deployment/migration-assistant-solution/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions deployment/migration-assistant-solution/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"lint": "eslint .",
"snyth": "cdk synthesize",
"test": "jest"
"test": "npm run test:lint && npm run test:jest",
"test:lint": "eslint .",
"test:jest": "jest",
"synth": "cdk synthesize --asset-metadata false --path-metadata false",
"deploy": "cdk deploy --require-approval never"
},
"devDependencies": {
"@aws-cdk/assert": "2.68.0",
"@eslint/js": "^9.13.0",
"@types/eslint__js": "^8.42.3",
"@types/jest": "^29.5.5",
"@types/node": "20.9.0",
"@types/node": "^20.9.0",
"aws-cdk": "2.105.0",
"aws-cdk-lib": "2.105.0",
"constructs": "10.3.0",
Expand All @@ -33,6 +35,8 @@
"dependencies": {
"@aws-cdk/aws-servicecatalogappregistry-alpha": "2.105.0-alpha.0",
"@jest/globals": "^29.7.0",
"cdk": "^2.164.1",
"globals": "^15.11.0",
"source-map-support": "^0.5.21"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect, test } from '@jest/globals';
import { describe, test } from '@jest/globals';
import { Template } from 'aws-cdk-lib/assertions';
import { App } from 'aws-cdk-lib';
import { SolutionsInfrastructureStack } from '../lib/solutions-stack';
Expand Down