From b0fca07f9a9d082e8db0a719b18a29c76bb891bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20P=C3=BDrek?= Date: Sun, 12 May 2024 13:10:37 +0200 Subject: [PATCH] feat: add rds control panel --- .../rds-instance-control-panel/preset.mjs | 3 ++ .../templates/README.md | 25 ++++++++++++ .../templates/lib/example-stack.ts | 39 +++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 presets/library/rds-instance-control-panel/preset.mjs create mode 100644 presets/library/rds-instance-control-panel/templates/README.md create mode 100644 presets/library/rds-instance-control-panel/templates/lib/example-stack.ts diff --git a/presets/library/rds-instance-control-panel/preset.mjs b/presets/library/rds-instance-control-panel/preset.mjs new file mode 100644 index 0000000..6e1afff --- /dev/null +++ b/presets/library/rds-instance-control-panel/preset.mjs @@ -0,0 +1,3 @@ +import { extend, extract } from '../../../src/index.js' + +export default [extend('presets/base/typescript-cdk'), extract()] diff --git a/presets/library/rds-instance-control-panel/templates/README.md b/presets/library/rds-instance-control-panel/templates/README.md new file mode 100644 index 0000000..2f4c61b --- /dev/null +++ b/presets/library/rds-instance-control-panel/templates/README.md @@ -0,0 +1,25 @@ +

+ + Buttonize.io + +

+ +--- + +## RDS Instance Control Panel + +[![RDS Instance Control Panel](https://github.com/buttonize/create-buttonize/assets/6282843/2b47ee3d-d4c6-442a-a366-acfc35765ab9)](https://buttonize.io/library/rds-instance-control-panel) + +Learn more about RDS Instance Control Panel Construct [here](https://buttonize.io/library/rds-instance-control-panel). + +## CDK + +The `cdk.json` file tells the CDK Toolkit how to execute your app. + +### Useful commands + +* `npm run build` compile typescript to js +* `npm run watch` watch for changes and compile +* `npx cdk deploy` deploy this stack to your default AWS account/region +* `npx cdk diff` compare deployed stack with current state +* `npx cdk synth` emits the synthesized CloudFormation template diff --git a/presets/library/rds-instance-control-panel/templates/lib/example-stack.ts b/presets/library/rds-instance-control-panel/templates/lib/example-stack.ts new file mode 100644 index 0000000..ce57e8b --- /dev/null +++ b/presets/library/rds-instance-control-panel/templates/lib/example-stack.ts @@ -0,0 +1,39 @@ +import * as cdk from 'aws-cdk-lib' +import { + InstanceClass, + InstanceSize, + InstanceType, + SubnetType, + Vpc +} from 'aws-cdk-lib/aws-ec2' +import { DatabaseInstance, DatabaseInstanceEngine } from 'aws-cdk-lib/aws-rds' +import { Buttonize } from 'buttonize/cdk' +import { RDSInstanceControlPanel } from 'buttonize/library' +import { Construct } from 'constructs' + +export class ExampleStack extends cdk.Stack { + constructor(scope: Construct, id: string, props?: cdk.StackProps) { + super(scope, id, props) + + Buttonize.init(this, { + apiKey: '@@apiKey' + }) + + const defaultVpc = Vpc.fromLookup(this, 'VPC', { isDefault: true }) + + const instance = new DatabaseInstance(this, 'RdsInstance', { + engine: DatabaseInstanceEngine.POSTGRES, + vpc: defaultVpc, + instanceType: InstanceType.of(InstanceClass.T4G, InstanceSize.MICRO), + removalPolicy: cdk.RemovalPolicy.DESTROY, + instanceIdentifier: 'my-little-test-buttonize-db', + vpcSubnets: { + subnetType: SubnetType.PUBLIC // Publicly accessible instance + } + }) + + new RDSInstanceControlPanel(this, 'ControlPanel', { + instance + }) + } +}