Skip to content

Commit c31b919

Browse files
authored
chore: update contributing guide with new process for unconventional dependencies (#22851)
---- ### All Submissions: * [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 50422df commit c31b919

File tree

2 files changed

+38
-17
lines changed

2 files changed

+38
-17
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)
77

8-
### Adding new Unconventional Dependencies:
8+
### Adding new Construct Runtime Dependencies:
99

10-
* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)
10+
* [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies)
1111

1212
### New Features
1313

CONTRIBUTING.md

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ $ yarn watch & # runs in the background
360360

361361
* Shout out to collaborators.
362362

363-
* Call out any new [unconventional dependencies](#adding-new-unconventional-dependencies) that are created as part of your PR.
363+
* Call out any new [runtime dependencies](#adding-construct-runtime-dependencies) that are created as part of your PR.
364364

365365
* If not obvious (i.e. from unit tests), describe how you verified that your change works.
366366

@@ -389,27 +389,48 @@ $ yarn watch & # runs in the background
389389
* Make sure to update the PR title/description if things change. The PR title/description are going to be used as the
390390
commit title/message and will appear in the CHANGELOG, so maintain them all the way throughout the process.
391391

392+
#### Adding construct runtime dependencies
393+
394+
Any tool that is not part of the CDK, and needs to be used by a construct during
395+
deployment or runtime, can be included in the CDK Framework Library in one of two
396+
ways.
397+
398+
1. Add a direct dependency on an npm package containing the tool. For example,
399+
`@aws-cdk/asset-awscli-v1`.
400+
2. Expose a property on the construct you are creating that allows users to
401+
supply their own version of the tool. For example, the `eks.Cluster`
402+
construct has a construct prop called `kubectlLayer` where you must provide a
403+
version of `kubectl` from one of the `@aws-cdk/asset-kubectl-vXY` packages.
404+
The version of `kubectl` must be compatible with the Kubernetes version of
405+
the cluster.
406+
407+
Both options involve creating separate repositories (like this
408+
[one](https://github.com/cdklabs/awscdk-asset-kubectl) for kubectl). If you
409+
would like to introduce additional runtime dependencies, it likely involves
410+
discussing with a CDK maintainer and opening a new repository in cdklabs that
411+
vends the dependency as a lambda layer. Generally, each branch on the repository
412+
will focus on a specific version of the dependency. For example, in
413+
`awscdk-asset-kubectl`, branch `kubectl-v20/main` vends kubectl v1.20, branch
414+
`kubectl-v21/main` vends kubectl v1.21, and so on.
415+
416+
**If your PR introduces runtime dependencies in lambda layers, make sure to call
417+
it out in the description so that we can discuss the best way to manage that
418+
dependency.**
419+
392420
#### Adding new unconventional dependencies
393421

422+
> :warning: Do not add these. If there is a tool that you want to use in your
423+
CDK constructs, see [Adding construct runtime
424+
dependencies](#Adding-construct-runtime-dependencies).
425+
394426
**For the aws-cdk an unconventional dependency is defined as any dependency that is not managed via the module's
395427
`package.json` file.**
396428

397-
Sometimes constructs introduce new unconventional dependencies. Any new unconventional dependency that is introduced needs to have
398-
an auto upgrade process in place. The recommended way to update dependencies is through [dependabot](https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates).
429+
Sometimes, constructs introduce new unconventional dependencies. Any new unconventional dependency that is introduced needs to have
430+
an auto upgrade process in place. The recommended way to update dependencies is through
431+
[dependabot](https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates).
399432
You can find the dependabot config file [here](./.github/dependabot.yml).
400433

401-
An example of this is the [@aws-cdk/lambda-layer-awscli](packages/@aws-cdk/lambda-layer-awscli) module.
402-
This module creates a lambda layer that bundles the AWS CLI. This is considered an unconventional
403-
dependency because the AWS CLI is bundled into the CDK as part of the build, and the version
404-
of the AWS CLI that is bundled is not managed by the `package.json` file.
405-
406-
In order to automatically update the version of the AWS CLI, a custom build process was
407-
created that takes upgrades into consideration. You can take a look at the files in
408-
[packages/@aws-cdk/lambda-layer-awscli/layer](packages/@aws-cdk/lambda-layer-awscli/layer)
409-
to see how the build works, but at a high level a [requirements.txt](packages/@aws-cdk/lambda-layer-awscli/layer/requirements.txt)
410-
file was created to manage the version. This file was then added to [dependabot.yml](https://github.com/aws/aws-cdk/blob/ab57eb6d1ed69b40ed6ec774853c275785acace8/.github/dependabot.yml#L14-L20)
411-
so that dependabot will automatically upgrade the version as new versions are released.
412-
413434
**If you think your PR introduces a new unconventional dependency, make sure to call it
414435
out in the description so that we can discuss the best way to manage that dependency.**
415436

0 commit comments

Comments
 (0)