اذهب إلى المحتوى
  • 0

كيف أنشئ Security Group باستخدام AWS CLI؟

Jason

السؤال

Recommended Posts

  • 0

يمكن إنشاء مجموعة أمان Security Group باستخدام واجهة سطر الأوامر CLI ويتم ذلك باستخدام الأمر create-security-group

لإنشاء مجموعة أمان في EC2-VPC اكتب الأمر التالي:

$ aws ec2 create-security-group --group-name my-sg --description "My security group" --vpc-id vpc-1a2b3c4d
{
    "GroupId": "sg-903004f8"
}

لعرض المعلومات الأولية للمجموعة my-sg استخدم الأمر describe-security-group:

$ aws ec2 describe-security-groups --group-ids sg-903004f8
{
    "SecurityGroups": [
        {
            "IpPermissionsEgress": [
                {
                    "IpProtocol": "-1",
                    "IpRanges": [
                        {
                            "CidrIp": "0.0.0.0/0"
                        }
                    ],
                    "UserIdGroupPairs": []
                }
            ],
            "Description": "My security group"
            "IpPermissions": [],
            "GroupName": "my-sg",
            "VpcId": "vpc-1a2b3c4d",
            "OwnerId": "123456789012",
            "GroupId": "sg-903004f8"
        }
    ]
}

لإضافة قواعد لمجموعة الأمان الخاصة بك في EC2-VPC:

الأمر التالي يضيف قاعدة لمجموعة أمان لها معرّف ID sg-903004f8

$ aws ec2 authorize-security-group-ingress --group-id sg-903004f8 --protocol tcp --port 3389 --cidr 203.0.113.0/24

لإضافة قاعدة لـ SSH إلى مجموعة أمان لها معرّف ID sg-903004f8 اكتب الأمر التالي:

$ aws ec2 authorize-security-group-ingress --group-id sg-903004f8 --protocol tcp --port 22 --cidr 203.0.113.0/24

لعرض التغييرات في مجموعة استخدم الأمر describe-security-group على النحو التالي:

$ aws ec2 describe-security-groups --group-ids sg-903004f8
{
    "SecurityGroups": [
        {
            "IpPermissionsEgress": [
                {
                    "IpProtocol": "-1",
                    "IpRanges": [
                        {
                            "CidrIp": "0.0.0.0/0"
                        }
                    ],
                    "UserIdGroupPairs": []
                }
            ],
            "Description": "My security group"
            "IpPermissions": [
                {
                    "ToPort": 22,
                    "IpProtocol": "tcp",
                    "IpRanges": [
                        {
                            "CidrIp": "203.0.113.0/24"
                        }
                    ]
                    "UserIdGroupPairs": [],
                    "FromPort": 22
                }
            ],
            "GroupName": "my-sg",
            "OwnerId": "123456789012",
            "GroupId": "sg-903004f8"
        }
    ]
}

يمكنك حذف مجموعة أمان باستخدام الأمر delete-security-group. الأمر التالي يقوم بحذف مجموعة أمان لها معرّف ID sg-903004f8 في EC2-VPC

$ aws ec2 delete-security-group --group-id sg-903004f8

ملاحظة: لا يمكنك حذف مجموعة أمان مرتبطة ببيئة في AWS

رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...