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

CLI option to specify existing VPC ID #404

Merged
merged 3 commits into from
Mar 8, 2024
Merged
Changes from all 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
36 changes: 36 additions & 0 deletions cli/magic-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const embeddingModels = [
fs.readFileSync("./bin/config.json").toString("utf8")
);
options.prefix = config.prefix;
options.vpcId = config.vpc?.vpcId;
options.createVpcEndpoints = config.vpc?.createVpcEndpoints;
options.privateWebsite = config.privateWebsite;
options.certificate = config.certificate;
options.domain = config.domain;
Expand Down Expand Up @@ -117,6 +119,34 @@ async function processCreateOptions(options: any): Promise<void> {
initial: options.prefix,
askAnswered: false,
},
{
type: "confirm",
name: "existingVpc",
message: "Do you want to use existing vpc? (selecting false will create a new vpc)",
initial: options.vpcId ? true : false,
},
{
type: "input",
name: "vpcId",
message: "Specify existing VpcId (vpc-xxxxxxxxxxxxxxxxx)",
initial: options.vpcId,
validate(vpcId: string) {
return ((this as any).skipped || RegExp(/^vpc-[0-9a-f]{8,17}$/i).test(vpcId)) ?
true : 'Enter a valid VpcId in vpc-xxxxxxxxxxx format'
},
skip(): boolean {
return !(this as any).state.answers.existingVpc;
},
},
{
type: "confirm",
name: "createVpcEndpoints",
message: "Do you want create VPC Endpoints?",
initial: options.createVpcEndpoints || false,
skip(): boolean {
return !(this as any).state.answers.existingVpc;
},
},
{
type: "confirm",
name: "privateWebsite",
Expand Down Expand Up @@ -337,6 +367,12 @@ async function processCreateOptions(options: any): Promise<void> {
// Create the config object
const config = {
prefix: answers.prefix,
vpc: answers.existingVpc
? {
vpcId: answers.vpcId.toLowerCase(),
createVpcEndpoints: answers.createVpcEndpoints,
}
: undefined,
privateWebsite: answers.privateWebsite,
certificate: answers.certificate,
domain: answers.domain,
Expand Down
Loading