Skip to content

Commit

Permalink
Merge branch 'main' into feat/entrypoint-cmd-17092
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Oct 28, 2022
2 parents c44fd86 + 7979d1c commit 6e475a0
Show file tree
Hide file tree
Showing 403 changed files with 4,883 additions and 9,899 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.v2.alpha.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

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.49.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.48.0-alpha.0...v2.49.0-alpha.0) (2022-10-27)

## [2.48.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.47.0-alpha.0...v2.48.0-alpha.0) (2022-10-27)


### Features

* **synthetics:** runtime version syn-nodejs-puppeteer-3.7 ([#22610](https://github.com/aws/aws-cdk/issues/22610)) ([326637c](https://github.com/aws/aws-cdk/commit/326637c2879657bfac33b5cc60dced7471abf7c8))

## [2.47.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.46.0-alpha.0...v2.47.0-alpha.0) (2022-10-20)


Expand Down
32 changes: 32 additions & 0 deletions CHANGELOG.v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@

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.49.0](https://github.com/aws/aws-cdk/compare/v2.48.0...v2.49.0) (2022-10-27)


### Features

* **eks:** support for Kubernetes version 1.23 ([#22638](https://github.com/aws/aws-cdk/issues/22638)) ([4e858f2](https://github.com/aws/aws-cdk/commit/4e858f2ddd4d04de90453ce50c83b68b8595e87f))


### Bug Fixes

* **eks:** kubectl get handler output includes stderr ([#22658](https://github.com/aws/aws-cdk/issues/22658)) ([66d1ed3](https://github.com/aws/aws-cdk/commit/66d1ed36b1628c116d5f1b3397688308d888c9de))

## [2.48.0](https://github.com/aws/aws-cdk/compare/v2.47.0...v2.48.0) (2022-10-27)


### Features

* **cfnspec:** cloudformation spec v93.0.0 ([#22562](https://github.com/aws/aws-cdk/issues/22562)) ([2afb718](https://github.com/aws/aws-cdk/commit/2afb718b02e8fef70729981c2f1cd5b23449dcde))
* **cfnspec:** cloudformation spec v94.0.0 ([#22599](https://github.com/aws/aws-cdk/issues/22599)) ([e5be100](https://github.com/aws/aws-cdk/commit/e5be10049047d29e9e687f5f4f39037275d51d38))
* **cfnspec:** cloudformation spec v94.0.0 ([#22649](https://github.com/aws/aws-cdk/issues/22649)) ([42160fc](https://github.com/aws/aws-cdk/commit/42160fc2e5532acfb6b97652f6ad0e3354b32baa))
* **cli:** allow disabling parallel asset publishing ([#22579](https://github.com/aws/aws-cdk/issues/22579)) ([69981ac](https://github.com/aws/aws-cdk/commit/69981ac07b40ce3f690f6c1ad0010b51f29103a6)), closes [#19367](https://github.com/aws/aws-cdk/issues/19367)
* **ec2:** Vpc supports allocating CIDR from AWS IPAM ([#22458](https://github.com/aws/aws-cdk/issues/22458)) ([7ed9cd1](https://github.com/aws/aws-cdk/commit/7ed9cd14aa5aaff90badb6438a0941fbca2d370c))
* **eks:** support for Kubernetes version 1.22 ([#22604](https://github.com/aws/aws-cdk/issues/22604)) ([91704aa](https://github.com/aws/aws-cdk/commit/91704aa3632dd6424017ae7aafebda832f309315)), closes [#20263](https://github.com/aws/aws-cdk/issues/20263)
* **rds:** dual-stack mode support ([#22596](https://github.com/aws/aws-cdk/issues/22596)) ([89a7365](https://github.com/aws/aws-cdk/commit/89a73651ccd619b9b1878c40214e4647095803de)), closes [#19525](https://github.com/aws/aws-cdk/issues/19525)


### Bug Fixes

* **apigateway:** relax access log format check to allow either requestId or extendedRequestId ([#22591](https://github.com/aws/aws-cdk/issues/22591)) ([1a16ad0](https://github.com/aws/aws-cdk/commit/1a16ad0bf422e17b8c56d1fe2581eda7c60e7522))
* **eks:** kubectl layer must contain AWS CLI ([#22559](https://github.com/aws/aws-cdk/issues/22559)) ([d8b4c09](https://github.com/aws/aws-cdk/commit/d8b4c091d85eb818c6e106416eea52d26f4fa73b))
* **ssm:** `StringParameter.fromSecureStringParameterAttributes` not working without version ([#22618](https://github.com/aws/aws-cdk/issues/22618)) ([b33b9b0](https://github.com/aws/aws-cdk/commit/b33b9b0a3ce2cfd79082bb743b36c6fda9e8278b)), closes [#18729](https://github.com/aws/aws-cdk/issues/18729) [#22311](https://github.com/aws/aws-cdk/issues/22311)

## [2.47.0](https://github.com/aws/aws-cdk/compare/v2.46.0...v2.47.0) (2022-10-20)


Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@
"@aws-cdk/aws-cognito/punycode/**",
"@aws-cdk/aws-ecr-assets/minimatch",
"@aws-cdk/aws-ecr-assets/minimatch/**",
"@aws-cdk/aws-eks/semver",
"@aws-cdk/aws-eks/semver/**",
"@aws-cdk/aws-eks/yaml",
"@aws-cdk/aws-eks/yaml/**",
"@aws-cdk/aws-events-targets/aws-sdk",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apprunner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ To associate an App Runner service with a custom VPC, define `vpcConnector` for
import * as ec2 from '@aws-cdk/aws-ec2';

const vpc = new ec2.Vpc(this, 'Vpc', {
cidr: '10.0.0.0/16',
ipAddresses: ec2.IpAddresses.cidr('10.0.0.0/16')
});

const vpcConnector = new apprunner.VpcConnector(this, 'VpcConnector', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const stack = new cdk.Stack(app, 'integ-apprunner');

// Scenario 6: Create the service from ECR public with a VPC Connector
const vpc = new ec2.Vpc(stack, 'Vpc', {
cidr: '10.0.0.0/16',
ipAddresses: ec2.IpAddresses.cidr('10.0.0.0/16'),
});

const securityGroup = new ec2.SecurityGroup(stack, 'SecurityGroup', { vpc });
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apprunner/test/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ test('specifying a vpcConnector should assign the service to it and set the egre
const stack = new cdk.Stack(app, 'demo-stack');

const vpc = new ec2.Vpc(stack, 'Vpc', {
cidr: '10.0.0.0/16',
ipAddresses: ec2.IpAddresses.cidr('10.0.0.0/16'),
});

const securityGroup = new ec2.SecurityGroup(stack, 'SecurityGroup', { vpc });
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-apprunner/test/vpc-connector.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test('create a vpcConnector with all properties', () => {
const stack = new cdk.Stack(app, 'demo-stack');

const vpc = new ec2.Vpc(stack, 'Vpc', {
cidr: '10.0.0.0/16',
ipAddresses: ec2.IpAddresses.cidr('10.0.0.0/16'),
});

const securityGroup = new ec2.SecurityGroup(stack, 'SecurityGroup', { vpc });
Expand Down Expand Up @@ -48,7 +48,7 @@ test('create a vpcConnector without a name', () => {
const stack = new cdk.Stack(app, 'demo-stack');

const vpc = new ec2.Vpc(stack, 'Vpc', {
cidr: '10.0.0.0/16',
ipAddresses: ec2.IpAddresses.cidr('10.0.0.0/16'),
});

const securityGroup = new ec2.SecurityGroup(stack, 'SecurityGroup', { vpc });
Expand Down Expand Up @@ -85,7 +85,7 @@ test('create a vpcConnector without a security group should create one', () => {
const stack = new cdk.Stack(app, 'demo-stack');

const vpc = new ec2.Vpc(stack, 'Vpc', {
cidr: '10.0.0.0/16',
ipAddresses: ec2.IpAddresses.cidr('10.0.0.0/16'),
});

// WHEN
Expand Down Expand Up @@ -120,7 +120,7 @@ test('create a vpcConnector with an empty security group array should create one
const stack = new cdk.Stack(app, 'demo-stack');

const vpc = new ec2.Vpc(stack, 'Vpc', {
cidr: '10.0.0.0/16',
ipAddresses: ec2.IpAddresses.cidr('10.0.0.0/16'),
});

// WHEN
Expand Down
72 changes: 64 additions & 8 deletions packages/@aws-cdk/aws-ec2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,62 @@ new ec2.Vpc(this, 'TheVPC', {
provider.connections.allowFrom(ec2.Peer.ipv4('1.2.3.4/8'), ec2.Port.tcp(80));
```

### Ip Address Management

The VPC spans a supernet IP range, which contains the non-overlapping IPs of its contained subnets. Possible sources for this IP range are:

* You specify an IP range directly by specifying a CIDR
* You allocate an IP range of a given size automatically from AWS IPAM

By default the Vpc will allocate the `10.0.0.0/16` address range which will be exhaustively spread across all subnets in the subnet configuration. This behavior can be changed by passing an object that implements `IIpAddresses` to the `ipAddress` property of a Vpc. See the subsequent sections for the options.

Be aware that if you don't explicitly reserve subnet groups in `subnetConfiguration`, the address space will be fully allocated! If you predict you may need to add more subnet groups later, add them early on and set `reserved: true` (see the "Advanced Subnet Configuration" section for more information).

#### Specifying a CIDR directly

Use `IpAddresses.cidr` to define a Cidr range for your Vpc directly in code:

```ts
import { IpAddresses } from '@aws-cdk/aws-ec2';

new ec2.Vpc(stack, 'TheVPC', {
ipAddresses: ec2.IpAddresses.cidr('10.0.1.0/20')
});
```

Space will be allocated to subnets in the following order:

* First, spaces is allocated for all subnets groups that explicitly have a `cidrMask` set as part of their configuration (including reserved subnets).
* Afterwards, any remaining space is divided evenly between the rest of the subnets (if any).

The argument to `IpAddresses.cidr` may not be a token, and concrete Cidr values are generated in the synthesized CloudFormation template.

#### Allocating an IP range from AWS IPAM

Amazon VPC IP Address Manager (IPAM) manages a large IP space, from which chunks can be allocated for use in the Vpc. For information on Amazon VPC IP Address Manager please see the [official documentation](https://docs.aws.amazon.com/vpc/latest/ipam/what-it-is-ipam.html). An example of allocating from AWS IPAM looks like this:

```ts
import { IpAddresses } from '@aws-cdk/aws-ec2';

declare const pool: ec2.CfnIPAMPool;

new ec2.Vpc(stack, 'TheVPC', {
ipAddresses: ec2.IpAddresses.awsIpamAllocation({
ipv4IpamPoolId: pool.ref,
ipv4NetmaskLength: 18,
defaultSubnetIpv4NetmaskLength: 24
})
});
```

`IpAddresses.awsIpamAllocation` requires the following:

* `ipv4IpamPoolId`, the id of an IPAM Pool from which the VPC range should be allocated.
* `ipv4NetmaskLength`, the size of the IP range that will be requested from the Pool at deploy time.
* `defaultSubnetIpv4NetmaskLength`, the size of subnets in groups that don't have `cidrMask` set.

With this method of IP address management, no attempt is made to guess at subnet group sizes or to exhaustively allocate the IP range. All subnet groups must have an explicit `cidrMask` set as part of their subnet configuration, or `defaultSubnetIpv4NetmaskLength` must be set for a default size. If not, synthesis will fail and you must provide one or the other.

### Advanced Subnet Configuration

If the default VPC configuration (public and private subnets spanning the
Expand All @@ -227,9 +283,9 @@ subnet configuration could look like this:

```ts
const vpc = new ec2.Vpc(this, 'TheVPC', {
// 'cidr' configures the IP range and size of the entire VPC.
// The IP space will be divided over the configured subnets.
cidr: '10.0.0.0/21',
// 'IpAddresses' configures the IP range and size of the entire VPC.
// The IP space will be divided based on configuration for the subnets.
ipAddresses: IpAddresses.cidr('10.0.0.0/21'),

// 'maxAzs' configures the maximum number of availability zones to use.
// If you want to specify the exact availability zones you want the VPC
Expand Down Expand Up @@ -948,11 +1004,11 @@ new ec2.Instance(this, 'Instance2', {
}),
});

// AWS Linux 2 with kernel 5.x
// AWS Linux 2 with kernel 5.x
new ec2.Instance(this, 'Instance3', {
vpc,
instanceType,
machineImage: new ec2.AmazonLinuxImage({
machineImage: new ec2.AmazonLinuxImage({
generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2,
kernel: ec2.AmazonLinuxKernel.KERNEL5_X,
}),
Expand All @@ -962,7 +1018,7 @@ new ec2.Instance(this, 'Instance3', {
new ec2.Instance(this, 'Instance4', {
vpc,
instanceType,
machineImage: new ec2.AmazonLinuxImage({
machineImage: new ec2.AmazonLinuxImage({
generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2022,
}),
});
Expand Down Expand Up @@ -1407,9 +1463,9 @@ asset.grantRead(instance.role);
### Persisting user data

By default, EC2 UserData is run once on only the first time that an instance is started. It is possible to make the
user data script run on every start of the instance.
user data script run on every start of the instance.

When creating a Windows UserData you can use the `persist` option to set whether or not to add
When creating a Windows UserData you can use the `persist` option to set whether or not to add
`<persist>true</persist>` [to the user data script](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-windows-user-data.html#user-data-scripts). it can be used as follows:

```ts
Expand Down
77 changes: 77 additions & 0 deletions packages/@aws-cdk/aws-ec2/lib/cidr-splits.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* Return the splits necessary to allocate the given sequence of cidrs in the given order
*
* The entire block is of size 'rootNetmask', and subsequent blocks will be allocated
* from it sized according to the sizes in the 'netmasks' array.
*
* The return value is a list of `CidrSplit` objects, which represent
* invocations of a pair of `Fn.select(Fn.cidr(...))` operations.
*
* Strategy: walk through the IP block space, clipping to the next possible
* start of a block of the given size, then allocate it. Here is an unrealistic
* example (with a weird ordering of the netmasks to show how clipping and hence
* space wasting plays out in practice):
*
* root space /16
* ┌──────────────────────────────────────────────────────────────────────────────────────────────┐
* │ │
* A /21 B /19
* ┌───┬───┬───┬───┬───────────────┬───────────────┬───┬───────────┬───────────────┬──────────────┐
* │ A │ A │ A │###│ B │ B │ A │###########│ B │ .... │
* └───┴───┴───┴───┴───────────────┴───────────────┴───┴───────────┴───────────────┴──────────────┘
* ^^^______ wasted space _________________^^^^^^
*/
export function calculateCidrSplits(rootNetmask: number, netmasks: number[]): CidrSplit[] {
const ret = new Array<CidrSplit>();

let offset = 0;
for (const netmask of netmasks) {
const size = Math.pow(2, 32 - netmask);

// Clip offset to the next block of the given size
offset = nextMultiple(offset, size);

const count = Math.pow(2, netmask - rootNetmask);
ret.push({
count,
netmask,
index: offset / size,
});

// Consume
offset += size;
}

if (offset > Math.pow(2, 32 - rootNetmask)) {
throw new Error(`IP space of size /${rootNetmask} not big enough to allocate subnets of sizes ${netmasks.map(x => `/${x}`)}`);
}

return ret;
}

function nextMultiple(current: number, multiple: number) {
return Math.ceil(current / multiple) * multiple;
}

/**
* A representation of a pair of `Fn.select(Fn.cidr())` invocations
*/
export interface CidrSplit {
/**
* The netmask of this block size
*
* This is the inverse number of what you need to pass to Fn.cidr (pass `32 -
* netmask` to Fn.cidr)`.
*/
readonly netmask: number;

/**
* How many parts the mask needs to be split into
*/
readonly count: number;

/**
* What subnet index to select from the split
*/
readonly index: number;
}
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-ec2/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export * from './client-vpn-endpoint-types';
export * from './client-vpn-endpoint';
export * from './client-vpn-authorization-rule';
export * from './client-vpn-route';
export * from './ip-addresses';

// AWS::EC2 CloudFormation Resources:
export * from './ec2.generated';
Expand Down
Loading

0 comments on commit 6e475a0

Please sign in to comment.