amazon web services - Setting .authorize_egress() with protocol set to all -


i trying execute following code

def createsecuritygroup(self, securitygroupname):      conn = boto3.resource('ec2')      response = conn.create_security_group(groupname=securitygroupname, description = 'test')  vpc_nat_securityobject = createsecuritygroup("mysecurity_group")  response_egress_all =  vpc_nat_securityobject.authorize_egress(         ippermissions=[{'ipprotocol': '-1'}]) 

and getting below exception

exception : an error occurred (invalidparametervalue) when calling authorizesecuritygroupegress operation: amazon vpc security groups may used operation.

i tried several different combinations not able set protocol . used '-1' explained in boto3 documentation. can pls suggest how done.

(update)

1.boto3.resource("ec2") class high level class wrap around client class. must create extract class instantiation using boto3.resource("ec2").vpc in order attach specific vpc id e.g.

import boto3 ec2_resource = boto3.resource("ec2")  myvpc = ec2_resource.vpc("vpc-xxxxxxxx")  response = myvpc.create_security_group(    groupname = securitygroupname,     description = 'test') 

2.sometime straightforward use boto3.client("ec2") if check boto3 ec2 client create_security_group, see this:

response = client.create_security_group(   dryrun=true|false,   groupname='string',   description='string',   vpcid='string'  ) 

if use automation script/template rebuild vpc, e.g. salt-cloud, need give vpc tag name in order acquire automatically boto3 script. save hassle when aws migrate aws resources id 8 alphanumeric 12 or 15 character.

another option using cloudformation let put , specify variable in template recreate vpc stack.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -