Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CFN input for VPC id and Stage #1122

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions deployment/migration-assistant-solution/initBootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ else
fi

cd deployment/cdk/opensearch-service-migration || exit

if [[ -n "$VPC_ID" ]]; then
sed -i "s|<VPC_ID>|$VPC_ID|g" /opensearch-migrations/deployment/cdk/opensearch-service-migration/cdk.context.json
fi
if [[ -n "$STAGE" ]]; then
sed -i "s|<STAGE>|$STAGE|g" /opensearch-migrations/deployment/cdk/opensearch-service-migration/cdk.context.json
fi

npm install -g aws-cdk 2>&1
npm install 2>&1
./buildDockerImages.sh
13 changes: 7 additions & 6 deletions deployment/migration-assistant-solution/lib/solutions-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,6 @@ export class SolutionsInfrastructureStack extends Stack {
})

const solutionsUserAgent = `AwsSolution/${props.solutionId}/${props.solutionVersion}`
const cfnInitConfig: InitElement[] = [
InitCommand.shellCommand(`echo "export MIGRATIONS_APP_REGISTRY_ARN=${appRegistryAppARN}; export MIGRATIONS_USER_AGENT=${solutionsUserAgent}" > /etc/profile.d/solutionsEnv.sh`),
InitFile.fromFileInline("/opensearch-migrations/initBootstrap.sh", './initBootstrap.sh', {
mode: "000744"
}),
]

const bootstrapRole = new Role(this, 'BootstrapRole', {
assumedBy: new ServicePrincipal('ec2.amazonaws.com'),
Expand Down Expand Up @@ -188,6 +182,13 @@ export class SolutionsInfrastructureStack extends Stack {
vpc = importVPC(this, vpcIdParameter, availabilityZonesParameter, privateSubnetIdsParameter);
}

const cfnInitConfig: InitElement[] = [
InitCommand.shellCommand(`echo "export MIGRATIONS_APP_REGISTRY_ARN=${appRegistryAppARN}; export MIGRATIONS_USER_AGENT=${solutionsUserAgent}; export VPC_ID=${vpc.vpcId}; export STAGE=${stageParameter.valueAsString}" > /etc/profile.d/solutionsEnv.sh`),
Copy link
Member

Choose a reason for hiding this comment

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

Nit: create a function to generate these environment variables exports

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added

InitFile.fromFileInline("/opensearch-migrations/initBootstrap.sh", './initBootstrap.sh', {
mode: "000744"
}),
]

new Instance(this, 'BootstrapEC2Instance', {
vpc: vpc,
vpcSubnets: {
Expand Down
Loading