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

feat: start endpoint resolver generation #472

Merged
merged 9 commits into from
Dec 17, 2019

Conversation

mtdowling
Copy link
Member

@mtdowling mtdowling commented Nov 27, 2019

Issue #, if available:

Description of changes:

Adds support for endpoint generation.

  • Integrate the shared endpoint interfaces into the SDK
  • Update as needed to better integrate into config resolving
  • Add tests

The generated endpoints work in two modes:

  • Service has regionalized endpoints. Services with a regionalized endpoint check for exact region matches and return a code generated endpoint. Finally, if the region doesn't have an exact match, it tries to guess an endpoint. It check each known partition for endpoints and see if the region is in the partition. If it is, is uses the template of that partition to guess an endpoint (taking into account the defaults of the both the service and partition).
  • Service has partition endpoints. It still checks for exact region matches. It then falls back to using the partitionEndpoint in the endpoints.json file to generate an endpoint. This is handled using recursion by referring the partitionEndpoint by name (goes back to using exact matching).

Note: this implementation does not implement regex based guessing.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Examples

data.iot

/// This exampe is for data.iot. It uses partition endpoints and
/// a signingService.

//// This should be in the SDK:
export interface EndpointOptions {}

export interface EndpointProvider {
    (region: string, options?: EndpointOptions): Endpoint | undefined;
}

export interface Endpoint {
    hostname: string;
    path?: string;
    signingService?: string;
    signingRegion?: string;
}

/// ....

// Partition default templates
const AWS_TEMPLATE = "data.iot.{region}.amazonaws.com";
const AWS_CN_TEMPLATE = "data.iot.{region}.amazonaws.com.cn";
const AWS_ISO_TEMPLATE = "data.iot.{region}.c2s.ic.gov";
const AWS_ISO_B_TEMPLATE = "data.iot.{region}.sc2s.sgov.gov";
const AWS_US_GOV_TEMPLATE = "data.iot.{region}.amazonaws.com";

// Partition regions
const AWS_REGIONS = new Set([
  "ap-south-1",
  "eu-north-1",
  "eu-west-3",
  "eu-west-2",
  "eu-west-1",
  "ap-northeast-2",
  "ap-northeast-1",
  "me-south-1",
  "ca-central-1",
  "sa-east-1",
  "ap-east-1",
  "ap-southeast-1",
  "ap-southeast-2",
  "eu-central-1",
  "us-east-1",
  "us-east-2",
  "us-west-1",
  "us-west-2",
]);
const AWS_CN_REGIONS = new Set([
  "cn-north-1",
  "cn-northwest-1",
]);
const AWS_ISO_REGIONS = new Set([
  "us-iso-east-1",
]);
const AWS_ISO_B_REGIONS = new Set([
  "us-isob-east-1",
]);
const AWS_US_GOV_REGIONS = new Set([
  "us-gov-west-1",
  "us-gov-east-1",
]);

export let defaultEndpointProvider: EndpointProvider;
defaultEndpointProvider = function(
  region: string,
  options?: EndpointOptions
) {
  switch (region) {
    // First, try to match exact region names.
    case "ap-east-1":
      return {
        hostname: "data.iot.ap-east-1.amazonaws.com",
        signingService: "iotdata",
      };
    case "ap-northeast-1":
      return {
        hostname: "data.iot.ap-northeast-1.amazonaws.com",
        signingService: "iotdata",
      };
    case "ap-northeast-2":
      return {
        hostname: "data.iot.ap-northeast-2.amazonaws.com",
        signingService: "iotdata",
      };
    case "ap-south-1":
      return {
        hostname: "data.iot.ap-south-1.amazonaws.com",
        signingService: "iotdata",
      };
    case "ap-southeast-1":
      return {
        hostname: "data.iot.ap-southeast-1.amazonaws.com",
        signingService: "iotdata",
      };
    case "ap-southeast-2":
      return {
        hostname: "data.iot.ap-southeast-2.amazonaws.com",
        signingService: "iotdata",
      };
    case "ca-central-1":
      return {
        hostname: "data.iot.ca-central-1.amazonaws.com",
        signingService: "iotdata",
      };
    case "cn-north-1":
      return {
        hostname: "data.iot.cn-north-1.amazonaws.com.cn",
        signingService: "iotdata",
      };
    case "cn-northwest-1":
      return {
        hostname: "data.iot.cn-northwest-1.amazonaws.com.cn",
        signingService: "iotdata",
      };
    case "eu-central-1":
      return {
        hostname: "data.iot.eu-central-1.amazonaws.com",
        signingService: "iotdata",
      };
    case "eu-north-1":
      return {
        hostname: "data.iot.eu-north-1.amazonaws.com",
        signingService: "iotdata",
      };
    case "eu-west-1":
      return {
        hostname: "data.iot.eu-west-1.amazonaws.com",
        signingService: "iotdata",
      };
    case "eu-west-2":
      return {
        hostname: "data.iot.eu-west-2.amazonaws.com",
        signingService: "iotdata",
      };
    case "eu-west-3":
      return {
        hostname: "data.iot.eu-west-3.amazonaws.com",
        signingService: "iotdata",
      };
    case "me-south-1":
      return {
        hostname: "data.iot.me-south-1.amazonaws.com",
        signingService: "iotdata",
      };
    case "sa-east-1":
      return {
        hostname: "data.iot.sa-east-1.amazonaws.com",
        signingService: "iotdata",
      };
    case "us-east-1":
      return {
        hostname: "data.iot.us-east-1.amazonaws.com",
        signingService: "iotdata",
      };
    case "us-east-2":
      return {
        hostname: "data.iot.us-east-2.amazonaws.com",
        signingService: "iotdata",
      };
    case "us-gov-west-1":
      return {
        hostname: "data.iot.us-gov-west-1.amazonaws.com",
        signingService: "iotdata",
      };
    case "us-west-1":
      return {
        hostname: "data.iot.us-west-1.amazonaws.com",
        signingService: "iotdata",
      };
    case "us-west-2":
      return {
        hostname: "data.iot.us-west-2.amazonaws.com",
        signingService: "iotdata",
      };
    // Next, try to match partition endpoints.
    default:
      if (region in AWS_REGIONS) {
        return {
          hostname: AWS_TEMPLATE.replace("{region}", region),
          signingService: "iotdata",
        };
      }
      if (region in AWS_CN_REGIONS) {
        return {
          hostname: AWS_CN_TEMPLATE.replace("{region}", region),
          signingService: "iotdata",
        };
      }
      if (region in AWS_ISO_REGIONS) {
        return {
          hostname: AWS_ISO_TEMPLATE.replace("{region}", region),
        };
      }
      if (region in AWS_ISO_B_REGIONS) {
        return {
          hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region),
        };
      }
      if (region in AWS_US_GOV_REGIONS) {
        return {
          hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region),
          signingService: "iotdata",
        };
      }
      // Finally, assume it's an AWS partition endpoint.
      return {
        hostname: AWS_TEMPLATE.replace("{region}", region),
        signingService: "iotdata",
      };
  }
}

acm

/// This exampe is for acm. It's in aws and aws-us-gov.
/// It uses regular regional endpoints for both partitions.

// Partition default templates
const AWS_TEMPLATE = "acm.{region}.amazonaws.com";
const AWS_CN_TEMPLATE = "acm.{region}.amazonaws.com.cn";
const AWS_ISO_TEMPLATE = "acm.{region}.c2s.ic.gov";
const AWS_ISO_B_TEMPLATE = "acm.{region}.sc2s.sgov.gov";
const AWS_US_GOV_TEMPLATE = "acm.{region}.amazonaws.com";

// Partition regions
const AWS_REGIONS = new Set([
  "ap-south-1",
  "eu-north-1",
  "eu-west-3",
  "eu-west-2",
  "eu-west-1",
  "ap-northeast-2",
  "ap-northeast-1",
  "me-south-1",
  "ca-central-1",
  "sa-east-1",
  "ap-east-1",
  "ap-southeast-1",
  "ap-southeast-2",
  "eu-central-1",
  "us-east-1",
  "us-east-2",
  "us-west-1",
  "us-west-2",
]);
const AWS_CN_REGIONS = new Set([
  "cn-north-1",
  "cn-northwest-1",
]);
const AWS_ISO_REGIONS = new Set([
  "us-iso-east-1",
]);
const AWS_ISO_B_REGIONS = new Set([
  "us-isob-east-1",
]);
const AWS_US_GOV_REGIONS = new Set([
  "us-gov-west-1",
  "us-gov-east-1",
]);

export let defaultEndpointProvider: EndpointProvider;
defaultEndpointProvider = function(
  region: string,
  options?: EndpointOptions
) {
  switch (region) {
    // First, try to match exact region names.
    case "ap-east-1":
      return {
        hostname: "acm.ap-east-1.amazonaws.com",
      };
    case "ap-northeast-1":
      return {
        hostname: "acm.ap-northeast-1.amazonaws.com",
      };
    case "ap-northeast-2":
      return {
        hostname: "acm.ap-northeast-2.amazonaws.com",
      };
    case "ap-south-1":
      return {
        hostname: "acm.ap-south-1.amazonaws.com",
      };
    case "ap-southeast-1":
      return {
        hostname: "acm.ap-southeast-1.amazonaws.com",
      };
    case "ap-southeast-2":
      return {
        hostname: "acm.ap-southeast-2.amazonaws.com",
      };
    case "ca-central-1":
      return {
        hostname: "acm.ca-central-1.amazonaws.com",
      };
    case "eu-central-1":
      return {
        hostname: "acm.eu-central-1.amazonaws.com",
      };
    case "eu-north-1":
      return {
        hostname: "acm.eu-north-1.amazonaws.com",
      };
    case "eu-west-1":
      return {
        hostname: "acm.eu-west-1.amazonaws.com",
      };
    case "eu-west-2":
      return {
        hostname: "acm.eu-west-2.amazonaws.com",
      };
    case "eu-west-3":
      return {
        hostname: "acm.eu-west-3.amazonaws.com",
      };
    case "me-south-1":
      return {
        hostname: "acm.me-south-1.amazonaws.com",
      };
    case "sa-east-1":
      return {
        hostname: "acm.sa-east-1.amazonaws.com",
      };
    case "us-east-1":
      return {
        hostname: "acm.us-east-1.amazonaws.com",
      };
    case "us-east-2":
      return {
        hostname: "acm.us-east-2.amazonaws.com",
      };
    case "us-gov-east-1":
      return {
        hostname: "acm.us-gov-east-1.amazonaws.com",
      };
    case "us-gov-west-1":
      return {
        hostname: "acm.us-gov-west-1.amazonaws.com",
      };
    case "us-west-1":
      return {
        hostname: "acm.us-west-1.amazonaws.com",
      };
    case "us-west-2":
      return {
        hostname: "acm.us-west-2.amazonaws.com",
      };
    // Next, try to match partition endpoints.
    default:
      if (region in AWS_REGIONS) {
        return {
          hostname: AWS_TEMPLATE.replace("{region}", region),
        };
      }
      if (region in AWS_CN_REGIONS) {
        return {
          hostname: AWS_CN_TEMPLATE.replace("{region}", region),
        };
      }
      if (region in AWS_ISO_REGIONS) {
        return {
          hostname: AWS_ISO_TEMPLATE.replace("{region}", region),
        };
      }
      if (region in AWS_ISO_B_REGIONS) {
        return {
          hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region),
        };
      }
      if (region in AWS_US_GOV_REGIONS) {
        return {
          hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region),
        };
      }
      // Finally, assume it's an AWS partition endpoint.
      return {
        hostname: AWS_TEMPLATE.replace("{region}", region),
      };
  }
}

rds-data

/// RDS Data example - note it's not actually in the endpoints.json

// Partition default templates
const AWS_TEMPLATE = "rds-data.{region}.amazonaws.com";
const AWS_CN_TEMPLATE = "rds-data.{region}.amazonaws.com.cn";
const AWS_ISO_TEMPLATE = "rds-data.{region}.c2s.ic.gov";
const AWS_ISO_B_TEMPLATE = "rds-data.{region}.sc2s.sgov.gov";
const AWS_US_GOV_TEMPLATE = "rds-data.{region}.amazonaws.com";

// Partition regions
const AWS_REGIONS = new Set([
  "ap-south-1",
  "eu-north-1",
  "eu-west-3",
  "eu-west-2",
  "eu-west-1",
  "ap-northeast-2",
  "ap-northeast-1",
  "me-south-1",
  "ca-central-1",
  "sa-east-1",
  "ap-east-1",
  "ap-southeast-1",
  "ap-southeast-2",
  "eu-central-1",
  "us-east-1",
  "us-east-2",
  "us-west-1",
  "us-west-2",
]);
const AWS_CN_REGIONS = new Set([
  "cn-north-1",
  "cn-northwest-1",
]);
const AWS_ISO_REGIONS = new Set([
  "us-iso-east-1",
]);
const AWS_ISO_B_REGIONS = new Set([
  "us-isob-east-1",
]);
const AWS_US_GOV_REGIONS = new Set([
  "us-gov-west-1",
  "us-gov-east-1",
]);

export let defaultEndpointProvider: EndpointProvider;
defaultEndpointProvider = function(
  region: string,
  options?: EndpointOptions
) {
  switch (region) {
    // First, try to match exact region names.
    // Next, try to match partition endpoints.
    default:
      if (region in AWS_REGIONS) {
        return {
          hostname: AWS_TEMPLATE.replace("{region}", region),
        };
      }
      if (region in AWS_CN_REGIONS) {
        return {
          hostname: AWS_CN_TEMPLATE.replace("{region}", region),
        };
      }
      if (region in AWS_ISO_REGIONS) {
        return {
          hostname: AWS_ISO_TEMPLATE.replace("{region}", region),
        };
      }
      if (region in AWS_ISO_B_REGIONS) {
        return {
          hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region),
        };
      }
      if (region in AWS_US_GOV_REGIONS) {
        return {
          hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region),
        };
      }
      // Finally, assume it's an AWS partition endpoint.
      return {
        hostname: AWS_TEMPLATE.replace("{region}", region),
      };
  }
}

iam

/// This example shows iam working as a partition service in
/// all partitions.

// Partition default templates
const AWS_TEMPLATE = "iam.{region}.amazonaws.com";
const AWS_CN_TEMPLATE = "iam.{region}.amazonaws.com.cn";
const AWS_ISO_TEMPLATE = "iam.{region}.c2s.ic.gov";
const AWS_ISO_B_TEMPLATE = "iam.{region}.sc2s.sgov.gov";
const AWS_US_GOV_TEMPLATE = "iam.{region}.amazonaws.com";

// Partition regions
const AWS_REGIONS = new Set([
  "ap-south-1",
  "eu-north-1",
  "eu-west-3",
  "eu-west-2",
  "eu-west-1",
  "ap-northeast-2",
  "ap-northeast-1",
  "me-south-1",
  "ca-central-1",
  "sa-east-1",
  "ap-east-1",
  "ap-southeast-1",
  "ap-southeast-2",
  "eu-central-1",
  "us-east-1",
  "us-east-2",
  "us-west-1",
  "us-west-2",
]);
const AWS_CN_REGIONS = new Set([
  "cn-north-1",
  "cn-northwest-1",
]);
const AWS_ISO_REGIONS = new Set([
  "us-iso-east-1",
]);
const AWS_ISO_B_REGIONS = new Set([
  "us-isob-east-1",
]);
const AWS_US_GOV_REGIONS = new Set([
  "us-gov-west-1",
  "us-gov-east-1",
]);

export let defaultEndpointProvider: EndpointProvider;
defaultEndpointProvider = function(
  region: string,
  options?: EndpointOptions
) {
  switch (region) {
    // First, try to match exact region names.
    case "aws-cn-global":
      return {
        hostname: "iam.cn-north-1.amazonaws.com.cn",
        signingRegion: "cn-north-1",
      };
    case "aws-global":
      return {
        hostname: "iam.amazonaws.com",
        signingRegion: "us-east-1",
      };
    case "aws-iso-b-global":
      return {
        hostname: "iam.us-isob-east-1.sc2s.sgov.gov",
        signingRegion: "us-isob-east-1",
      };
    case "aws-iso-global":
      return {
        hostname: "iam.us-iso-east-1.c2s.ic.gov",
        signingRegion: "us-iso-east-1",
      };
    case "aws-us-gov-global":
      return {
        hostname: "iam.us-gov.amazonaws.com",
        signingRegion: "us-gov-west-1",
      };
    // Next, try to match partition endpoints.
    default:
      if (region in AWS_REGIONS) {
        return defaultEndpointProvider("aws-global");
      }
      if (region in AWS_CN_REGIONS) {
        return defaultEndpointProvider("aws-cn-global");
      }
      if (region in AWS_ISO_REGIONS) {
        return defaultEndpointProvider("aws-iso-global");
      }
      if (region in AWS_ISO_B_REGIONS) {
        return defaultEndpointProvider("aws-iso-b-global");
      }
      if (region in AWS_US_GOV_REGIONS) {
        return defaultEndpointProvider("aws-us-gov-global");
      }
      // Finally, assume it's an AWS partition endpoint.
      return defaultEndpointProvider("aws-global");
  }
}

budgets

/// This example is of budgets. It's only in the
/// aws partition and it uses a partition endpoint.

// Partition default templates
const AWS_TEMPLATE = "budgets.{region}.amazonaws.com";
const AWS_CN_TEMPLATE = "budgets.{region}.amazonaws.com.cn";
const AWS_ISO_TEMPLATE = "budgets.{region}.c2s.ic.gov";
const AWS_ISO_B_TEMPLATE = "budgets.{region}.sc2s.sgov.gov";
const AWS_US_GOV_TEMPLATE = "budgets.{region}.amazonaws.com";

// Partition regions
const AWS_REGIONS = new Set([
  "ap-south-1",
  "eu-north-1",
  "eu-west-3",
  "eu-west-2",
  "eu-west-1",
  "ap-northeast-2",
  "ap-northeast-1",
  "me-south-1",
  "ca-central-1",
  "sa-east-1",
  "ap-east-1",
  "ap-southeast-1",
  "ap-southeast-2",
  "eu-central-1",
  "us-east-1",
  "us-east-2",
  "us-west-1",
  "us-west-2",
]);
const AWS_CN_REGIONS = new Set([
  "cn-north-1",
  "cn-northwest-1",
]);
const AWS_ISO_REGIONS = new Set([
  "us-iso-east-1",
]);
const AWS_ISO_B_REGIONS = new Set([
  "us-isob-east-1",
]);
const AWS_US_GOV_REGIONS = new Set([
  "us-gov-west-1",
  "us-gov-east-1",
]);

export let defaultEndpointProvider: EndpointProvider;
defaultEndpointProvider = function(
  region: string,
  options?: EndpointOptions
) {
  switch (region) {
    // First, try to match exact region names.
    case "aws-global":
      return {
        hostname: "budgets.amazonaws.com",
        signingRegion: "us-east-1",
      };
    // Next, try to match partition endpoints.
    default:
      if (region in AWS_REGIONS) {
        return defaultEndpointProvider("aws-global");
      }
      if (region in AWS_CN_REGIONS) {
        return {
          hostname: AWS_CN_TEMPLATE.replace("{region}", region),
        };
      }
      if (region in AWS_ISO_REGIONS) {
        return {
          hostname: AWS_ISO_TEMPLATE.replace("{region}", region),
        };
      }
      if (region in AWS_ISO_B_REGIONS) {
        return {
          hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region),
        };
      }
      if (region in AWS_US_GOV_REGIONS) {
        return {
          hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region),
        };
      }
      // Finally, assume it's an AWS partition endpoint.
      return defaultEndpointProvider("aws-global");
  }
}

sts

/// This example shows how STS resolves endpoints.

// Partition default templates
const AWS_TEMPLATE = "sts.{region}.amazonaws.com";
const AWS_CN_TEMPLATE = "sts.{region}.amazonaws.com.cn";
const AWS_ISO_TEMPLATE = "sts.{region}.c2s.ic.gov";
const AWS_ISO_B_TEMPLATE = "sts.{region}.sc2s.sgov.gov";
const AWS_US_GOV_TEMPLATE = "sts.{region}.amazonaws.com";

// Partition regions
const AWS_REGIONS = new Set([
  "ap-south-1",
  "eu-north-1",
  "eu-west-3",
  "eu-west-2",
  "eu-west-1",
  "ap-northeast-2",
  "ap-northeast-1",
  "me-south-1",
  "ca-central-1",
  "sa-east-1",
  "ap-east-1",
  "ap-southeast-1",
  "ap-southeast-2",
  "eu-central-1",
  "us-east-1",
  "us-east-2",
  "us-west-1",
  "us-west-2",
]);
const AWS_CN_REGIONS = new Set([
  "cn-north-1",
  "cn-northwest-1",
]);
const AWS_ISO_REGIONS = new Set([
  "us-iso-east-1",
]);
const AWS_ISO_B_REGIONS = new Set([
  "us-isob-east-1",
]);
const AWS_US_GOV_REGIONS = new Set([
  "us-gov-west-1",
  "us-gov-east-1",
]);

export let defaultEndpointProvider: EndpointProvider;
defaultEndpointProvider = function(
  region: string,
  options?: EndpointOptions
) {
  switch (region) {
    // First, try to match exact region names.
    case "ap-east-1":
      return {
        hostname: "sts.ap-east-1.amazonaws.com",
      };
    case "ap-northeast-1":
      return {
        hostname: "sts.ap-northeast-1.amazonaws.com",
      };
    case "ap-northeast-2":
      return {
        hostname: "sts.ap-northeast-2.amazonaws.com",
      };
    case "ap-south-1":
      return {
        hostname: "sts.ap-south-1.amazonaws.com",
      };
    case "ap-southeast-1":
      return {
        hostname: "sts.ap-southeast-1.amazonaws.com",
      };
    case "ap-southeast-2":
      return {
        hostname: "sts.ap-southeast-2.amazonaws.com",
      };
    case "aws-global":
      return {
        hostname: "sts.amazonaws.com",
        signingRegion: "us-east-1",
      };
    case "ca-central-1":
      return {
        hostname: "sts.ca-central-1.amazonaws.com",
      };
    case "cn-north-1":
      return {
        hostname: "sts.cn-north-1.amazonaws.com.cn",
      };
    case "cn-northwest-1":
      return {
        hostname: "sts.cn-northwest-1.amazonaws.com.cn",
      };
    case "eu-central-1":
      return {
        hostname: "sts.eu-central-1.amazonaws.com",
      };
    case "eu-north-1":
      return {
        hostname: "sts.eu-north-1.amazonaws.com",
      };
    case "eu-west-1":
      return {
        hostname: "sts.eu-west-1.amazonaws.com",
      };
    case "eu-west-2":
      return {
        hostname: "sts.eu-west-2.amazonaws.com",
      };
    case "eu-west-3":
      return {
        hostname: "sts.eu-west-3.amazonaws.com",
      };
    case "me-south-1":
      return {
        hostname: "sts.me-south-1.amazonaws.com",
      };
    case "sa-east-1":
      return {
        hostname: "sts.sa-east-1.amazonaws.com",
      };
    case "us-east-1":
      return {
        hostname: "sts.us-east-1.amazonaws.com",
      };
    case "us-east-1-fips":
      return {
        hostname: "sts-fips.us-east-1.amazonaws.com",
        signingRegion: "us-east-1",
      };
    case "us-east-2":
      return {
        hostname: "sts.us-east-2.amazonaws.com",
      };
    case "us-east-2-fips":
      return {
        hostname: "sts-fips.us-east-2.amazonaws.com",
        signingRegion: "us-east-2",
      };
    case "us-gov-east-1":
      return {
        hostname: "sts.us-gov-east-1.amazonaws.com",
      };
    case "us-gov-west-1":
      return {
        hostname: "sts.us-gov-west-1.amazonaws.com",
      };
    case "us-iso-east-1":
      return {
        hostname: "sts.us-iso-east-1.c2s.ic.gov",
      };
    case "us-isob-east-1":
      return {
        hostname: "sts.us-isob-east-1.sc2s.sgov.gov",
      };
    case "us-west-1":
      return {
        hostname: "sts.us-west-1.amazonaws.com",
      };
    case "us-west-1-fips":
      return {
        hostname: "sts-fips.us-west-1.amazonaws.com",
        signingRegion: "us-west-1",
      };
    case "us-west-2":
      return {
        hostname: "sts.us-west-2.amazonaws.com",
      };
    case "us-west-2-fips":
      return {
        hostname: "sts-fips.us-west-2.amazonaws.com",
        signingRegion: "us-west-2",
      };
    // Next, try to match partition endpoints.
    default:
      if (region in AWS_REGIONS) {
        return {
          hostname: AWS_TEMPLATE.replace("{region}", region),
        };
      }
      if (region in AWS_CN_REGIONS) {
        return {
          hostname: AWS_CN_TEMPLATE.replace("{region}", region),
        };
      }
      if (region in AWS_ISO_REGIONS) {
        return {
          hostname: AWS_ISO_TEMPLATE.replace("{region}", region),
        };
      }
      if (region in AWS_ISO_B_REGIONS) {
        return {
          hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region),
        };
      }
      if (region in AWS_US_GOV_REGIONS) {
        return {
          hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region),
        };
      }
      // Finally, assume it's an AWS partition endpoint.
      return {
        hostname: AWS_TEMPLATE.replace("{region}", region),
      };
  }
}

@codecov-io
Copy link

codecov-io commented Nov 27, 2019

Codecov Report

Merging #472 into smithy-codegen will increase coverage by 0.62%.
The diff coverage is n/a.

Impacted file tree graph

@@                Coverage Diff                 @@
##           smithy-codegen     #472      +/-   ##
==================================================
+ Coverage           94.54%   95.17%   +0.62%     
==================================================
  Files                  68       72       +4     
  Lines                1284     1389     +105     
  Branches              256      272      +16     
==================================================
+ Hits                 1214     1322     +108     
+ Misses                 70       67       -3
Impacted Files Coverage Δ
packages/node-http-handler/src/server.mock.ts 74.19% <0%> (-2.48%) ⬇️
packages/signature-v4/src/constants.ts 100% <0%> (ø) ⬆️
packages/signature-v4/src/suite.fixture.ts 100% <0%> (ø) ⬆️
...ackages/node-http-handler/src/node-http-handler.ts 100% <0%> (ø) ⬆️
packages/signature-v4/src/SignatureV4.ts 100% <0%> (ø) ⬆️
packages/http-serialization/src/index.ts 100% <0%> (ø)
packages/http-serialization/src/constants.ts 100% <0%> (ø)
...ackages/http-serialization/src/requests.fixture.ts 100% <0%> (ø)
...ckages/http-serialization/src/responses.fixture.ts 100% <0%> (ø)
...ckages/node-http-handler/src/node-http2-handler.ts 90% <0%> (+0.34%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e08b134...cf0c0a3. Read the comment docs.

@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mtdowling mtdowling force-pushed the add-endpoint-generation branch from 45d0cfa to bcf3d5b Compare November 27, 2019 01:40
@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@srchase srchase added the smithy-codegen Changes regarding supporting smithy model. Will be merged to smithy-codegen branch label Nov 27, 2019
@AllanZhengYP AllanZhengYP force-pushed the add-endpoint-generation branch from bcf3d5b to d2acbaa Compare December 10, 2019 20:02
@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

mtdowling and others added 5 commits December 13, 2019 15:13
Now in each client you can run `yarn build` or `yarn pretest`. They are
the same that build js files to `dist` folder. In the workspace root,
you can run `yarn: build:all` to compile the whole workspace from .ts to
.js. You can also `yarn: test:all` to run all the test we have. Furthermore,
you can run `yarn test:functional` to run the hostname integration test.
This script can only be called after the repo is compiled.
@AllanZhengYP AllanZhengYP force-pushed the add-endpoint-generation branch from d2acbaa to fd42ffb Compare December 13, 2019 23:16
@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@AllanZhengYP AllanZhengYP force-pushed the add-endpoint-generation branch from fd42ffb to 7e3eaf3 Compare December 13, 2019 23:46
@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@AllanZhengYP AllanZhengYP force-pushed the add-endpoint-generation branch from e581cfc to 0daf9ad Compare December 14, 2019 00:08
@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@AllanZhengYP
Copy link
Contributor

AllanZhengYP commented Dec 14, 2019

@mtdowling RIP is integrated in the client config, and functional test is added. But it only contain rds-data test case for now. We will add more cases as we generate more clients.

This PR should be merged to unblock the client codegen. After we generate the clients then we can test whether all the clients can infer the hostname correctly

@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

sha256
} = input;
let signer: Provider<RequestSigner>;
if (input.signer) signer = normalizeProvider(input.signer);
Copy link
Member Author

Choose a reason for hiding this comment

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

This should be expanded out into a block form. Short form if statements are generally harder to read, and this one in particular is hard to read because the else uses a block but the first if statement doesn't.

I also think some comments in here to say what's going on would be useful to help future maintainers follow the code

//do nothing
}
}

Copy link
Member Author

Choose a reason for hiding this comment

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

nit: extra newlines

LanguageTarget target
) {
switch (target) {
case BROWSER:
Copy link
Member Author

Choose a reason for hiding this comment

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

nit: You could omit the BROWSER and NODE entries in the switch.

@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mtdowling
Copy link
Member Author

LGTM

@AllanZhengYP AllanZhengYP merged commit fb2f6bc into smithy-codegen Dec 17, 2019
@lock
Copy link

lock bot commented Dec 26, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 26, 2019
@trivikr trivikr deleted the add-endpoint-generation branch January 8, 2020 04:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
smithy-codegen Changes regarding supporting smithy model. Will be merged to smithy-codegen branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants