@@ -92,16 +92,11 @@ export class CdkStack extends Stack {
9292 for ( let i = 0 ; i < config . instanceCount ; i ++ ) {
9393 const userData = ec2 . UserData . forLinux ( ) ;
9494
95- // Download worker binary from S3 asset
96- userData . addS3DownloadCommand ( {
97- bucket : workerBinary . bucket ,
98- bucketKey : workerBinary . s3ObjectKey ,
99- localFile : '/usr/local/bin/worker' ,
100- } ) ;
101-
10295 userData . addCommands (
103- // Make binary executable
104- 'chmod +x /usr/local/bin/worker' ,
96+ // Install Rust tooling.
97+ 'yum install gcc' ,
98+ "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh" ,
99+ 'cargo install --locked tokio-console' ,
105100
106101 // Create systemd service
107102 `cat > /etc/systemd/system/worker.service << 'EOF'
@@ -160,7 +155,9 @@ sudo journalctl -u worker.service -f -o cat
160155 description : 'Session Manager commands to connect to instances' ,
161156 } ) ;
162157
163- // Custom resource to restart worker service on every deploy
158+ // Downloads the latest version of the worker binary and restarts the systemd service.
159+ // This is done instead of the userData.addS3Download() so that the instance does not need
160+ // to restart every time a new worker binary is available.
164161 const restartWorker = new cr . AwsCustomResource ( this , 'RestartWorkerService' , {
165162 onUpdate : {
166163 service : 'SSM' ,
0 commit comments