@@ -52,16 +52,15 @@ jobs:
5252 IP=$(curl -s https://checkip.amazonaws.com | tr -d '\r\n')
5353 echo "ip=$IP" >> "$GITHUB_OUTPUT"
5454
55- - name : Allow SSH and capture rule-id
55+ - name : Allow SSH
5656 id : add
5757 run : |
5858 CIDR="${{ steps.egress.outputs.ip }}/32"
59- OUT=$(aws ec2 authorize-security-group-ingress \
59+ echo "Authorizing SSH from $CIDR"
60+ aws ec2 authorize-security-group-ingress \
6061 --group-id "${{ secrets.AWS_SECURITY_GROUP_ID }}" \
61- --protocol tcp --port 22 --cidr "$CIDR" \
62- --output json 2>&1) || true
63- RID=$(echo "$OUT" | jq -r '.SecurityGroupRules[0].SecurityGroupRuleId // empty')
64- echo "rule_id=$RID" >> "$GITHUB_OUTPUT"
62+ --protocol tcp --port 22 --cidr "$CIDR" || true
63+
6564
6665 - name : Wait for SG propagation
6766 run : sleep 8
@@ -104,12 +103,10 @@ jobs:
104103 - name : Revoke SSH
105104 if : always()
106105 run : |
107- RID="${{ steps.add.outputs.rule_id }}"
108106 CIDR="${{ steps.egress.outputs.ip }}/32"
109- if [ -n "$RID" ]; then
110- aws ec2 revoke-security-group-ingress --security-group-rule-ids "$RID" || true
111- else
112- aws ec2 revoke-security-group-ingress \
113- --group-id "${{ secrets.AWS_SECURITY_GROUP_ID }}" \
114- --protocol tcp --port 22 --cidr "$CIDR" || true
107+ echo "Revoking SSH from $CIDR"
108+ aws ec2 revoke-security-group-ingress \
109+ --group-id "${{ secrets.AWS_SECURITY_GROUP_ID }}" \
110+ --protocol tcp --port 22 --cidr "$CIDR" || true
111+
115112 fi
0 commit comments