2016-05-03 9 views
5

में दो सुरक्षा समूहों के बीच नियम जोड़ने के लिए boto3 authorize_security_group_ingress का उपयोग कैसे करें मैं सुरक्षा समूह नियमों को अद्यतन करने के लिए सुरक्षा समूह नियमों को अद्यतन करने के लिए boto3 का उपयोग करने का प्रयास कर रहा हूं, सुरक्षा समूह b (sg_a) को सुरक्षा समूह b (sg_b) को अनुमति देने के लिए) बंदरगाह 8443.गैर डिफ़ॉल्ट वीपीसी

मैं निम्नलिखित

ec2.authorize_security_group_ingress(
     GroupId=sg_a, 
     SourceSecurityGroupName=sg_b, 
     IpProtocol='tcp', 
     FromPort=service_port, 
     ToPort=service_port 
    ) 

साथ इस लक्ष्य को हासिल करने के लिए EC2 ग्राहक का उपयोग करने की कोशिश कर रहा हूँ का उपयोग करने की है, लेकिन मैं यह त्रुटि आई:

botocore.exceptions.ClientError: An error occurred (VPCIdNotSpecified) when calling the AuthorizeSecurityGroupIngress operation: No default VPC for this user. 

मैं अधिकारियों का उपयोग कैसे करूँ एक गैर-डिफ़ॉल्ट वीपीसी के लिए ze_security_group_igress?

+0

[डॉक्स मदद मिल सकती है] (http://boto3.readthedocs.io/en/latest/reference/services/ec2.html#EC2.Client.authorize_security_group_ingress) – hangtwenty

+1

सही सिंटैक्स है: ' ec2.authorize_security_group_ingress ( ग्रुप = sg_a, IpPermissions = [{ 'IpProtocol': 'टीसीपी', 'FromPort': from_port, 'ToPort': to_port, 'UserIdGroupPairs' : [{ 'समूह आईडी': sg_b }] }], ) ' – blindstack

+0

कृपया अपना समाधान लिखें और इसे हल करें। – mootmoot

उत्तर

3

सही सिंटैक्स है:

ec2.authorize_security_group_ingress( 
    GroupId=sg_a, 
    IpPermissions=[ 
     {'IpProtocol': 'tcp', 
     'FromPort': from_port, 
     'ToPort': to_port, 
     'UserIdGroupPairs': [{ 'GroupId': sg_b }] } 
    ], 
) 
संबंधित मुद्दे