CDK Preinstalled Amazon Linux EC2 Instance Construct
This is a CDK Construct for creating a preinstalled AmazonLinux EC2 instance.
You can use Node.js, Visual Studio Code, git and other software as soon as the EC2 instance starts.
Usage
Install the package:
npm install cdk-preinstalled-amazon-linux-ec2
Use it in your CDK stack:
import { PreinstalledAmazonLinuxInstance } from 'cdk-preinstalled-amazon-linux-ec2';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
declare const vpc: ec2.IVpc;
// You can configure all properties of the EC2 instance
new PreinstalledAmazonLinuxInstance(this, 'Instance', {
vpc,
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.NANO),
machineImage: new ec2.AmazonLinuxImage({
generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2023,
}),
// Specify preinstalled software
preinstalledSoftware: {
packages: [
PreinstalledSoftwareType.NODEJS,
PreinstalledSoftwareType.VSCODE,
PreinstalledSoftwareType.GIT,
],
others: ['rsyslog'], // You can specify other software packages. These parameters are used as `sudo dnf install ${parameter}`
});
After the stack is deployed, you can SSH into the EC2 instance and use Node.js:
$ ssh ec2-user@<public-ip>
$ node --version
v20.13.1
$ code --version
1.89.1
$ git --version
git version 2.39.3
user data
Installation of software is done by user data script. You can see the script in the src/index.ts file.
// Install Node.js
userData.addCommands(
'touch ~/.bashrc',
'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash',
'source ~/.bashrc',
'export NVM_DIR="$HOME/.nvm"',
'[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"',
`nvm install ${props.nodeJsVersion ?? '--lts'}`,
// Note that the above will install nvm, node and npm for the root user.
// It will not add the correct ENV VAR in ec2-user's environment.
`cat <<EOF >> /home/ec2-user/.bashrc
export NVM_DIR="/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
EOF`);
Ofcourse, you can customize the additional user data script by calling instance.userData.addCommands() method.
declare const instance: PreinstalledAmazonLinuxInstance;
// install yarn
instance.userData.addCommands(
'npm install -g yarn'
);
Metadata
Release files for cdk-preinstalled-amazon-linux-ec2 0.0.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cdk_preinstalled_amazon_linux_ec2-0.0.15.tar.gz | 46.7 kB | With provenance | Details for cdk_preinstalled_amazon_linux_ec2-0.0.15.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cdk_preinstalled_amazon_linux_ec2-0.0.15-py3-none-any.whl | Python 3 | none | any | Details for cdk_preinstalled_amazon_linux_ec2-0.0.15-py3-none-any.whl |
Total release size: 91.7 kB
Release files / cdk_preinstalled_amazon_linux_ec2-0.0.15.tar.gz
| Download URL | cdk_preinstalled_amazon_linux_ec2-0.0.15.tar.gz |
|---|---|
| Size | 46.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
203f05101ed2d63150c76e6d186ffb48d254bd651d29df43e927aec9b08474a3
|
|
BLAKE2b-256 checksum How to use checksums |
77b7399a72e1b4068dea5a224cb15152012f0c16c81e7b527dd942fd31c99851
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.14.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.
Transparency logRelease files / cdk_preinstalled_amazon_linux_ec2-0.0.15-py3-none-any.whl
| Download URL | cdk_preinstalled_amazon_linux_ec2-0.0.15-py3-none-any.whl |
|---|---|
| Size | 45.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6fcd3619d54c9c3187c4b4225a10d662f8ee6801fb9133d2b61414603dc7bec8
|
|
BLAKE2b-256 checksum How to use checksums |
08156bb8efefbab6aaebf13e856aad34661afad522f4cf144fe4692a4047c223
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.14.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.
Transparency logSecurity for cdk-preinstalled-amazon-linux-ec2 0.0.15
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for cdk_preinstalled_amazon_linux_ec2-0.0.15.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.