MCPcopy Create free account
hub / github.com/awsdocs/aws-doc-sdk-examples / create

Method create

python/example_code/ec2/vpc.py:40–59  ·  view source on GitHub ↗

Creates a new Amazon VPC with the specified CIDR block. :param cidr_block: The CIDR block for the new VPC, such as '10.0.0.0/16'. :return: The ID of the new VPC.

(self, cidr_block: str)

Source from the content-addressed store, hash-verified

38
39 # snippet-start:[python.example_code.ec2.CreateVpc]
40 def create(self, cidr_block: str) -> str:
41 """
42 Creates a new Amazon VPC with the specified CIDR block.
43
44 :param cidr_block: The CIDR block for the new VPC, such as '10.0.0.0/16'.
45 :return: The ID of the new VPC.
46 """
47 try:
48 response = self.ec2_client.create_vpc(CidrBlock=cidr_block)
49 vpc_id = response["Vpc"]["VpcId"]
50
51 waiter = self.ec2_client.get_waiter("vpc_available")
52 waiter.wait(VpcIds=[vpc_id])
53 return vpc_id
54 except ClientError as client_error:
55 logging.error(
56 "Couldn't create the vpc. Here's why: %s",
57 client_error.response["Error"]["Message"],
58 )
59 raise
60
61 # snippet-end:[python.example_code.ec2.CreateVpc]
62

Callers 15

test_createFunction · 0.95
App.tsxFile · 0.45
extendErrorFunction · 0.45
makeClassHandleFunction · 0.45
ClassHandle_cloneFunction · 0.45
__embind_register_classFunction · 0.45
create_security_groupMethod · 0.45
create_instanceMethod · 0.45
mainMethod · 0.45
mainMethod · 0.45
mainMethod · 0.45

Calls 1

waitMethod · 0.45