createVpcConnector method

Future<CreateVpcConnectorResponse> createVpcConnector({
  1. required List<String> subnets,
  2. required String vpcConnectorName,
  3. List<String>? securityGroups,
  4. List<Tag>? tags,
})

Create an App Runner VPC connector resource. App Runner requires this resource when you want to associate your App Runner service to a custom Amazon Virtual Private Cloud (Amazon VPC).

May throw InternalServiceErrorException. May throw InvalidRequestException. May throw ServiceQuotaExceededException.

Parameter subnets : A list of IDs of subnets that App Runner should use when it associates your service with a custom Amazon VPC. Specify IDs of subnets of a single Amazon VPC. App Runner determines the Amazon VPC from the subnets you specify.

Parameter vpcConnectorName : A name for the VPC connector.

Parameter securityGroups : A list of IDs of security groups that App Runner should use for access to Amazon Web Services resources under the specified subnets. If not specified, App Runner uses the default security group of the Amazon VPC. The default security group allows all outbound traffic.

Parameter tags : A list of metadata items that you can associate with your VPC connector resource. A tag is a key-value pair.

Implementation

Future<CreateVpcConnectorResponse> createVpcConnector({
  required List<String> subnets,
  required String vpcConnectorName,
  List<String>? securityGroups,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'AppRunner.CreateVpcConnector'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Subnets': subnets,
      'VpcConnectorName': vpcConnectorName,
      if (securityGroups != null) 'SecurityGroups': securityGroups,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateVpcConnectorResponse.fromJson(jsonResponse.body);
}