Skip to content

Commit

Permalink
Merge branch 'main' into add-batch-secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jul 5, 2022
2 parents 4a6ee8e + e274edc commit df24128
Show file tree
Hide file tree
Showing 462 changed files with 7,176 additions and 4,478 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.v2.alpha.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.30.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.29.1-alpha.0...v2.30.0-alpha.0) (2022-07-01)

## [2.29.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.29.0-alpha.0...v2.29.1-alpha.0) (2022-06-24)

## [2.29.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.28.1-alpha.0...v2.29.0-alpha.0) (2022-06-22)
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.30.0](https://github.com/aws/aws-cdk/compare/v2.29.1...v2.30.0) (2022-07-01)

### Features

* **appmesh:** ipv6 support for app mesh ([#20766](https://github.com/aws/aws-cdk/issues/20766)) ([b1e6d62](https://github.com/aws/aws-cdk/commit/b1e6d62ed6b6ede0362d0a68d804660e84efe5cb)), closes [#20737](https://github.com/aws/aws-cdk/issues/20737)
* **cognito:** make `grant()` available on `IUserPool` ([#20799](https://github.com/aws/aws-cdk/issues/20799)) ([a1df570](https://github.com/aws/aws-cdk/commit/a1df570b89c6d456077bb934e0bf08217677ef1f)), closes [#20285](https://github.com/aws/aws-cdk/issues/20285)
* **iam:** PolicyStatements can be frozen ([#20911](https://github.com/aws/aws-cdk/issues/20911)) ([3bf737b](https://github.com/aws/aws-cdk/commit/3bf737bd172eda016d2e9bb7c5f40c001399fd23))
* **lambda:** grant function permissions to an AWS organization ([#19975](https://github.com/aws/aws-cdk/issues/19975)) ([2566017](https://github.com/aws/aws-cdk/commit/2566017a83ec4f9c2c5cefda4585a3f71e3516e7)), closes [#19538](https://github.com/aws/aws-cdk/issues/19538) [#20146](https://github.com/aws/aws-cdk/issues/20146)
* **rds:** add missing aurora postgres versions ([#20830](https://github.com/aws/aws-cdk/issues/20830)) ([2151a0e](https://github.com/aws/aws-cdk/commit/2151a0e9b988723e050e6f37ed1780cced16c519))


### Bug Fixes

* **apigateway:** Explicitly test for undefined instead of falsey for stage default options ([#20868](https://github.com/aws/aws-cdk/issues/20868)) ([b368a31](https://github.com/aws/aws-cdk/commit/b368a315cab0cedf03298083f5f1fb809bd1d1f2))
* **eks:** revert shell=True and allow public ecr to work ([#20724](https://github.com/aws/aws-cdk/issues/20724)) ([de153fc](https://github.com/aws/aws-cdk/commit/de153fcdd47a4cdcd1d156d5e19684969d990c8e))
* **pipelines:** 'ConfirmPermissionsBroadening' uses wrong node version ([#20861](https://github.com/aws/aws-cdk/issues/20861)) ([bac965e](https://github.com/aws/aws-cdk/commit/bac965e9c4d435ae45d5cf16aa809f33bbb05a0f))
* **secretsmanager:** SecretRotation app does not set DeletionPolicy ([#20901](https://github.com/aws/aws-cdk/issues/20901)) ([f2b4eff](https://github.com/aws/aws-cdk/commit/f2b4effc903ab3a36dc925516f3329f236d03a70))

## [2.29.1](https://github.com/aws/aws-cdk/compare/v2.29.0...v2.29.1) (2022-06-24)


Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@ $ yarn watch & # runs in the background
[conventionalcommits](https://www.conventionalcommits.org).
* The title must begin with `feat(module): title`, `fix(module): title`, `refactor(module): title` or
`chore(module): title`.
* `feat`: indicates a feature added (requires tests and README updates in principle, but can be suppressed)
* `fix`: indicates a bug fixes (requires tests in principle, but can be suppressed)
* `docs`: indicates updated documentation (docstrings or Markdown files)
* `refactor`: indicates a feature-preserving refactoring
* `chore`: something without directly visible user benefit (does not end up in the CHANGELOG). Typically used for build scripts, config, or changes so minor they don't warrant showing up the CHANGELOG.
* Titles for `feat` and `fix` PRs end up in the change log. Think about what makes most sense for users reading the changelog while writing them.
* `feat`: describe the feature (not the action of creating the commit or PR, for example, avoid words like "added" or "changed")
* `fix`: describe the bug (not the solution)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
[![Go Reference](https://pkg.go.dev/badge/github.com/aws/aws-cdk-go/awscdk.svg)](https://pkg.go.dev/github.com/aws/aws-cdk-go/awscdk)
[![Mergify](https://img.shields.io/endpoint.svg?url=https://gh.mergify.io/badges/aws/aws-cdk&style=flat)](https://mergify.io)

[![View on Construct Hub](https://constructs.dev/badge?package=aws-cdk-lib)](https://constructs.dev/packages/aws-cdk-lib)

The **AWS Cloud Development Kit (AWS CDK)** is an open-source software development
framework to define cloud infrastructure in code and provision it through AWS CloudFormation.

Expand Down
10 changes: 5 additions & 5 deletions docs/DESIGN_GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ The AWS Construct Library, which is shipped as part of the AWS CDK constructs
representing AWS resources.

The AWS Construct Library has multiple layers of constructs, beginning
with low-level constructs, which we call _CFN Resources_ (or L1, short for
"level 1") or CFN Resources (short for CloudFormation). These constructs
with low-level constructs, which we call _CFN Resources_ (short for
CloudFormation resources), or L1 (short for "level 1"). These constructs
directly represent all resources available in AWS CloudFormation. CFN Resources
are periodically generated from the AWS CloudFormation Resource
Specification. They are named **Cfn**_Xyz_, where _Xyz_ is name of the
Expand Down Expand Up @@ -456,7 +456,7 @@ A prop should be *required* only if there is no possible sensible default value
that can be provided *or calculated*.

Sensible defaults have a tremendous impact on the developer experience. They
offer a quick way to get started with minimal cognitive, but do not limit users
offer a quick way to get started with minimal cognitive load, but do not limit users
from harnessing the full power of the resource, and customizing its behavior.

> A good way to determine what's the right sensible default is to refer to the
Expand Down Expand Up @@ -754,10 +754,10 @@ interface IFoo extends IConstruct {
class Foo extends Construct implements IFoo {
public bar() { }

/** @mutating */
@config
public goo() { }

public mutateMe() { } // ERROR! missing "@mutating" or missing on IFoo
public mutateMe() { } // ERROR! missing "@config" or missing on IFoo
}
```
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export class Stage extends Resource implements IStage {
};

// if any of them are defined, add an entry for '/*/*'.
const hasCommonOptions = Object.keys(commonMethodOptions).map(v => (commonMethodOptions as any)[v]).filter(x => x).length > 0;
const hasCommonOptions = Object.keys(commonMethodOptions).map(v => (commonMethodOptions as any)[v]).filter(x => x !== undefined).length > 0;
if (hasCommonOptions) {
settings.push(renderEntry('/*/*', commonMethodOptions));
}
Expand Down
27 changes: 27 additions & 0 deletions packages/@aws-cdk/aws-apigateway/test/stage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Template } from '@aws-cdk/assertions';
import * as logs from '@aws-cdk/aws-logs';
import * as cdk from '@aws-cdk/core';
import * as apigateway from '../lib';
import { ApiDefinition } from '../lib';

describe('stage', () => {
test('minimal setup', () => {
Expand Down Expand Up @@ -396,4 +397,30 @@ describe('stage', () => {
accessLogFormat: testFormat,
})).toThrow(/Access log format is specified without a destination/);
});

test('default throttling settings', () => {
// GIVEN
const stack = new cdk.Stack();
new apigateway.SpecRestApi(stack, 'testapi', {
apiDefinition: ApiDefinition.fromInline({
openapi: '3.0.2',
}),
deployOptions: {
throttlingBurstLimit: 0,
throttlingRateLimit: 0,
metricsEnabled: false,
},
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ApiGateway::Stage', {
MethodSettings: [{
DataTraceEnabled: false,
HttpMethod: '*',
ResourcePath: '/*',
ThrottlingBurstLimit: 0,
ThrottlingRateLimit: 0,
}],
});
});
});
53 changes: 53 additions & 0 deletions packages/@aws-cdk/aws-appmesh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ const mesh = new appmesh.Mesh(this, 'AppMesh', {
});
```

A mesh with an IP preference can be created by providing the property `serviceDiscovery` that specifes an `ipPreference`.

```ts
const mesh = new appmesh.Mesh(this, 'AppMesh', {
meshName: 'myAwsMesh',
serviceDiscovery: {
ipPreference: appmesh.IpPreference.IPV4_ONLY,
},
});
```

## Adding VirtualRouters

A _mesh_ uses _virtual routers_ as logical units to route requests to _virtual nodes_.
Expand Down Expand Up @@ -425,6 +436,48 @@ const gateway = new appmesh.VirtualGateway(this, 'gateway', {
});
```

### Adding an IP Preference to a Virtual Node

An `ipPreference` can be specified as part of a Virtual Node's service discovery. An IP preference defines how clients for this Virtual Node will interact with it.

There a four different IP preferences available to use which each specify what IP versions this Virtual Node will use and prefer.

- `IPv4_ONLY` - Only use IPv4. For CloudMap service discovery, only IPv4 addresses returned from CloudMap will be used. For DNS service discovery, Envoy's DNS resolver will only resolve DNS queries for IPv4.

- `IPv4_PREFERRED` - Prefer IPv4 and fall back to IPv6. For CloudMap service discovery, an IPv4 address will be used if returned from CloudMap. Otherwise, an IPv6 address will be used if available. For DNS service discovery, Envoy's DNS resolver will first attempt to resolve DNS queries using IPv4 and fall back to IPv6.

- `IPv6_ONLY` - Only use IPv6. For CloudMap service discovery, only IPv6 addresses returned from CloudMap will be used. For DNS service discovery, Envoy's DNS resolver will only resolve DNS queries for IPv6.

- `IPv6_PREFERRED` - Prefer IPv6 and fall back to IPv4. For CloudMap service discovery, an IPv6 address will be used if returned from CloudMap. Otherwise, an IPv4 address will be used if available. For DNS service discovery, Envoy's DNS resolver will first attempt to resolve DNS queries using IPv6 and fall back to IPv4.

```ts
const mesh = new appmesh.Mesh(stack, 'mesh', {
meshName: 'mesh-with-preference',
});

// Virtual Node with DNS service discovery and an IP preference
const dnsNode = new appmesh.VirtualNode(stack, 'dns-node', {
mesh,
serviceDiscovery: appmesh.ServiceDiscovery.dns('test', appmesh.DnsResponseType.LOAD_BALANCER, appmesh.IpPreference.IPV4_ONLY),
});

// Virtual Node with CloudMap service discovery and an IP preference
const vpc = new ec2.Vpc(stack, 'vpc');
const namespace = new cloudmap.PrivateDnsNamespace(stack, 'test-namespace', {
vpc,
name: 'domain.local',
});
const service = namespace.createService('Svc');

const instanceAttribute : { [key: string]: string} = {};
instanceAttribute.testKey = 'testValue';

const cloudmapNode = new appmesh.VirtualNode(stack, 'cloudmap-node', {
mesh,
serviceDiscovery: appmesh.ServiceDiscovery.cloudMap(service, instanceAttribute, appmesh.IpPreference.IPV4_ONLY),
});
```

## Adding a Route

A _route_ matches requests with an associated virtual router and distributes traffic to its associated virtual nodes.
Expand Down
9 changes: 9 additions & 0 deletions packages/@aws-cdk/aws-appmesh/lib/mesh.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as cdk from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnMesh } from './appmesh.generated';
import { MeshServiceDiscovery } from './service-discovery';
import { VirtualGateway, VirtualGatewayBaseProps } from './virtual-gateway';
import { VirtualNode, VirtualNodeBaseProps } from './virtual-node';
import { VirtualRouter, VirtualRouterBaseProps } from './virtual-router';
Expand Down Expand Up @@ -124,6 +125,13 @@ export interface MeshProps {
* @default DROP_ALL
*/
readonly egressFilter?: MeshFilterType;

/**
* Defines how upstream clients will discover VirtualNodes in the Mesh
*
* @default - No Service Discovery
*/
readonly serviceDiscovery?: MeshServiceDiscovery;
}

/**
Expand Down Expand Up @@ -187,6 +195,7 @@ export class Mesh extends MeshBase {
egressFilter: props.egressFilter ? {
type: props.egressFilter,
} : undefined,
serviceDiscovery: props.serviceDiscovery,
},
});

Expand Down
66 changes: 60 additions & 6 deletions packages/@aws-cdk/aws-appmesh/lib/service-discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,52 @@ import * as cloudmap from '@aws-cdk/aws-servicediscovery';
import { Construct } from 'constructs';
import { CfnVirtualNode } from './appmesh.generated';

/**
* Enum of supported IP preferences.
* Used to dictate the IP version for mesh wide and virtual node service discovery.
* Also used to specify the IP version that a sidecar Envoy uses when sending traffic to a local application.
*/

export enum IpPreference {
/**
* Use IPv4 when sending traffic to a local application.
* Only use IPv4 for service discovery.
*/
IPV4_ONLY = 'IPv4_ONLY',
/**
* Use IPv4 when sending traffic to a local application.
* First attempt to use IPv4 and fall back to IPv6 for service discovery.
*/
IPV4_PREFERRED = 'IPv4_PREFERRED',
/**
* Use IPv6 when sending traffic to a local application.
* Only use IPv6 for service discovery.
*/
IPV6_ONLY = 'IPv6_ONLY',
/**
* Use IPv6 when sending traffic to a local application.
* First attempt to use IPv6 and fall back to IPv4 for service discovery.
*/
IPV6_PREFERRED = 'IPv6_PREFERRED'
}

/**
* Properties for Mesh Service Discovery
*/
export interface MeshServiceDiscovery {
/**
* IP preference applied to all Virtual Nodes in the Mesh
*
* @default - No IP preference is applied to any of the Virtual Nodes in the Mesh.
* Virtual Nodes without an IP preference will have the following configured.
* Envoy listeners are configured to bind only to IPv4.
* Envoy will use IPv4 when sending traffic to a local application.
* For DNS service discovery, the Envoy DNS resolver to prefer using IPv6 and fall back to IPv4.
* For CloudMap service discovery, App Mesh will prefer using IPv4 and fall back to IPv6 for IPs returned by CloudMap.
*/
readonly ipPreference?: IpPreference;
}

/**
* Properties for VirtualNode Service Discovery
*/
Expand Down Expand Up @@ -48,9 +94,10 @@ export abstract class ServiceDiscovery {
* @param hostname
* @param responseType Specifies the DNS response type for the virtual node.
* The default is `DnsResponseType.LOAD_BALANCER`.
* @param ipPreference No IP preference is applied to the Virtual Node.
*/
public static dns(hostname: string, responseType?: DnsResponseType): ServiceDiscovery {
return new DnsServiceDiscovery(hostname, responseType);
public static dns(hostname: string, responseType?: DnsResponseType, ipPreference?: IpPreference): ServiceDiscovery {
return new DnsServiceDiscovery(hostname, responseType, ipPreference);
}

/**
Expand All @@ -61,9 +108,10 @@ export abstract class ServiceDiscovery {
* filter instances by any custom attribute that you specified when you
* registered the instance. Only instances that match all of the specified
* key/value pairs will be returned.
* @param ipPreference No IP preference is applied to the Virtual Node.
*/
public static cloudMap(service: cloudmap.IService, instanceAttributes?: {[key: string]: string}): ServiceDiscovery {
return new CloudMapServiceDiscovery(service, instanceAttributes);
public static cloudMap(service: cloudmap.IService, instanceAttributes?: {[key: string]: string}, ipPreference?: IpPreference): ServiceDiscovery {
return new CloudMapServiceDiscovery(service, instanceAttributes, ipPreference);
}

/**
Expand All @@ -75,18 +123,21 @@ export abstract class ServiceDiscovery {
class DnsServiceDiscovery extends ServiceDiscovery {
private readonly hostname: string;
private readonly responseType?: DnsResponseType;
private readonly ipPreference?: IpPreference;

constructor(hostname: string, responseType?: DnsResponseType) {
constructor(hostname: string, responseType?: DnsResponseType, ipPreference?: IpPreference) {
super();
this.hostname = hostname;
this.responseType = responseType;
this.ipPreference = ipPreference;
}

public bind(_scope: Construct): ServiceDiscoveryConfig {
return {
dns: {
hostname: this.hostname,
responseType: this.responseType,
ipPreference: this.ipPreference,
},
};
}
Expand All @@ -95,11 +146,13 @@ class DnsServiceDiscovery extends ServiceDiscovery {
class CloudMapServiceDiscovery extends ServiceDiscovery {
private readonly service: cloudmap.IService;
private readonly instanceAttributes?: {[key: string]: string};
private readonly ipPreference?: IpPreference;

constructor(service: cloudmap.IService, instanceAttributes?: {[key: string]: string}) {
constructor(service: cloudmap.IService, instanceAttributes?: {[key: string]: string}, ipPreference?: IpPreference) {
super();
this.service = service;
this.instanceAttributes = instanceAttributes;
this.ipPreference = ipPreference;
}

public bind(_scope: Construct): ServiceDiscoveryConfig {
Expand All @@ -108,6 +161,7 @@ class CloudMapServiceDiscovery extends ServiceDiscovery {
namespaceName: this.service.namespace.namespaceName,
serviceName: this.service.serviceName,
attributes: renderAttributes(this.instanceAttributes),
ipPreference: this.ipPreference,
},
};
}
Expand Down
7 changes: 6 additions & 1 deletion packages/@aws-cdk/aws-appmesh/test/integ.mesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ const namespace = new cloudmap.PrivateDnsNamespace(stack, 'test-namespace', {
});

const mesh = new appmesh.Mesh(stack, 'mesh');
new appmesh.Mesh(stack, 'mesh-with-preference', {
serviceDiscovery: {
ipPreference: appmesh.IpPreference.IPV4_ONLY,
},
});
const router = mesh.addVirtualRouter('router', {
listeners: [
appmesh.VirtualRouterListener.http(),
Expand All @@ -29,7 +34,7 @@ const virtualService = new appmesh.VirtualService(stack, 'service', {
});

const node = mesh.addVirtualNode('node', {
serviceDiscovery: appmesh.ServiceDiscovery.dns(`node1.${namespace.namespaceName}`),
serviceDiscovery: appmesh.ServiceDiscovery.dns(`node1.${namespace.namespaceName}`, undefined, appmesh.IpPreference.IPV4_ONLY),
listeners: [appmesh.VirtualNodeListener.http({
healthCheck: appmesh.HealthCheck.http({
healthyThreshold: 3,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"17.0.0"}
{"version":"20.0.0"}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "18.0.0",
"version": "20.0.0",
"testCases": {
"aws-appmesh/test/integ.mesh": {
"integ.mesh": {
"stacks": [
"mesh-stack"
],
Expand Down
Loading

0 comments on commit df24128

Please sign in to comment.