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.
Ensure aws-cdk is installed and bootstrapped.
$ npm install -g aws-cdk
$ cdk bootstrap
Then build and deploy.
$ npm run build
$ cdk deploy
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.
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:
-
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
-
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.
# Destroy all project resources.
$ cdk destroy