Skip to content

Commit

Permalink
chore: update contributing guide with new process for unconventional …
Browse files Browse the repository at this point in the history
…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*
  • Loading branch information
kaizencc authored Nov 29, 2022
1 parent 50422df commit c31b919
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

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

### Adding new Unconventional Dependencies:
### Adding new Construct Runtime 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)
* [ ] 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)

### New Features

Expand Down
51 changes: 36 additions & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ $ yarn watch & # runs in the background

* Shout out to collaborators.

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

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

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

#### Adding construct runtime dependencies

Any tool that is not part of the CDK, and needs to be used by a construct during
deployment or runtime, can be included in the CDK Framework Library in one of two
ways.

1. Add a direct dependency on an npm package containing the tool. For example,
`@aws-cdk/asset-awscli-v1`.
2. Expose a property on the construct you are creating that allows users to
supply their own version of the tool. For example, the `eks.Cluster`
construct has a construct prop called `kubectlLayer` where you must provide a
version of `kubectl` from one of the `@aws-cdk/asset-kubectl-vXY` packages.
The version of `kubectl` must be compatible with the Kubernetes version of
the cluster.

Both options involve creating separate repositories (like this
[one](https://github.com/cdklabs/awscdk-asset-kubectl) for kubectl). If you
would like to introduce additional runtime dependencies, it likely involves
discussing with a CDK maintainer and opening a new repository in cdklabs that
vends the dependency as a lambda layer. Generally, each branch on the repository
will focus on a specific version of the dependency. For example, in
`awscdk-asset-kubectl`, branch `kubectl-v20/main` vends kubectl v1.20, branch
`kubectl-v21/main` vends kubectl v1.21, and so on.

**If your PR introduces runtime dependencies in lambda layers, make sure to call
it out in the description so that we can discuss the best way to manage that
dependency.**

#### Adding new unconventional dependencies

> :warning: Do not add these. If there is a tool that you want to use in your
CDK constructs, see [Adding construct runtime
dependencies](#Adding-construct-runtime-dependencies).

**For the aws-cdk an unconventional dependency is defined as any dependency that is not managed via the module's
`package.json` file.**

Sometimes constructs introduce new unconventional dependencies. Any new unconventional dependency that is introduced needs to have
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).
Sometimes, constructs introduce new unconventional dependencies. Any new unconventional dependency that is introduced needs to have
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).
You can find the dependabot config file [here](./.github/dependabot.yml).

An example of this is the [@aws-cdk/lambda-layer-awscli](packages/@aws-cdk/lambda-layer-awscli) module.
This module creates a lambda layer that bundles the AWS CLI. This is considered an unconventional
dependency because the AWS CLI is bundled into the CDK as part of the build, and the version
of the AWS CLI that is bundled is not managed by the `package.json` file.

In order to automatically update the version of the AWS CLI, a custom build process was
created that takes upgrades into consideration. You can take a look at the files in
[packages/@aws-cdk/lambda-layer-awscli/layer](packages/@aws-cdk/lambda-layer-awscli/layer)
to see how the build works, but at a high level a [requirements.txt](packages/@aws-cdk/lambda-layer-awscli/layer/requirements.txt)
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)
so that dependabot will automatically upgrade the version as new versions are released.

**If you think your PR introduces a new unconventional dependency, make sure to call it
out in the description so that we can discuss the best way to manage that dependency.**

Expand Down

0 comments on commit c31b919

Please sign in to comment.