Hi@Lakshminarayanan,
You can find command to remove your ingress rule from the security group. You can use the below-given command in your script file.
$ aws ec2 revoke-security-group-ingress --group-name mygroup --protocol tcp --port 22 --cidr 203.0.113.0/24
Now to automate the script you can use Cron Job concept and schedule your task every two hours.