From 6a11f0e4e66d0ddda3130c486f4e335f331d31c6 Mon Sep 17 00:00:00 2001 From: miles-grant-ibi Date: Tue, 21 May 2024 13:38:58 -0400 Subject: [PATCH 1/2] disable tokens requirement --- .../java/com/conveyal/datatools/manager/jobs/DeployJob.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/conveyal/datatools/manager/jobs/DeployJob.java b/src/main/java/com/conveyal/datatools/manager/jobs/DeployJob.java index 162f28525..ffa8bd9a8 100644 --- a/src/main/java/com/conveyal/datatools/manager/jobs/DeployJob.java +++ b/src/main/java/com/conveyal/datatools/manager/jobs/DeployJob.java @@ -7,6 +7,7 @@ import com.amazonaws.services.ec2.model.Filter; import com.amazonaws.services.ec2.model.IamInstanceProfileSpecification; import com.amazonaws.services.ec2.model.Instance; +import com.amazonaws.services.ec2.model.InstanceMetadataOptionsRequest; import com.amazonaws.services.ec2.model.InstanceNetworkInterfaceSpecification; import com.amazonaws.services.ec2.model.InstanceStateChange; import com.amazonaws.services.ec2.model.InstanceType; @@ -1009,6 +1010,7 @@ private List startEC2Instances(int count, boolean graphAlreadyBuilt) { .withKeyName(otpServer.ec2Info.keyName) // This will have the instance terminate when it is shut down. .withInstanceInitiatedShutdownBehavior("terminate") + .withMetadataOptions(new InstanceMetadataOptionsRequest().withHttpTokens("optional").withHttpEndpoint("enabled")) .withUserData(Base64.encodeBase64String(userData.getBytes())); List instances; try { @@ -1383,6 +1385,7 @@ public String constructUserData(boolean graphAlreadyBuilt) { List lines = new ArrayList<>(); lines.add("#!/bin/bash"); + lines.add("mkdir /opt/otp/"); // NOTE: user data output is logged to `/var/log/cloud-init-output.log` automatically with ec2 instances // Add some items to the $PATH as the $PATH with user-data scripts differs from the ssh $PATH. lines.add("export PATH=\"$PATH:/home/ubuntu/.yarn/bin\""); From e9753de0610080e6b7212b1f162468ed3faa5cc3 Mon Sep 17 00:00:00 2001 From: miles-grant-ibi Date: Wed, 22 May 2024 13:48:19 -0400 Subject: [PATCH 2/2] update snapshots --- .../canMakeGraphBuildAndServeManifestAndUserData-1.json | 2 +- .../canMakeOtp2GraphBuildAndServeManifestAndUserData-1.json | 2 +- .../DeployJobTest/canMakeServerOnlyManifestAndUserData-1.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/resources/snapshots/com/conveyal/datatools/manager/jobs/DeployJobTest/canMakeGraphBuildAndServeManifestAndUserData-1.json b/src/test/resources/snapshots/com/conveyal/datatools/manager/jobs/DeployJobTest/canMakeGraphBuildAndServeManifestAndUserData-1.json index fd57ffc19..a38842fc8 100644 --- a/src/test/resources/snapshots/com/conveyal/datatools/manager/jobs/DeployJobTest/canMakeGraphBuildAndServeManifestAndUserData-1.json +++ b/src/test/resources/snapshots/com/conveyal/datatools/manager/jobs/DeployJobTest/canMakeGraphBuildAndServeManifestAndUserData-1.json @@ -1 +1 @@ -"#!/bin/bash\nexport PATH=\"$PATH:/home/ubuntu/.yarn/bin\"\nexport PATH=\"$PATH:/home/ubuntu/.nvm/versions/node/v12.16.3/bin\"\nrm /usr/share/nginx/client/status.json || echo '' > /dev/null\nrm /var/otp/otp-runner-manifest.json || echo '' > /dev/null\nrm /opt/otp/otp-latest-trimet-dev || echo '' > /dev/null\nrm /var/log/otp-runner.log || echo '' > /dev/null\nrm /var/log/otp-build.log || echo '' > /dev/null\nrm /var/log/otp-server.log || echo '' > /dev/null\naws s3 cp s3://datatools-dev/test-deploy/otp-runner-graph-build-manifest.json /var/otp/otp-runner-manifest.json\nyarn global add https://github.com/ibi-group/otp-runner.git#master\notp-runner /var/otp/otp-runner-manifest.json" \ No newline at end of file +"#!/bin/bash\nmkdir /opt/otp/\nexport PATH=\"$PATH:/home/ubuntu/.yarn/bin\"\nexport PATH=\"$PATH:/home/ubuntu/.nvm/versions/node/v12.16.3/bin\"\nrm /usr/share/nginx/client/status.json || echo '' > /dev/null\nrm /var/otp/otp-runner-manifest.json || echo '' > /dev/null\nrm /opt/otp/otp-latest-trimet-dev || echo '' > /dev/null\nrm /var/log/otp-runner.log || echo '' > /dev/null\nrm /var/log/otp-build.log || echo '' > /dev/null\nrm /var/log/otp-server.log || echo '' > /dev/null\naws s3 cp s3://datatools-dev/test-deploy/otp-runner-graph-build-manifest.json /var/otp/otp-runner-manifest.json\nyarn global add https://github.com/ibi-group/otp-runner.git#master\notp-runner /var/otp/otp-runner-manifest.json" \ No newline at end of file diff --git a/src/test/resources/snapshots/com/conveyal/datatools/manager/jobs/DeployJobTest/canMakeOtp2GraphBuildAndServeManifestAndUserData-1.json b/src/test/resources/snapshots/com/conveyal/datatools/manager/jobs/DeployJobTest/canMakeOtp2GraphBuildAndServeManifestAndUserData-1.json index fd57ffc19..a38842fc8 100644 --- a/src/test/resources/snapshots/com/conveyal/datatools/manager/jobs/DeployJobTest/canMakeOtp2GraphBuildAndServeManifestAndUserData-1.json +++ b/src/test/resources/snapshots/com/conveyal/datatools/manager/jobs/DeployJobTest/canMakeOtp2GraphBuildAndServeManifestAndUserData-1.json @@ -1 +1 @@ -"#!/bin/bash\nexport PATH=\"$PATH:/home/ubuntu/.yarn/bin\"\nexport PATH=\"$PATH:/home/ubuntu/.nvm/versions/node/v12.16.3/bin\"\nrm /usr/share/nginx/client/status.json || echo '' > /dev/null\nrm /var/otp/otp-runner-manifest.json || echo '' > /dev/null\nrm /opt/otp/otp-latest-trimet-dev || echo '' > /dev/null\nrm /var/log/otp-runner.log || echo '' > /dev/null\nrm /var/log/otp-build.log || echo '' > /dev/null\nrm /var/log/otp-server.log || echo '' > /dev/null\naws s3 cp s3://datatools-dev/test-deploy/otp-runner-graph-build-manifest.json /var/otp/otp-runner-manifest.json\nyarn global add https://github.com/ibi-group/otp-runner.git#master\notp-runner /var/otp/otp-runner-manifest.json" \ No newline at end of file +"#!/bin/bash\nmkdir /opt/otp/\nexport PATH=\"$PATH:/home/ubuntu/.yarn/bin\"\nexport PATH=\"$PATH:/home/ubuntu/.nvm/versions/node/v12.16.3/bin\"\nrm /usr/share/nginx/client/status.json || echo '' > /dev/null\nrm /var/otp/otp-runner-manifest.json || echo '' > /dev/null\nrm /opt/otp/otp-latest-trimet-dev || echo '' > /dev/null\nrm /var/log/otp-runner.log || echo '' > /dev/null\nrm /var/log/otp-build.log || echo '' > /dev/null\nrm /var/log/otp-server.log || echo '' > /dev/null\naws s3 cp s3://datatools-dev/test-deploy/otp-runner-graph-build-manifest.json /var/otp/otp-runner-manifest.json\nyarn global add https://github.com/ibi-group/otp-runner.git#master\notp-runner /var/otp/otp-runner-manifest.json" \ No newline at end of file diff --git a/src/test/resources/snapshots/com/conveyal/datatools/manager/jobs/DeployJobTest/canMakeServerOnlyManifestAndUserData-1.json b/src/test/resources/snapshots/com/conveyal/datatools/manager/jobs/DeployJobTest/canMakeServerOnlyManifestAndUserData-1.json index 64c1ee425..26213dbbb 100644 --- a/src/test/resources/snapshots/com/conveyal/datatools/manager/jobs/DeployJobTest/canMakeServerOnlyManifestAndUserData-1.json +++ b/src/test/resources/snapshots/com/conveyal/datatools/manager/jobs/DeployJobTest/canMakeServerOnlyManifestAndUserData-1.json @@ -1 +1 @@ -"#!/bin/bash\nexport PATH=\"$PATH:/home/ubuntu/.yarn/bin\"\nexport PATH=\"$PATH:/home/ubuntu/.nvm/versions/node/v12.16.3/bin\"\nrm /usr/share/nginx/client/status.json || echo '' > /dev/null\nrm /var/otp/otp-runner-manifest.json || echo '' > /dev/null\nrm /opt/otp/otp-latest-trimet-dev || echo '' > /dev/null\nrm /var/log/otp-runner.log || echo '' > /dev/null\nrm /var/log/otp-build.log || echo '' > /dev/null\nrm /var/log/otp-server.log || echo '' > /dev/null\naws s3 cp s3://datatools-dev/test-deploy/otp-runner-server-only-manifest.json /var/otp/otp-runner-manifest.json\nyarn global add https://github.com/ibi-group/otp-runner.git#master\notp-runner /var/otp/otp-runner-manifest.json" \ No newline at end of file +"#!/bin/bash\nmkdir /opt/otp/\nexport PATH=\"$PATH:/home/ubuntu/.yarn/bin\"\nexport PATH=\"$PATH:/home/ubuntu/.nvm/versions/node/v12.16.3/bin\"\nrm /usr/share/nginx/client/status.json || echo '' > /dev/null\nrm /var/otp/otp-runner-manifest.json || echo '' > /dev/null\nrm /opt/otp/otp-latest-trimet-dev || echo '' > /dev/null\nrm /var/log/otp-runner.log || echo '' > /dev/null\nrm /var/log/otp-build.log || echo '' > /dev/null\nrm /var/log/otp-server.log || echo '' > /dev/null\naws s3 cp s3://datatools-dev/test-deploy/otp-runner-server-only-manifest.json /var/otp/otp-runner-manifest.json\nyarn global add https://github.com/ibi-group/otp-runner.git#master\notp-runner /var/otp/otp-runner-manifest.json" \ No newline at end of file