@cdk-constructs-zone/super-ec2
v0.0.451
Published
A construct lib for AWS CDK EC2
Downloads
346
Readme
Welcome to @cdk-constructs-zone/super-ec2
This repository template helps you create EC2 .
Sample
Jenkins
- Simplest deployment: It would creat a VPC and ALB by default.
import * as cdk from '@aws-cdk/core';
import { JenkinsEC2, ELBtype } from '@cdk-constructs-zone/super-ec2';
const app = new cdk.App();
const stack = new cdk.Stack(app, 'demo');
const jks = new JenkinsEC2(stack, 'superJks', {});
new cdk.CfnOutput(stack, 'loadbalancerDNS', {
value: jks.loadbalancer.loadBalancerDnsName,
});
new cdk.CfnOutput(stack, 'connect-to-instance', {
value: `aws ssm start-session --target ${jks.instance.instanceId}`,
});
- Deploy Jenkins with self-defined VPC and NLB
const jks = new JenkinsEC2(stack, 'superJks', {
vpc: Vpc.fromLookup(stack, 'defaultVPC', { isDefault: true }),
loadbalancerType: ELBtype.NLB,
});
- Deploy Jenkins with R53 records: If
acm
is not given, it would create a certificate validated from DNS by default.
const jks = new JenkinsEC2(stack, 'superJks', {
vpc: Vpc.fromLookup(stack, 'defaultVPC', { isDefault: true }),
loadbalancerType: ELBtype.NLB,
domain: {
acm: Certificate.fromCertificateArn(stack, 'cert',
'arn:aws:xxx',
),
hostedZoneId: 'xxx',
zoneName: 'bbb.ccc',
recordName: 'aaa',
},
});
Note: Jenkins initial admin password has been written to /home/ec2-user/jenkins-data/secrets/initialAdminPassword
. You can access EC2 instance using ssm tool.
aws ssm start-session --target instance-id