Skip to content

Commit

Permalink
Merge branch 'master' into markusl/fix-9980
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Dec 8, 2020
2 parents 41245e6 + ae2e9c1 commit 5efe812
Show file tree
Hide file tree
Showing 82 changed files with 26,347 additions and 563 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class AppMeshExtension extends ServiceExtension {
}
}

public modifyTaskDefinitionProps(props: ecs.TaskDefinitionProps) {
public modifyTaskDefinitionProps(props: ecs.TaskDefinitionProps): ecs.TaskDefinitionProps {
// Find the app extension, to get its port
const containerextension = this.parentService.serviceDescription.get('service-container') as Container;

Expand Down Expand Up @@ -223,7 +223,7 @@ export class AppMeshExtension extends ServiceExtension {
}

// Enable CloudMap for the service.
public modifyServiceProps(props: ServiceBuild) {
public modifyServiceProps(props: ServiceBuild): ServiceBuild {
return {
...props,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class AssignPublicIpExtension extends ServiceExtension {
}
}

public modifyServiceProps(props: ServiceBuild) {
public modifyServiceProps(props: ServiceBuild): ServiceBuild {
return {
...props,
assignPublicIp: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class Container extends ServiceExtension {

// This hook sets the overall task resource requirements to the
// resource requirements of the application itself.
public modifyTaskDefinitionProps(props: ecs.TaskDefinitionProps) {
public modifyTaskDefinitionProps(props: ecs.TaskDefinitionProps): ecs.TaskDefinitionProps {
return {
...props,
cpu: this.props.cpu.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export abstract class ServiceExtension {
* the task.
* @param props - Properties of the task definition to be created
*/
public modifyTaskDefinitionProps(props: ecs.TaskDefinitionProps) {
public modifyTaskDefinitionProps(props: ecs.TaskDefinitionProps): ecs.TaskDefinitionProps {
return {
...props,
} as ecs.TaskDefinitionProps;
Expand Down Expand Up @@ -185,7 +185,7 @@ export abstract class ServiceExtension {
* of the service to be created
* @param props - The service properties to mutate
*/
public modifyServiceProps(props: ServiceBuild) {
public modifyServiceProps(props: ServiceBuild): ServiceBuild {
return {
...props,
} as ServiceBuild;
Expand Down Expand Up @@ -225,7 +225,7 @@ export abstract class ContainerMutatingHook {
* settings of the application container.
* @param props - The container definition to mutate
*/
public mutateContainerDefinition(props: ecs.ContainerDefinitionOptions) {
public mutateContainerDefinition(props: ecs.ContainerDefinitionOptions): ecs.ContainerDefinitionOptions {
return {
...props,
} as ecs.ContainerDefinitionOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class FirelensMutatingHook extends ContainerMutatingHook {
this.logGroup = props.logGroup;
}

public mutateContainerDefinition(props: ecs.ContainerDefinitionOptions) {
public mutateContainerDefinition(props: ecs.ContainerDefinitionOptions): ecs.ContainerDefinitionOptions {
return {
...props,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class HttpLoadBalancerExtension extends ServiceExtension {
}

// Minor service configuration tweaks to work better with a load balancer
public modifyServiceProps(props: ServiceBuild) {
public modifyServiceProps(props: ServiceBuild): ServiceBuild {
return {
...props,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class ScaleOnCpuUtilization extends ServiceExtension {

// This service modifies properties of the service prior
// to construct creation.
public modifyServiceProps(props: ServiceBuild) {
public modifyServiceProps(props: ServiceBuild): ServiceBuild {
return {
...props,

Expand Down
33 changes: 33 additions & 0 deletions packages/@aws-cdk/aws-acmpca/lib/certificate-authority.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import * as cdk from '@aws-cdk/core';
import { Construct } from 'constructs';

/**
* Interface which all CertificateAuthority based class must implement
*/
export interface ICertificateAuthority extends cdk.IResource {
/**
* The Amazon Resource Name of the Certificate
*
* @attribute
*/
readonly certificateAuthorityArn: string;
}

/**
* Defines a Certificate for ACMPCA
*
* @resource AWS::ACMPCA::CertificateAuthority
*/
export class CertificateAuthority {
/**
* Import an existing Certificate given an ARN
*/
public static fromCertificateAuthorityArn(scope: Construct, id: string, certificateAuthorityArn: string): ICertificateAuthority {
return new class extends cdk.Resource implements ICertificateAuthority {
readonly certificateAuthorityArn = certificateAuthorityArn;
}(scope, id);
}

private constructor() {
}
}
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-acmpca/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// AWS::ACMPCA CloudFormation Resources:
export * from './acmpca.generated';
export * from './certificate-authority';
41 changes: 26 additions & 15 deletions packages/@aws-cdk/aws-apigateway/lib/restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CfnOutput, IResource as IResourceBase, Resource, Stack } from '@aws-cdk
import { Construct } from 'constructs';
import { ApiDefinition } from './api-definition';
import { ApiKey, ApiKeyOptions, IApiKey } from './api-key';
import { ApiGatewayMetrics } from './apigateway-canned-metrics.generated';
import { CfnAccount, CfnRestApi } from './apigateway.generated';
import { CorsOptions } from './cors';
import { Deployment } from './deployment';
Expand Down Expand Up @@ -397,74 +398,77 @@ export abstract class RestApiBase extends Resource implements IRestApi {
metricName,
dimensions: { ApiName: this.restApiName },
...props,
});
}).attachTo(this);
}

/**
* Metric for the number of client-side errors captured in a given period.
*
* @default - sum over 5 minutes
* Default: sum over 5 minutes
*/
public metricClientError(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.metric('4XXError', { statistic: 'Sum', ...props });
return this.cannedMetric(ApiGatewayMetrics._4XxErrorSum, props);
}

/**
* Metric for the number of server-side errors captured in a given period.
*
* @default - sum over 5 minutes
* Default: sum over 5 minutes
*/
public metricServerError(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.metric('5XXError', { statistic: 'Sum', ...props });
return this.cannedMetric(ApiGatewayMetrics._5XxErrorSum, props);
}

/**
* Metric for the number of requests served from the API cache in a given period.
*
* @default - sum over 5 minutes
* Default: sum over 5 minutes
*/
public metricCacheHitCount(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.metric('CacheHitCount', { statistic: 'Sum', ...props });
return this.cannedMetric(ApiGatewayMetrics.cacheHitCountSum, props);
}

/**
* Metric for the number of requests served from the backend in a given period,
* when API caching is enabled.
*
* @default - sum over 5 minutes
* Default: sum over 5 minutes
*/
public metricCacheMissCount(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.metric('CacheMissCount', { statistic: 'Sum', ...props });
return this.cannedMetric(ApiGatewayMetrics.cacheMissCountSum, props);
}

/**
* Metric for the total number API requests in a given period.
*
* @default - SampleCount over 5 minutes
* Default: samplecount over 5 minutes
*/
public metricCount(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.metric('Count', { statistic: 'SampleCount', ...props });
return this.cannedMetric(ApiGatewayMetrics.countSum, {
statistic: 'SampleCount',
...props,
});
}

/**
* Metric for the time between when API Gateway relays a request to the backend
* and when it receives a response from the backend.
*
* @default - no statistic
* Default: average over 5 minutes.
*/
public metricIntegrationLatency(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.metric('IntegrationLatency', props);
return this.cannedMetric(ApiGatewayMetrics.integrationLatencyAverage, props);
}

/**
* The time between when API Gateway receives a request from a client
* and when it returns a response to the client.
* The latency includes the integration latency and other API Gateway overhead.
*
* @default - no statistic
* Default: average over 5 minutes.
*/
public metricLatency(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.metric('Latency', props);
return this.cannedMetric(ApiGatewayMetrics.latencyAverage, props);
}

/**
Expand Down Expand Up @@ -544,6 +548,13 @@ export abstract class RestApiBase extends Resource implements IRestApi {
}
return undefined;
}

private cannedMetric(fn: (dims: { ApiName: string }) => cloudwatch.MetricProps, props?: cloudwatch.MetricOptions) {
return new cloudwatch.Metric({
...fn({ ApiName: this.restApiName }),
...props,
}).attachTo(this);
}
}

/**
Expand Down
32 changes: 16 additions & 16 deletions packages/@aws-cdk/aws-apigatewayv2/lib/http/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Metric, MetricOptions } from '@aws-cdk/aws-cloudwatch';
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
import { Duration, IResource, Resource } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnApi, CfnApiProps } from '../apigatewayv2.generated';
Expand Down Expand Up @@ -28,43 +28,43 @@ export interface IHttpApi extends IResource {
*
* @default - average over 5 minutes
*/
metric(metricName: string, props?: MetricOptions): Metric;
metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric;

/**
* Metric for the number of client-side errors captured in a given period.
*
* @default - sum over 5 minutes
*/
metricClientError(props?: MetricOptions): Metric;
metricClientError(props?: cloudwatch.MetricOptions): cloudwatch.Metric;

/**
* Metric for the number of server-side errors captured in a given period.
*
* @default - sum over 5 minutes
*/
metricServerError(props?: MetricOptions): Metric;
metricServerError(props?: cloudwatch.MetricOptions): cloudwatch.Metric;

/**
* Metric for the amount of data processed in bytes.
*
* @default - sum over 5 minutes
*/
metricDataProcessed(props?: MetricOptions): Metric;
metricDataProcessed(props?: cloudwatch.MetricOptions): cloudwatch.Metric;

/**
* Metric for the total number API requests in a given period.
*
* @default - SampleCount over 5 minutes
*/
metricCount(props?: MetricOptions): Metric;
metricCount(props?: cloudwatch.MetricOptions): cloudwatch.Metric;

/**
* Metric for the time between when API Gateway relays a request to the backend
* and when it receives a response from the backend.
*
* @default - no statistic
*/
metricIntegrationLatency(props?: MetricOptions): Metric;
metricIntegrationLatency(props?: cloudwatch.MetricOptions): cloudwatch.Metric;

/**
* The time between when API Gateway receives a request from a client
Expand All @@ -73,7 +73,7 @@ export interface IHttpApi extends IResource {
*
* @default - no statistic
*/
metricLatency(props?: MetricOptions): Metric;
metricLatency(props?: cloudwatch.MetricOptions): cloudwatch.Metric;

/**
* Add a new VpcLink
Expand Down Expand Up @@ -186,36 +186,36 @@ abstract class HttpApiBase extends Resource implements IHttpApi { // note that t
public abstract readonly httpApiId: string;
private vpcLinks: Record<string, VpcLink> = {};

public metric(metricName: string, props?: MetricOptions): Metric {
return new Metric({
public metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return new cloudwatch.Metric({
namespace: 'AWS/ApiGateway',
metricName,
dimensions: { ApiId: this.httpApiId },
...props,
}).attachTo(this);
}

public metricClientError(props?: MetricOptions): Metric {
public metricClientError(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.metric('4XXError', { statistic: 'Sum', ...props });
}

public metricServerError(props?: MetricOptions): Metric {
public metricServerError(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.metric('5XXError', { statistic: 'Sum', ...props });
}

public metricDataProcessed(props?: MetricOptions): Metric {
public metricDataProcessed(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.metric('DataProcessed', { statistic: 'Sum', ...props });
}

public metricCount(props?: MetricOptions): Metric {
public metricCount(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.metric('Count', { statistic: 'SampleCount', ...props });
}

public metricIntegrationLatency(props?: MetricOptions): Metric {
public metricIntegrationLatency(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.metric('IntegrationLatency', props);
}

public metricLatency(props?: MetricOptions): Metric {
public metricLatency(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.metric('Latency', props);
}

Expand Down
Loading

0 comments on commit 5efe812

Please sign in to comment.