Refresh team keys for each runner

This commit is contained in:
Mikhail f. Shiryaev 2022-06-27 14:45:50 +02:00
parent 9dffe573bb
commit f2611c3707
No known key found for this signature in database
GPG Key ID: 4B02ED204C7D93F4
2 changed files with 7 additions and 2 deletions

View File

@ -26,6 +26,11 @@ export LABELS
aws ssm get-parameter --region us-east-1 --name AmazonCloudWatch-github-runners --query 'Parameter.Value' --output text > /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json aws ssm get-parameter --region us-east-1 --name AmazonCloudWatch-github-runners --query 'Parameter.Value' --output text > /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json
systemctl restart amazon-cloudwatch-agent.service systemctl restart amazon-cloudwatch-agent.service
# Refresh teams ssh keys
TEAM_KEYS_URL=$(aws ssm get-parameter --region us-east-1 --name team-keys-url --query 'Parameter.Value' --output=text)
curl "${TEAM_KEYS_URL}" > /home/ubuntu/.ssh/authorized_keys2
chown ubuntu: /home/ubuntu/.ssh -R
# Create a pre-run script that will restart docker daemon before the job started # Create a pre-run script that will restart docker daemon before the job started
mkdir -p /tmp/actions-hooks mkdir -p /tmp/actions-hooks

View File

@ -98,8 +98,8 @@ rm -rf /home/ubuntu/awscliv2.zip /home/ubuntu/aws
mkdir -p /home/ubuntu/.ssh mkdir -p /home/ubuntu/.ssh
# ~/.ssh/authorized_keys is cleaned out, so we use deprecated but working ~/.ssh/authorized_keys2 # ~/.ssh/authorized_keys is cleaned out, so we use deprecated but working ~/.ssh/authorized_keys2
aws lambda invoke --region us-east-1 --function-name team-keys-lambda /tmp/core.keys TEAM_KEYS_URL=$(aws ssm get-parameter --region us-east-1 --name team-keys-url --query 'Parameter.Value' --output=text)
jq < /tmp/core.keys -r '.body' > /home/ubuntu/.ssh/authorized_keys2 curl "${TEAM_KEYS_URL}" > /home/ubuntu/.ssh/authorized_keys2
chown ubuntu: /home/ubuntu/.ssh -R chown ubuntu: /home/ubuntu/.ssh -R
chmod 0700 /home/ubuntu/.ssh chmod 0700 /home/ubuntu/.ssh