How to use the @aws-cdk/cx-api.CONTEXT_ENV function in @aws-cdk/cx-api

To help you get started, we’ve selected a few @aws-cdk/cx-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws / aws-cdk / packages / @aws-cdk / core / lib / app.ts View on Github external
private loadContext(defaults: { [key: string]: string } = { }) {
    // prime with defaults passed through constructor
    for (const [ k, v ] of Object.entries(defaults)) {
      this.node.setContext(k, v);
    }

    // read from environment
    const contextJson = process.env[cxapi.CONTEXT_ENV];
    const contextFromEnvironment = contextJson
      ? JSON.parse(contextJson)
      : { };

    for (const [ k, v ] of Object.entries(contextFromEnvironment)) {
      this.node.setContext(k, v);
    }
  }
}
github aws / aws-cdk / packages / aws-cdk / lib / api / cxapp / exec.ts View on Github external
}

  if (!versionReporting) {
    context[cxapi.DISABLE_VERSION_REPORTING] = true;
  }

  let stagingEnabled = config.settings.get(['staging']);
  if (stagingEnabled === undefined) {
    stagingEnabled = true;
  }
  if (!stagingEnabled) {
    context[cxapi.DISABLE_ASSET_STAGING_CONTEXT] = true;
  }

  debug('context:', context);
  env[cxapi.CONTEXT_ENV] = JSON.stringify(context);

  const app = config.settings.get(['app']);
  if (!app) {
    throw new Error(`--app is required either in command-line, in ${PROJECT_CONFIG} or in ${USER_DEFAULTS}`);
  }

  // by pass "synth" if app points to a cloud assembly
  if (await fs.pathExists(app) && (await fs.stat(app)).isDirectory()) {
    debug('--app points to a cloud assembly, so we by pass synth');
    return new cxapi.CloudAssembly(app);
  }

  const commandLine = await guessExecutable(appToArray(app));

  const outdir = config.settings.get([ 'output' ]);
  if (!outdir) {
github aws / aws-cdk / packages / aws-cdk / lib / commands / doctor.ts View on Github external
function displayCdkEnvironmentVariables() {
  const keys = Object.keys(process.env).filter(s => s.startsWith('CDK_'));
  if (keys.length === 0) {
    print('ℹ️ No CDK environment variables');
    return true;
  }
  print('ℹ️ CDK environment variables:');
  let healthy = true;
  for (const key of keys.sort()) {
    if (key === cxapi.CONTEXT_ENV || key === cxapi.OUTDIR_ENV) {
      print(`  - ${colors.red(key)} = ${colors.green(process.env[key]!)} (⚠️ reserved for use by the CDK toolkit)`);
      healthy = false;
    } else {
      print(`  - ${colors.blue(key)} = ${colors.green(process.env[key]!)}`);
    }
  }
  return healthy;
}