createContainerAssociation method

Future<CreateContainerAssociationResponse> createContainerAssociation({
  1. required String containerAssociationName,
  2. required List<ContainerMonitoringConfiguration> containerMonitoringConfigurations,
  3. required ContainerMonitoringType type,
  4. String? description,
  5. List<Tag>? tags,
})

Creates a Network Firewall container association. The association monitors container lifecycle events in your Amazon ECS or Amazon EKS clusters and resolves running container addresses for use in firewall rules.

May throw InsufficientCapacityException. May throw InternalServerError. May throw InvalidRequestException. May throw LimitExceededException. May throw ThrottlingException.

Parameter containerAssociationName : The descriptive name of the container association. You can't change the name of a container association after you create it.

Parameter containerMonitoringConfigurations : The monitoring configurations for the container association. Each configuration specifies an Amazon ECS or Amazon EKS cluster to monitor and optional attribute filters to narrow which containers are tracked.

Parameter type : The type of containers to monitor. You can't change the container type after creation. Valid values:

  • ECS - Amazon Elastic Container Service
  • EKS - Amazon Elastic Kubernetes Service

Parameter description : A description of the container association.

Parameter tags : The key:value pairs to associate with the resource.

Implementation

Future<CreateContainerAssociationResponse> createContainerAssociation({
  required String containerAssociationName,
  required List<ContainerMonitoringConfiguration>
      containerMonitoringConfigurations,
  required ContainerMonitoringType type,
  String? description,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'NetworkFirewall_20201112.CreateContainerAssociation'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ContainerAssociationName': containerAssociationName,
      'ContainerMonitoringConfigurations': containerMonitoringConfigurations,
      'Type': type.value,
      if (description != null) 'Description': description,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateContainerAssociationResponse.fromJson(jsonResponse.body);
}