def create_network_interface(self): subnet_id = self._get_param("SubnetId") private_ip_address = self._get_param("PrivateIpAddress") private_ip_addresses = self._get_multi_param("PrivateIpAddresses") ipv6_addresses = self._get_multi_param("Ipv6Addresses") ipv6_address_count = self._get_int_param("Ipv6AddressCount", 0) secondary_ips_count = self._get_param("SecondaryPrivateIpAddressCount") groups = self._get_multi_param("SecurityGroupId") subnet = self.ec2_backend.get_subnet(subnet_id) description = self._get_param("Description") tags = self._get_multi_param("TagSpecification") tags = add_tag_specification(tags) if self.is_not_dryrun("CreateNetworkInterface"): eni = self.ec2_backend.create_network_interface( subnet, private_ip_address, private_ip_addresses, groups, description, tags, secondary_ips_count=secondary_ips_count, ipv6_addresses=ipv6_addresses, ipv6_address_count=ipv6_address_count, ) template = self.response_template( CREATE_NETWORK_INTERFACE_RESPONSE) return template.render(eni=eni)
def create_vpc_endpoint(self): vpc_id = self._get_param("VpcId") service_name = self._get_param("ServiceName") route_table_ids = self._get_multi_param("RouteTableId") subnet_ids = self._get_multi_param("SubnetId") endpoint_type = self._get_param("VpcEndpointType") policy_document = self._get_param("PolicyDocument") client_token = self._get_param("ClientToken") tags = self._get_multi_param("TagSpecification") private_dns_enabled = self._get_bool_param("PrivateDnsEnabled", if_none=True) security_group_ids = self._get_multi_param("SecurityGroupId") tags = add_tag_specification(tags) vpc_end_point = self.ec2_backend.create_vpc_endpoint( vpc_id=vpc_id, service_name=service_name, endpoint_type=endpoint_type, policy_document=policy_document, route_table_ids=route_table_ids, subnet_ids=subnet_ids, client_token=client_token, security_group_ids=security_group_ids, tags=tags, private_dns_enabled=private_dns_enabled, ) template = self.response_template(CREATE_VPC_END_POINT) return template.render(vpc_end_point=vpc_end_point)
def create_egress_only_internet_gateway(self): vpc_id = self._get_param("VpcId") tags = self._get_multi_param("TagSpecification") tags = add_tag_specification(tags) egress_only_igw = self.ec2_backend.create_egress_only_internet_gateway( vpc_id=vpc_id, tags=tags) template = self.response_template(CREATE_EGRESS_ONLY_IGW_RESPONSE) return template.render(egress_only_igw=egress_only_igw)
def create_carrier_gateway(self): vpc_id = self._get_param("VpcId") tags = self._get_multi_param("TagSpecification") tags = add_tag_specification(tags) carrier_gateway = self.ec2_backend.create_carrier_gateway( vpc_id=vpc_id, tags=tags) template = self.response_template(CREATE_CARRIER_GATEWAY_RESPONSE) return template.render(carrier_gateway=carrier_gateway)
def allocate_address(self): domain = self._get_param("Domain", if_none="standard") reallocate_address = self._get_param("Address", if_none=None) tags = self._get_multi_param("TagSpecification") tags = add_tag_specification(tags) if self.is_not_dryrun("AllocateAddress"): if reallocate_address: address = self.ec2_backend.allocate_address( domain, address=reallocate_address, tags=tags) else: address = self.ec2_backend.allocate_address(domain, tags=tags) template = self.response_template(ALLOCATE_ADDRESS_RESPONSE) return template.render(address=address)
def create_nat_gateway(self): subnet_id = self._get_param("SubnetId") allocation_id = self._get_param("AllocationId") connectivity_type = self._get_param("ConnectivityType") tags = self._get_multi_param("TagSpecification") tags = add_tag_specification(tags) nat_gateway = self.ec2_backend.create_nat_gateway( subnet_id=subnet_id, allocation_id=allocation_id, tags=tags, connectivity_type=connectivity_type, ) template = self.response_template(CREATE_NAT_GATEWAY) return template.render(nat_gateway=nat_gateway)
def create_transit_gateway_peering_attachment(self): peer_account_id = self._get_param("PeerAccountId") peer_region = self._get_param("PeerRegion") peer_transit_gateway_id = self._get_param("PeerTransitGatewayId") transit_gateway_id = self._get_param("TransitGatewayId") tags = add_tag_specification(self._get_multi_param("TagSpecification")) transit_gateway_peering_attachment = self.ec2_backend.create_transit_gateway_peering_attachment( transit_gateway_id, peer_transit_gateway_id, peer_region, peer_account_id, tags, ) template = self.response_template(TRANSIT_GATEWAY_PEERING_ATTACHMENT) return template.render( method_name="CreateTransitGatewayPeeringAttachment", transit_gateway_peering_attachment=transit_gateway_peering_attachment, )
def create_vpn_connection(self): vpn_conn_type = self._get_param("Type") cgw_id = self._get_param("CustomerGatewayId") vgw_id = self._get_param("VpnGatewayId") tgw_id = self._get_param("TransitGatewayId") static_routes = self._get_param("StaticRoutesOnly") tags = add_tag_specification(self._get_multi_param("TagSpecification")) vpn_connection = self.ec2_backend.create_vpn_connection( vpn_conn_type, cgw_id, vpn_gateway_id=vgw_id, transit_gateway_id=tgw_id, static_routes_only=static_routes, tags=tags, ) if vpn_connection.transit_gateway_id: self.ec2_backend.create_transit_gateway_vpn_attachment( vpn_id=vpn_connection.id, transit_gateway_id=tgw_id) template = self.response_template(CREATE_VPN_CONNECTION_RESPONSE) return template.render(vpn_connection=vpn_connection)