Duncan. I suspect you have done this at an application level and not at a security group level, in which case your only option is to stop the instance, detach the root EBS volume if indeed it is an EBS volume and not an ephemeral drive, and attach it to another running instance as a secondary drive. On this second instance, navigate to the appropriate file, edit and make the change, unmount and disconnect the secondary drive from the running instance and re-connect it to the original instance and start up.
More specific details here.
http://aws.amazon.com/instance-help/