Skip to content

Commit

Permalink
allow to configure agents from the stack properties
Browse files Browse the repository at this point in the history
  • Loading branch information
tmokmss committed May 2, 2024
1 parent 31ae817 commit 3dfed63
Show file tree
Hide file tree
Showing 8 changed files with 2,148 additions and 2,031 deletions.
63 changes: 58 additions & 5 deletions bin/jenkins-unity-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import 'source-map-support/register';
import * as cdk from 'aws-cdk-lib';
import { JenkinsUnityBuildStack } from '../lib/jenkins-unity-build-stack';
import { InstanceClass, InstanceSize, InstanceType } from 'aws-cdk-lib/aws-ec2';
import { Size } from 'aws-cdk-lib';

const app = new cdk.App();
new JenkinsUnityBuildStack(app, 'JenkinsUnityBuildStack', {
Expand All @@ -17,14 +19,65 @@ new JenkinsUnityBuildStack(app, 'JenkinsUnityBuildStack', {
// ALB can be accessed with HTTP if you don't specify this property.
// certificateArn: "",

// Get the AMI ID for Mac instances from this page. Please make sure the region is correct.
// https://console.aws.amazon.com/ec2/v2/home#AMICatalog:
// macAmiId: 'ami-0665a0b2ea8636d1d', // Monterey Intel mac @us-east-2
// macAmiId: 'ami-013846afc111c94b0', // Monterey M1 mac @us-east-2

// You can use an existing VPC by specifying vpcId.
// vpcId: 'vpc-xxxxxxx',

ec2FleetConfigurations: [
{
type: 'LinuxFleet',
name: 'linux-small',
label: 'small',
numExecutors: 5,
},
{
type: 'LinuxFleet',
rootVolumeSize: Size.gibibytes(30),
dataVolumeSize: Size.gibibytes(100),
instanceTypes: [
InstanceType.of(InstanceClass.C5, InstanceSize.XLARGE),
InstanceType.of(InstanceClass.C5A, InstanceSize.XLARGE),
InstanceType.of(InstanceClass.C5N, InstanceSize.XLARGE),
InstanceType.of(InstanceClass.C4, InstanceSize.XLARGE),
],
name: 'linux-fleet',
label: 'linux',
fleetMinSize: 1,
fleetMaxSize: 4,
},
// You can add Windows fleet as well.
// {
// type: 'WindowsFleet',
// rootVolumeSize: Size.gibibytes(50),
// dataVolumeSize: Size.gibibytes(100),
// instanceTypes: [
// InstanceType.of(InstanceClass.M6A, InstanceSize.XLARGE),
// InstanceType.of(InstanceClass.M5A, InstanceSize.XLARGE),
// InstanceType.of(InstanceClass.M5N, InstanceSize.XLARGE),
// InstanceType.of(InstanceClass.M5, InstanceSize.XLARGE),
// ],
// name: 'windows-fleet',
// label: 'windows',
// fleetMinSize: 1,
// fleetMaxSize: 4,
// },
],

// You can add any number of Mac agents.
// macInstancesCOnfigurations: [
// {
// storageSize: cdk.Size.gibibytes(200),
// instanceType: InstanceType.of(InstanceClass.MAC2, InstanceSize.METAL),
// amiId: 'ami-038e1d574f3140013',
// name: 'mac0',
// subnet: (vpc) => vpc.privateSubnets[1],
// },
// ],

// You can deploy Unity Accelerator.
// unityAccelerator: {
// volumeSize: Size.gibibytes(100),
// }

// base url for your Unity license sever.
// You can setup one using this project: https://github.com/aws-samples/unity-build-server-with-aws-cdk
// licenseServerBaseUrl: 'http://10.0.0.100:8080',
Expand Down
4 changes: 2 additions & 2 deletions lib/construct/jenkins/agent-ec2-fleet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { join } from 'path';

export interface AgentEC2FleetPropsBase {
readonly vpc: ec2.IVpc;
readonly sshKeyName: string;
readonly sshKey: ec2.IKeyPair;
readonly instanceTypes: ec2.InstanceType[];

/**
Expand Down Expand Up @@ -172,7 +172,7 @@ export class AgentEC2Fleet extends Construct {
}),
},
],
keyName: props.sshKeyName,
keyPair: props.sshKey,
userData: props.userData,
role: new iam.Role(this, 'Role', {
assumedBy: new iam.ServicePrincipal('ec2.amazonaws.com'),
Expand Down
8 changes: 4 additions & 4 deletions lib/construct/jenkins/agent-mac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { CfnOutput, RemovalPolicy, Size } from 'aws-cdk-lib';

export interface AgentMacProps {
readonly vpc: IVpc;
readonly sshKeyName: string;
readonly sshKey: ec2.IKeyPair;
readonly amiId: string;
readonly storageSize: Size;
readonly instanceType: 'mac1.metal' | 'mac2.metal';
readonly instanceType: string;
readonly name: string;
readonly artifactBucket?: IBucket;
readonly subnet: ec2.ISubnet;
Expand Down Expand Up @@ -49,7 +49,7 @@ export class AgentMac extends Construct {
host.applyRemovalPolicy(RemovalPolicy.RETAIN);

// Brew installation path differs with mac1 (Intel) and mac2 (M1)
const brewPath = instanceType == 'mac2.metal' ? '/opt/homebrew' : '/usr/local';
const brewPath = instanceType == 'mac1.metal' ? '/usr/local' : '/opt/homebrew';
const userData = ec2.UserData.custom(`#!/bin/zsh
#install openjdk@17
su ec2-user -c '${brewPath}/bin/brew install openjdk@17 jq'
Expand Down Expand Up @@ -79,7 +79,7 @@ diskutil apfs resizeContainer $APFSCONT 0
}),
},
vpcSubnets: { subnets: [subnet] },
keyName: props.sshKeyName,
keyPair: props.sshKey,
blockDevices: [
{
deviceName: '/dev/sda1',
Expand Down
27 changes: 0 additions & 27 deletions lib/construct/jenkins/key-pair.ts

This file was deleted.

0 comments on commit 3dfed63

Please sign in to comment.