How could I add current pc IP into security group with aws cli

Question:

I want to add current working PC’s IP into a security group,

And enable all traffice for it. Every time I should do that manually with the web dashboard.

How could I do it with a shell script?

The following are the most common aws cli commands I used.

But I couldn’t find how to add ip in a specific security group.

Answer:

Here’s a script that determines the current computer’s IP address, then uses the AWS Command-Line Interface (CLI) to add access for ports 22 (SSH) and 3389 (RDP) — much safer than adding access on ALL ports.

It assumes that the AWS CLI has access to credentials, either via Instance Metadata (on Amazon EC2 instances) or from a local credentials file configured via aws configure.

Leave a Reply