-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
230 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,54 @@ | ||
#!/usr/bin/env node | ||
import * as cdk from 'aws-cdk-lib'; | ||
import { CdkStack } from '../lib/cdk-stack'; | ||
import * as path from 'path'; // Use * as path | ||
|
||
interface ExtendedStackProps extends cdk.StackProps { | ||
domainName?: string; // Make optional since we're not using it initially | ||
enableSSHAccess: boolean; | ||
envFile: string; | ||
branch: string; // Make required | ||
sshAllowedIpRange?: string; // Optional, but required if enableSSHAccess is true | ||
webKeyPairName?: string; // Optional, but required if enableSSHAccess is true | ||
mathWorkerKeyPairName?: string; // Optional, but required if enableSSHAccess is true | ||
} | ||
|
||
const app = new cdk.App(); | ||
new CdkStack(app, 'CdkStack', { | ||
env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION }, | ||
}); | ||
|
||
const envFilePath = process.env.ENV_FILE || '../../.env'; // Allow configurable .env file path | ||
const resolvedEnvFilePath = path.resolve(__dirname, envFilePath); | ||
|
||
// Helper function for boolean conversion | ||
function parseBoolean(value: string | undefined): boolean { | ||
return value?.toLowerCase() === 'true' || value === '1' || value?.toLowerCase() === 'yes'; | ||
} | ||
|
||
const props: ExtendedStackProps = { | ||
env: { | ||
account: process.env.CDK_DEFAULT_ACCOUNT, | ||
region: process.env.CDK_DEFAULT_REGION, | ||
}, | ||
domainName: process.env.CDK_DOMAIN_NAME, | ||
enableSSHAccess: parseBoolean(process.env.CDK_SSH_ACCESS), | ||
envFile: resolvedEnvFilePath, | ||
branch: process.env.CDK_BRANCH || 'edge', // Provide a default branch | ||
sshAllowedIpRange: process.env.CDK_SSH_ALLOWED_IP_RANGE, | ||
webKeyPairName: process.env.CDK_WEB_KEY_PAIR_NAME, | ||
mathWorkerKeyPairName: process.env.CDK_MATH_WORKER_KEY_PAIR_NAME, | ||
}; | ||
|
||
// Check for required parameters based on enableSSHAccess | ||
if (props.enableSSHAccess) { | ||
if (!props.sshAllowedIpRange) { | ||
throw new Error("sshAllowedIpRange is required when enableSSHAccess is true."); | ||
} | ||
if (!props.webKeyPairName) { | ||
throw new Error("webKeyPairName is required when enableSSHAccess is true"); | ||
} | ||
if (!props.mathWorkerKeyPairName) { | ||
throw new Error("mathWorkerKeyPairName is required when enableSSHAccess is true"); | ||
} | ||
} | ||
|
||
|
||
new CdkStack(app, 'CdkStack', props); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters