Skip to content

Commit a523e9f

Browse files
authored
2 parents ddbfac7 + 9d61cb9 commit a523e9f

File tree

14,350 files changed

+274878
-346819
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

14,350 files changed

+274878
-346819
lines changed

Diff for: CONTRIBUTING.md

+30-94
Original file line numberDiff line numberDiff line change
@@ -88,35 +88,35 @@ The CDK uses [jsii](https://github.com/aws/jsii/) as its primary build system. j
8888
typescript-compliant source code and produce polyglot libraries, such as, in Java, .NET, Python and Go.
8989

9090
The repo contains `packages/` directory that contains the CDK public modules. The source code for the IAM module in the
91-
CDK can be found at the location `packages/@aws-cdk/aws-iam`.
91+
CDK can be found at the location `packages/aws-cdk-lib/aws-iam`.
9292
The repo also contains the `tools/` directory that holds custom build tooling (modeled as private npm packages)
9393
specific to the CDK.
9494

9595
### Build
9696

97-
The full build of the CDK takes a long time to complete; 1-2 hours depending on the performance of the build machine.
98-
However, most first time contributions will require changing only one CDK module, sometimes two. A full build of the
99-
CDK is not required in these cases.
100-
101-
If you want to work on the `@aws-cdk/aws-ec2` module, the following command will build just the EC2 module and any
102-
necessary dependencies.
97+
The full build of all of the packages within the repository can take a few minutes, about 20 when all tests are run.
98+
Most contributions only require working on a single package, usually `aws-cdk-lib`. To build this package for the first
99+
time, you can execute the following to build it and it's dependencies.
103100

104101
```console
105-
$ cd packages/@aws-cdk/aws-ec2
106-
$ ../../../scripts/buildup
102+
$ cd packages/aws-cdk-lib
103+
$ ../../scripts/buildup
107104
```
108105

109106
Note: The `buildup` command is resumable. If your build fails, you can fix the issue and run `buildup --resume` to
110107
resume.
111108

112-
At this point, you can run build and test the `aws-ec2` module by running
109+
At this point, you can run build and test the `aws-cdk-lib` module by running
113110

114111
```console
115-
$ cd packages/@aws-cdk/aws-ec2
112+
$ cd packages/aws-cdk-lib
116113
$ yarn build
117114
$ yarn test
118115
```
119116

117+
To cut down on iteration time as you develop, you can run `yarn watch` within the `aws-cdk-lib` directory to keep
118+
some of the build state in memory and incrementally rebuild as you make changes.
119+
120120
However, if you wish to build the entire repository, the following command will achieve this.
121121

122122
```console
@@ -137,13 +137,13 @@ Packing involves generating CDK code in the various target languages and packagi
137137
respective package managers. Once in a while, these will need to be generated either to test the experience of a new
138138
feature, or reproduce a packaging failure.
139139

140-
To package a specific module, say the `@aws-cdk/aws-ec2` module:
140+
To package a specific module, say the `aws-cdk-lib` module:
141141

142142
```console
143143
$ cd <root-of-cdk-repo>
144144
$ docker run --rm --net=host -it -v $PWD:$PWD -w $PWD jsii/superchain:1-buster-slim
145-
docker$ cd packages/@aws-cdk/aws-ec2
146-
docker$ ../../../scripts/foreach.sh --up yarn run package
145+
docker$ cd packages/aws-cdk-lib
146+
docker$ ../../scripts/foreach.sh --up yarn run package
147147
docker$ exit
148148
```
149149

@@ -317,12 +317,12 @@ CDK integration tests.
317317
We've added a watch feature to the CDK that builds your code as you type it. Start this by running `yarn watch` for
318318
each module that you are modifying.
319319

320-
For example, watch the EC2 and IAM modules in a second terminal session:
320+
For example, watch the aws-cdk-lib and aws-cdk modules in a second terminal session:
321321

322322
```console
323-
$ cd packages/@aws-cdk/aws-ec2
323+
$ cd packages/aws-cdk-lib
324324
$ yarn watch & # runs in the background
325-
$ cd packages/@aws-cdk/aws-iam
325+
$ cd packages/aws-cdk
326326
$ yarn watch & # runs in the background
327327
```
328328

@@ -637,10 +637,10 @@ The README file contains code snippets written as typescript code. Code snippets
637637
(such as `` ```ts ``) will be automatically extracted, compiled and translated to other languages when the
638638
during the [pack](#pack) step. We call this feature 'rosetta'.
639639

640-
You can run rosetta on the EC2 module (or any other module) by running:
640+
You can run rosetta on the aws-cdk-lib module (or any other module) by running:
641641

642642
```console
643-
$ cd packages/@aws-cdk/aws-ec2
643+
$ cd packages/aws-cdk-lib
644644
$ yarn rosetta:extract --strict
645645
```
646646

@@ -696,14 +696,14 @@ cases where some of those do not apply - good judgement is to be applied):
696696
- Types from the documented module should be **un-qualified**:
697697

698698
```ts
699-
// An example in the @aws-cdk/core library, which defines Duration
699+
// An example in the aws-cdk-lib library, which defines Duration
700700
Duration.minutes(15);
701701
```
702702

703703
- Types from other modules should be **qualified**:
704704

705705
```ts
706-
// An example in the @aws-cdk/core library, using something from @aws-cdk/aws-s3
706+
// An example in the aws-cdk-lib library, using something from aws-cdk-lib/aws-s3
707707
const bucket = new s3.Bucket(this, 'Bucket');
708708
// ...rest of the example...
709709
```
@@ -712,7 +712,7 @@ cases where some of those do not apply - good judgement is to be applied):
712712
necessary for compilation but unimportant to the example:
713713

714714
```ts
715-
// An example about adding a stage to a pipeline in the @aws-cdk/pipelines library
715+
// An example about adding a stage to a pipeline in the aws-cdk-lib/pipelines library
716716
declare const pipeline: pipelines.CodePipeline;
717717
declare const myStage: Stage;
718718
pipeline.addStage(myStage);
@@ -766,7 +766,7 @@ Consequently, there are two useful scripts that are built on top of `foreach.sh`
766766
All linters are executed automatically as part of the build script, `yarn build`.
767767

768768
They can also be executed independently of the build script. From the root of a specific package (e.g.
769-
`packages/@aws-cdk/aws-ec2`), run the following command to execute all the linters on that package -
769+
`packages/aws-cdk-lib`), run the following command to execute all the linters on that package -
770770

771771
```bash
772772
yarn lint
@@ -878,88 +878,24 @@ $ cdk -a some.app.js synth | $awscdk/scripts/template-deps-to-dot | dot -Tpng >
878878

879879
You can use `find-cycles` to print a list of internal dependency cycles:
880880

881-
```shell
882-
$ scripts/find-cycles.sh
883-
Cycle: @aws-cdk/aws-iam => @aws-cdk/assert => aws-cdk => @aws-cdk/aws-s3 => @aws-cdk/aws-kms => @aws-cdk/aws-iam
884-
Cycle: @aws-cdk/assert => aws-cdk => @aws-cdk/aws-s3 => @aws-cdk/aws-kms => @aws-cdk/assert
885-
Cycle: @aws-cdk/aws-iam => @aws-cdk/assert => aws-cdk => @aws-cdk/aws-s3 => @aws-cdk/aws-iam
886-
Cycle: @aws-cdk/assert => aws-cdk => @aws-cdk/aws-s3 => @aws-cdk/assert
887-
Cycle: @aws-cdk/assert => aws-cdk => @aws-cdk/aws-cloudformation => @aws-cdk/assert
888-
Cycle: @aws-cdk/aws-iam => @aws-cdk/assert => aws-cdk => @aws-cdk/util => @aws-cdk/aws-iam
889-
Cycle: @aws-cdk/aws-sns => @aws-cdk/aws-lambda => @aws-cdk/aws-codecommit => @aws-cdk/aws-sns
890-
Cycle: @aws-cdk/aws-sns => @aws-cdk/aws-lambda => @aws-cdk/aws-codecommit => @aws-cdk/aws-codepipeline => @aws-cdk/aws-sns
891-
```
892-
893881
## Running CLI integration tests
894882

895883
The CLI package (`packages/aws-cdk`) has some integration tests that aren't
896884
run as part of the regular build, since they have some particular requirements.
897885
See the [CLI CONTRIBUTING.md file](packages/aws-cdk/CONTRIBUTING.md) for
898886
more information on running those tests.
899887

900-
## Building aws-cdk-lib
901-
902-
In AWS CDK v2, all stable libraries are packaged into a single monolithic
903-
package and published as `aws-cdk-lib`. In most cases, you can iterate on a
904-
single module's directory as previously described in this document (e.g.
905-
`packages/@aws-cdk/aws-s3`). In some cases, you might need to build
906-
`aws-cdk-lib`:
907-
908-
```
909-
# Generate all of the L1s first. If you have already done a full build in the repository, you can skip this.
910-
cd <CDK repo root>/
911-
./scripts/gen.sh
912-
913-
# Generate and build `aws-cdk-lib`
914-
cd packages/aws-cdk-lib
915-
yarn build
916-
```
917-
918-
The commands above perform the following steps:
919-
1. Run `yarn install` to install all dependencies
920-
2. Generate `.generated.ts` files in each `packages/@aws-cdk/aws-<service>`
921-
directory. These files contain TypeScript source code for all of the L1 (Cfn)
922-
Constructs, and are generated from the [CloudFormation Resource
923-
Specification](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-resource-specification.html).
924-
3. Copy the `.ts` source code files from each `packages/@aws-cdk/aws-<service>`
925-
directory to the corresponding `packages/aws-cdk-lib/aws-<service>`
926-
directory.
927-
4. Compile `aws-cdk-lib`.
928-
929-
Running unit tests and integration tests still has to be performed in each
930-
module's `packages/@aws-cdk` directory.
931-
932888
## Building and testing v2 -alpha packages
933889

934-
In AWS CDK v2, all experimental libraries are published separately with an
935-
-alpha suffix. In most cases, you can iterate on a single module's directory as
936-
already described in this document (e.g. `packages/@aws-cdk/aws-amplify`). If
937-
you need to generate and iterate on the alpha package, here are the steps. The
938-
main differences between the alpha package is naming of the package, and import
939-
statements.
940-
941-
First, make sure the following packages are built:
942-
- packages/@aws-cdk/assert
943-
- packages/aws-cdk-lib
944-
- tools/individual-pkg-gen
945-
946-
The following command will create all of the alpha packages by copying files
947-
from their source directories under `packages/@aws-cdk/aws-<service>`, and it
948-
will build and run unit tests for all of them. This is sometimes too much for a
949-
developer machine or laptop.
890+
Modules that are not stable are vended separately from `aws-cdk-lib`. These packages are found in the
891+
`packages/@aws-cdk` directory and are marked `stability: 'experimental'` in their package.json files.
892+
This means they will be given the `alpha` version from the `version.v2.json` when published and they
893+
cannot be taken as dependencies by `aws-cdk-lib`
950894

951-
```
952-
<CDK repo root>/scripts/transform.sh
953-
```
954-
955-
To only copy and transform the source files, and then build and test one
956-
alpha package at a time, use the following:
895+
Experimental packages are used to develop new constructs and experiment with their APIs before marking
896+
them as stable and including them within `aws-cdk-lib`. Once they are included in `aws-cdk-lib`, no
897+
more breaking api changes can be made.
957898

958-
```
959-
<CDK repo root>/scripts/transform.sh --skip-build
960-
cd packages/individual-packages/aws-<service>
961-
yarn build+test
962-
```
963899
## Changing Cloud Assembly Schema
964900

965901
If you plan on making changes to the `cloud-assembly-schema` package, make sure you familiarize yourself with

Diff for: buildspec-pr.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ phases:
2525
build:
2626
commands:
2727
- /bin/bash ./build.sh
28-
- /bin/bash ./scripts/transform.sh
2928
# After compilation, run Rosetta (using the cache if available).
3029
# This will print errors, and fail the build if there are compilation errors in any packages marked as 'strict'.
3130
- /bin/bash ./scripts/run-rosetta.sh

Diff for: buildspec-remodel.yaml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
version: 0.2
2+
3+
env:
4+
secrets-manager:
5+
TOKEN: $TOKEN_SECRET_ARN
6+
variables:
7+
NODE_OPTIONS: --max_old_space_size=8192
8+
9+
phases:
10+
install:
11+
commands:
12+
# CodeBuild always runs as root, allow npm to operate as such
13+
- npm config set unsafe-perm true
14+
- mkdir ${HOME}/aws-cdk && cd ${HOME}/aws-cdk
15+
# Configure git and git credentials
16+
- git config --global user.email "${COMMIT_EMAIL}"
17+
- git config --global user.name "${COMMIT_USERNAME}"
18+
- echo "Retrieving gh token from secretsmanager"
19+
- git clone https://[email protected]/aws/aws-cdk -b feat/repo-restructure .
20+
- git checkout ${CODEBUILD_RESOLVED_SOURCE_VERSION}
21+
# Install yarn if it wasn't already present in the image
22+
- yarn --version || npm -g install yarn
23+
- yarn install --frozen-lockfile
24+
- /sbin/sysctl -w vm.max_map_count=2251954
25+
build:
26+
commands:
27+
- cd ${HOME}/aws-cdk
28+
- npx lerna run build --scope @aws-cdk/remodel --include-dependencies
29+
- npx remodel ${PWD} --tmp-dir ${HOME}/remodel --no-clean --dry-run
30+
post_build:
31+
commands:
32+
- cd ${HOME}/remodel
33+
- git add -A
34+
- git commit -m "Execute remodel"
35+
- git remote add aws-cdk https://[email protected]/aws/aws-cdk
36+
- git fetch aws-cdk
37+
- git push aws-cdk +feat/repo-restructure:feat/remodel
38+
artifacts:
39+
files:
40+
- "**/*"
41+
base-directory: ${HOME}/remodel

Diff for: buildspec.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ phases:
2727
- 'if ${BUMP_CANDIDATE:-false}; then /bin/bash ./scripts/bump-candidate.sh; fi'
2828
- /bin/bash ./scripts/align-version.sh
2929
- /bin/bash ./build.sh
30-
- /bin/bash ./scripts/transform.sh
3130
post_build:
3231
commands:
3332
# Short-circuit: Don't run pack if the above build failed.

Diff for: packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ describe('ci', () => {
2020
const execOptions = {
2121
captureStderr: true,
2222
onlyStderr: true,
23-
modEnv: { CI: 'true' },
23+
modEnv: {
24+
CI: 'true',
25+
JSII_SILENCE_WARNING_KNOWN_BROKEN_NODE_VERSION: 'true',
26+
JSII_SILENCE_WARNING_UNTESTED_NODE_VERSION: 'true',
27+
JSII_SILENCE_WARNING_DEPRECATED_NODE_VERSION: 'true',
28+
},
2429
};
2530

2631
const deployOutput = await fixture.cdkDeploy('test-2', execOptions);
@@ -717,6 +722,17 @@ integTest('synthing a stage with errors can be suppressed', withDefaultFixture(a
717722
});
718723
}));
719724

725+
integTest('synth --quiet can be specified in cdk.json', withDefaultFixture(async (fixture) => {
726+
let cdkJson = JSON.parse(await fs.readFile(path.join(fixture.integTestDir, 'cdk.json'), 'utf8'));
727+
cdkJson = {
728+
...cdkJson,
729+
quiet: true,
730+
};
731+
await fs.writeFile(path.join(fixture.integTestDir, 'cdk.json'), JSON.stringify(cdkJson));
732+
const synthOutput = await fixture.cdk(['synth', fixture.fullStackName('test-2')]);
733+
expect(synthOutput).not.toContain('topic152D84A37');
734+
}));
735+
720736
integTest('deploy stack without resource', withDefaultFixture(async (fixture) => {
721737
// Deploy the stack without resources
722738
await fixture.cdkDeploy('conditional-resource', { modEnv: { NO_RESOURCE: 'TRUE' } });
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const baseConfig = require('../../../tools/@aws-cdk/cdk-build-tools/config/eslintrc');
2+
baseConfig.parserOptions.project = __dirname + '/tsconfig.json';
3+
module.exports = {
4+
...baseConfig,
5+
ignorePatterns: [
6+
...baseConfig.ignorePatterns,
7+
'**/*.snapshot/**/*'
8+
],
9+
rules: {
10+
...baseConfig.rules,
11+
'import/order': 'off',
12+
}
13+
};

Diff for: packages/@aws-cdk-testing/framework-integ/.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
.LAST_BUILD
3+
*.snk
4+
junit.xml
5+
!.eslintrc.js
6+
.nyc_output
7+
coverage
8+
nyc.config.js

Diff for: packages/@aws-cdk-testing/framework-integ/.npmignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
.LAST_BUILD
3+
*.snk
4+
junit.xml
5+
.eslintrc.js
6+
# exclude cdk artifacts
7+
**/cdk.out

Diff for: packages/@aws-cdk-testing/framework-integ/NOTICE

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
AWS Cloud Development Kit (AWS CDK)
2+
Copyright 2018-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
Third party attributions of this package can be found in the THIRD_PARTY_LICENSES file

0 commit comments

Comments
 (0)