<p>Ok I got the answer after exploring few things and looking at the error more attentively. Here is the way:</p>

<pre><code>aws ec2 authorize-security-group-ingress --group-id sg-07xxxx24d  --protocol tcp --port 22 --source-group sg-d7dyyyy5
</code></pre>

CC BY-SA 4.0
2018-07-26T23:15:18.290Z
2018-07-26T23:15:18.290Z
Prashast
<p>I have created a security group in AWS. I have added the ingress rule using the below command</p>

<pre><code>aws ec2 authorize-security-group-ingress --group-id sg-07xxxx4d --ip-protocol tcp --from-port 22 --to-port 22 --cidr-ip 0.0.0.0/0
</code></pre>

<p>But instead of IP, if i want to give the source as another existing security group, how can i do that?</p>

<amazon-web-services><aws-cli>
AWS Security Group Creation Using AWS CLI
Prashast
# AWS Security Group Creation Using AWS CLI

(Asked by: username_0 on 2018-07-26)

I have created a security group in AWS. I have added the ingress rule using the below command
aws ec2 authorize-security-group-ingress --group-id sg-07xxxx4d --ip-protocol tcp --from-port 22 --to-port 22 --cidr-ip 0.0.0.0/0

But instead of IP, if i want to give the source as another existing security group, how can i do that?

**Tags:** amazon-web-services, aws-cli


---

## 1 answers

### Answer by username_0 on 2018-07-26. Score: 2 | Accepted answer

Ok I got the answer after exploring few things and looking at the error more attentively. Here is the way:
aws ec2 authorize-security-group-ingress --group-id sg-07xxxx24d  --protocol tcp --port 22 --source-group sg-d7dyyyy5


---

