Skip to content

Commit 7658bdc

Browse files
authored
Simplify SSH rule management in deploy_fortest.yml
Refactor SSH security group rules in deployment workflow.
1 parent 3fb7c8b commit 7658bdc

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

.github/workflows/deploy_fortest.yml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)