How to use the @aws-cdk/cx-api.EnvironmentUtils 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 / lib / api / cxapp / environments.ts View on Github external
async function parseEnvironment(sdk: ISDK, env: cxapi.Environment): Promise {
  const account = env.account === cxapi.UNKNOWN_ACCOUNT ? await sdk.defaultAccount() : env.account;
  const region = env.region === cxapi.UNKNOWN_REGION ? await sdk.defaultRegion() : env.region;

  if (!account || !region) {
    throw new Error(`Unable to determine default account and/or region`);
  }

  return {
    account, region,
    name: cxapi.EnvironmentUtils.format(account, region)
  };
}
github aws / aws-cdk / packages / aws-cdk / lib / api / util / sdk.ts View on Github external
}

    if (account === cxapi.UNKNOWN_ACCOUNT) {
      account = await this.defaultAccount();
    }

    if (!region) {
      throw new Error(`AWS region must be configured either when you configure your CDK stack or through the environment`);
    }

    if (!account) {
      throw new Error(`Unable to resolve AWS account to use. It must be either configured when you define your CDK or through the environment`);
    }

    const environment: cxapi.Environment = {
      region, account, name: cxapi.EnvironmentUtils.format(account, region)
    };

    return environment;
  }