EC2 Instance Control Panel

EC2
EC2

“Have you tried turning it off and on again?” That’s usually the quickest and the most efficient advice you can tell someone debugging a problem. Sometimes there are things between heaven an earth that can’t be explained but can be solved by restarting a server.

For these cases Buttonize brings EC2InstanceControlPanel construct. Let your L1 support or even non-technical colleagues handle the basic operations around EC2 instances.

Features

  • CPU Utilization chart for the past hour
  • Status information
    • Instance name
    • Instance state
    • Instance type
    • Public DNS Name
    • Public IP Address
  • Actions
    • Start - calls StartInstances EC2 API to start the instance if it’s stopped
    • Stop - calls StopInstances EC2 API to stop the instance if it’s running
    • Reboot - calls RebootInstances EC2 API to reboot the instance if it’s running

Preview

EC2 Instance Control Panel App preview

Usage

In case you create EC2 instance in CDK

lib/example-stack.ts
import * as cdk from 'aws-cdk-lib'
import { AmazonLinuxImage, Instance, InstanceClass, InstanceSize, InstanceType, Vpc } from 'aws-cdk-lib/aws-ec2'
import { Buttonize } from 'buttonize/cdk'
import { EC2InstanceControlPanel } from 'buttonize/library'
import { Construct } from 'constructs'
export class CdkStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props)
Buttonize.init(this, { apiKey: 'YOUR_API_KEY' })
const defaultVpc = Vpc.fromLookup(this, 'VPC', { isDefault: true })
const ec2Instance = new Instance(this, 'EC2Instance', {
instanceType: InstanceType.of(InstanceClass.T3, InstanceSize.MICRO),
machineImage: new AmazonLinuxImage(),
vpc: defaultVpc
})
new EC2InstanceControlPanel(this, 'ControlPanel', {
instance: ec2Instance
})
}
}

In case you create EC2 outside of the CDK scope and know only instance’s ARN

lib/example-stack.ts
import * as cdk from 'aws-cdk-lib'
import { Buttonize } from 'buttonize/cdk'
import { EC2InstanceControlPanel } from 'buttonize/library'
import { Construct } from 'constructs'
export class CdkStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props)
Buttonize.init(this, { apiKey: 'YOUR_API_KEY' })
new EC2InstanceControlPanel(this, 'ControlPanel', {
instanceArn:
'arn:aws:ec2:<region>:<account-number>:instance/<instance-id>'
})
}
}
Setup
New repository
npx create-buttonize --template library/ec2-instance-control-panel --api-key=YOUR_API_KEY
Existing repository
import { Buttonize } from 'buttonize/cdk'
import { EC2InstanceControlPanel } from 'buttonize/library'
Buttonize.init(this, { apiKey: 'YOUR_API_KEY' })
new EC2InstanceControlPanel(this, 'ControlPanel', {
instance: yourEc2Instance
})
Deploy
npx cdk deploy
Delete
npx cdk destroy
Package
npm buttonize
Source
github EC2InstanceControlPanel.ts
Additional resources

Buttonize X.com profile Buttonize GitHub profile

© 2024 Buttonize OÜ

With ❤️ made in 🇨🇿

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.