Skip to content

akirchmyer/verdaccio-cdk-ec2

Repository files navigation

Deploys a Verdaccio private npm registry to an EC2 instance via CDK

Uses CDK to provision the following:

  • A new VPC
  • Two public subnets
  • A security group
  • An EC2 instance in one of the subnets

The /src/config.sh file is used as user-data for the EC2 instance. This file will handle configuring and running a Verdaccio private npm registry.

To Deploy

Ensure aws-cdk is installed and bootstrapped.

$ npm install -g aws-cdk
$ cdk bootstrap

Then build and deploy.

$ npm run build
$ cdk deploy

Output

  • Ec2CdkStack.DownloadKeyCommand: The command needed to download the private key that was created.
  • Ec2CdkStack.IPAddress: Public IP Address of Instance.
  • Ec2CdkStack.KeyName: Key Name that was created.
  • Ec2CdkStack.sshcommand: The command used to connect to the instance.

Keys and Access

A Key Pair is created as part of this project. The public key will be installed as an authorized key in the EC2 instance.

To connect to the instance:

  1. Download the private key from aws secretsmanager:

    # This will downloaded the key as `cdk-key.pem` and grant permissions.
    $ aws secretsmanager get-secret-value --secret-id ec2-ssh-key/cdk-keypair/private --query SecretString --output text > cdk-key.pem && chmod 400 cdk-key.pem
  2. SSH to the instance using the command provided from the stack's output Ec2CdkStack.sshcommand.

    For example:

    $ ssh -i cdk-key.pem -o IdentitiesOnly=yes ec2-user@1.111.11.111

    Find the command for your specific instance in the stack's output.

To Destroy

# Destroy all project resources.
$ cdk destroy

About

Deploys a Verdaccio private npm registry to an EC2 instance via CDK

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published