Table of Contents generated with DocToc
A script for managing states of EC2 instances and EKS clusters on AWS and getting info about published New Relic Lambda layers.
AWS CLI v2 must be installed and configured, like by running aws configure.
https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html
jq must be installed.
https://stedolan.github.io/jq/
eksctl must be installed for use with EKS.
https://eksctl.io/
unzip, xargs, and curl must also be available.
Assuming you've set an alias for this script to "cs"
alias cs='bash ~/path/to/cloudscript.sh'
------------------------------------------------------
Usage: cs COMPONENT <REQUIRED ARGS> [OPTIONAL ARGS]
About:
cs -v, --version Show version
cs -h, --help Show this message
Components:
ec2 Manage EC2 instance states
eks Manage EKS node states
ms Manage Metric Stream states
lambda List and download New Relic Lambda layers
Components and Args:
ec2 status
ec2 start|stop|restart|ssh <instanceId>
eks status
eks start <cluster> <number of nodes>
eks stop <cluster>
ms status
ms start <stream name>
ms stop <stream name>
lambda list-layers [runtime]|[all] [region]
lambda download-layers [<arn> | [layer]|[all] [region] [build]|[latest]] [extension|agent]
Examples:
cs ec2 status
cs eks start my-cluster 2
cs ms start my-stream
cs lambda list-layers List layer names
cs lambda list-layers all Details for all layers
cs lambda list-layers nodejs18.x us-west-2 Details for a specific layer
cs lambda download-layers NewRelicNodeJS18X us-west-2 24 Download build #24 for a layer
cs lambda download-layers arn extension Download layer given the layer arn and provide details about the extension
cs lambda download-layers arn agent Download layer given the layer arn and provide details about the agent
-
Copy
csto your PATH. -
Verify it is in your path.
which cs cs --version
-
Run a command (see below examples).
get a list of instances and their IDs
cs ec2 startstart an instance
cs ec2 start <your-instance-id>stop an instance
cs ec2 stop <your-instance-id>get a list of cluster names
cs eks startscale up an EKS node group to 2 nodes
cs eks start <your-cluster-name> 2stop an eks node group (scale down to 0 nodes)
cs eks stop <your-cluster-name>-
If leaving off the optional instanceId a list of instanceIds will be shown, but only those with a
Nametag."Tags": [ { "Key": "Name", "Value": "your-ec2-instance-name" } ],
get a list of compatible runtimes
cs lambda list-layersget a list of layer names
cs lambda download-layersdownload all layers and stat extension release dates
cs lambda download-layers all us-west-2 latest extensiondownload all layers and stat agent release dates
cs lambda download-layers all us-west-2 latest agentdownload a specific layer build
cs lambda download-layers NewRelicPython39 us-west-2 36- If leaving off the optional compatibleRuntime, a list of compatible runtimes is obtained.
- If leaving off the optional region, the default region defined in your aws-cli is used.
- If leaving off the optional build, the latest build is downloaded.
- If leaving off the optional extension or agent, details for both will be displayed.
Tested on Ubuntu 22.04 with Bash version 5.1.16
You can download the latest releases here. The cs file and its checksum are signed and can be verified against the developer's public PGP key.
Import the signing key:
gpg --import kmullaney.ascVerify that the fingerprint for the downloaded key matches the following:
gpg --fingerprint kmullaney@newrelic.comYou should get E67B C11C D9B3 EC3B 81B7 0C35 68BF EBFB 3C1B 8D5A.
When verifying the checksum, use the long format (the short format is not secure). For example:
gpg --keyid-format long --verify SHA512SUMS.asc SHA512SUMSNow that you've verified the checksum file has a valid signature, it's time to check that the cs file has not been modified in transit.
shasum -a 512 -c SHA512SUMSYou should get cs: OK.
Special thanks to NVM for inspiration.
See CONTRIBUTING.md