0

I am new to aws.

I have a third party service running on an instance. The service uses a few different ports. When there is a need to restart the service some of the ports change randomly even though the ports are pre defined in the service's config. This quirky behaviour is not in my control. I end up updating the security group with the changed port values manually every time there is a restart. I have to update as quickly as possible because connected user's might be blocked out.

I understand it is possible to programmatically change security groups using the aws sdk. I would like to automate this for the instance running the service. So basically have some script which restarts the service, checks the new port values and sets up the security group from within the instance. My questions are:

- Is it possible to do this from within the running instance?
- Or maybe from another aws instance?
- If it is possible are there any potential pitfalls ?
- Are their any other ways to achieve this automation?

thanks for the help.

1 Answer 1

0

Install the AWS command line utilities on that instance.

http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/set-up-ec2-cli-linux.html

One pitfall, is that you have to have your AWS Access Key and Secret copied to that instance so that the scripts will work.

You can also install on a separate instance. We use a micro instance for executing our EC2 scripts. You can execute the commands over SSH.

1
  • Just a side note on this, the preferred way is not to copy your AWS credentials to the machine but instead apply an IAM Role to the instance which has the minimum privileges needed applied to it.
    – Bazze
    Sep 23, 2015 at 16:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .