createApp method

Future<CreateAppResult> createApp({
  1. required String name,
  2. required String stackId,
  3. required AppType type,
  4. Source? appSource,
  5. Map<AppAttributesKeys, String>? attributes,
  6. List<DataSource>? dataSources,
  7. String? description,
  8. List<String>? domains,
  9. bool? enableSsl,
  10. List<EnvironmentVariable>? environment,
  11. String? shortname,
  12. SslConfiguration? sslConfiguration,
})

Creates an app for a specified stack. For more information, see Creating Apps.

Required Permissions: To use this action, an IAM user must have a Manage permissions level for the stack, or an attached policy that explicitly grants permissions. For more information on user permissions, see Managing User Permissions.

May throw ValidationException. May throw ResourceNotFoundException.

Parameter name : The app name.

Parameter stackId : The stack ID.

Parameter type : The app type. Each supported type is associated with a particular layer. For example, PHP applications are associated with a PHP layer. AWS OpsWorks Stacks deploys an application to those instances that are members of the corresponding layer. If your app isn't one of the standard types, or you prefer to implement your own Deploy recipes, specify other.

Parameter appSource : A Source object that specifies the app repository.

Parameter attributes : One or more user-defined key/value pairs to be added to the stack attributes.

Parameter dataSources : The app's data source.

Parameter description : A description of the app.

Parameter domains : The app virtual host settings, with multiple domains separated by commas. For example: 'www.example.com, example.com'

Parameter enableSsl : Whether to enable SSL for the app.

Parameter environment : An array of EnvironmentVariable objects that specify environment variables to be associated with the app. After you deploy the app, these variables are defined on the associated app server instance. For more information, see Environment Variables.

There is no specific limit on the number of environment variables. However, the size of the associated data structure - which includes the variables' names, values, and protected flag values - cannot exceed 20 KB. This limit should accommodate most if not all use cases. Exceeding it will cause an exception with the message, "Environment: is too large (maximum is 20KB)."

Parameter shortname : The app's short name.

Parameter sslConfiguration : An SslConfiguration object with the SSL configuration.

Implementation

Future<CreateAppResult> createApp({
  required String name,
  required String stackId,
  required AppType type,
  Source? appSource,
  Map<AppAttributesKeys, String>? attributes,
  List<DataSource>? dataSources,
  String? description,
  List<String>? domains,
  bool? enableSsl,
  List<EnvironmentVariable>? environment,
  String? shortname,
  SslConfiguration? sslConfiguration,
}) async {
  ArgumentError.checkNotNull(name, 'name');
  ArgumentError.checkNotNull(stackId, 'stackId');
  ArgumentError.checkNotNull(type, 'type');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'OpsWorks_20130218.CreateApp'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Name': name,
      'StackId': stackId,
      'Type': type.toValue(),
      if (appSource != null) 'AppSource': appSource,
      if (attributes != null)
        'Attributes': attributes.map((k, e) => MapEntry(k.toValue(), e)),
      if (dataSources != null) 'DataSources': dataSources,
      if (description != null) 'Description': description,
      if (domains != null) 'Domains': domains,
      if (enableSsl != null) 'EnableSsl': enableSsl,
      if (environment != null) 'Environment': environment,
      if (shortname != null) 'Shortname': shortname,
      if (sslConfiguration != null) 'SslConfiguration': sslConfiguration,
    },
  );

  return CreateAppResult.fromJson(jsonResponse.body);
}