createEnvironment method

Future<Environment> createEnvironment({
  1. required String applicationId,
  2. required String name,
  3. String? description,
  4. List<Monitor>? monitors,
  5. Map<String, String>? tags,
})

For each application, you define one or more environments. An environment is a logical deployment group of AppConfig targets, such as applications in a Beta or Production environment. You can also define environments for application subcomponents such as the Web, Mobile and Back-end components for your application. You can configure Amazon CloudWatch alarms for each environment. The system monitors alarms during a configuration deployment. If an alarm is triggered, the system rolls back the configuration.

May throw InternalServerException. May throw ResourceNotFoundException. May throw BadRequestException.

Parameter applicationId : The application ID.

Parameter name : A name for the environment.

Parameter description : A description of the environment.

Parameter monitors : Amazon CloudWatch alarms to monitor during the deployment process.

Parameter tags : Metadata to assign to the environment. Tags help organize and categorize your AppConfig resources. Each tag consists of a key and an optional value, both of which you define.

Implementation

Future<Environment> createEnvironment({
  required String applicationId,
  required String name,
  String? description,
  List<Monitor>? monitors,
  Map<String, String>? tags,
}) async {
  ArgumentError.checkNotNull(applicationId, 'applicationId');
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    1,
    64,
    isRequired: true,
  );
  _s.validateStringLength(
    'description',
    description,
    0,
    1024,
  );
  final $payload = <String, dynamic>{
    'Name': name,
    if (description != null) 'Description': description,
    if (monitors != null) 'Monitors': monitors,
    if (tags != null) 'Tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/applications/${Uri.encodeComponent(applicationId)}/environments',
    exceptionFnMap: _exceptionFns,
  );
  return Environment.fromJson(response);
}