createLayer method
- required String name,
- required String shortname,
- required String stackId,
- required LayerType type,
- Map<
LayerAttributesKeys, String> ? attributes, - bool? autoAssignElasticIps,
- bool? autoAssignPublicIps,
- CloudWatchLogsConfiguration? cloudWatchLogsConfiguration,
- String? customInstanceProfileArn,
- String? customJson,
- Recipes? customRecipes,
- List<
String> ? customSecurityGroupIds, - bool? enableAutoHealing,
- bool? installUpdatesOnBoot,
- LifecycleEventConfiguration? lifecycleEventConfiguration,
- List<
String> ? packages, - bool? useEbsOptimizedInstances,
- List<
VolumeConfiguration> ? volumeConfigurations,
Creates a layer. For more information, see How to Create a Layer. 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 layer name, which is used by the console.
Parameter shortname
:
For custom layers only, use this parameter to specify the layer's short
name, which is used internally by AWS OpsWorks Stacks and by Chef recipes.
The short name is also used as the name for the directory where your app
files are installed. It can have a maximum of 200 characters, which are
limited to the alphanumeric characters, '-', '_', and '.'.
The built-in layers' short names are defined by AWS OpsWorks Stacks. For more information, see the Layer Reference.
Parameter stackId
:
The layer stack ID.
Parameter type
:
The layer type. A stack cannot have more than one built-in layer of the
same type. It can have any number of custom layers. Built-in layers are
not available in Chef 12 stacks.
Parameter attributes
:
One or more user-defined key-value pairs to be added to the stack
attributes.
To create a cluster layer, set the EcsClusterArn
attribute to
the cluster's ARN.
Parameter autoAssignElasticIps
:
Whether to automatically assign an Elastic
IP address to the layer's instances. For more information, see How
to Edit a Layer.
Parameter autoAssignPublicIps
:
For stacks that are running in a VPC, whether to automatically assign a
public IP address to the layer's instances. For more information, see How
to Edit a Layer.
Parameter cloudWatchLogsConfiguration
:
Specifies CloudWatch Logs configuration options for the layer. For more
information, see CloudWatchLogsLogStream.
Parameter customInstanceProfileArn
:
The ARN of an IAM profile to be used for the layer's EC2 instances. For
more information about IAM ARNs, see Using
Identifiers.
Parameter customJson
:
A JSON-formatted string containing custom stack configuration and
deployment attributes to be installed on the layer's instances. For more
information, see
Using Custom JSON. This feature is supported as of version 1.7.42 of
the AWS CLI.
Parameter customRecipes
:
A LayerCustomRecipes
object that specifies the layer custom
recipes.
Parameter customSecurityGroupIds
:
An array containing the layer custom security group IDs.
Parameter enableAutoHealing
:
Whether to disable auto healing for the layer.
Parameter installUpdatesOnBoot
:
Whether to install operating system and package updates when the instance
boots. The default value is true
. To control when updates are
installed, set this value to false
. You must then update your
instances manually by using CreateDeployment to run the
update_dependencies
stack command or by manually running
yum
(Amazon Linux) or apt-get
(Ubuntu) on the
instances.
Parameter lifecycleEventConfiguration
:
A LifeCycleEventConfiguration
object that you can use to
configure the Shutdown event to specify an execution timeout and enable or
disable Elastic Load Balancer connection draining.
Parameter packages
:
An array of Package
objects that describes the layer
packages.
Parameter useEbsOptimizedInstances
:
Whether to use Amazon EBS-optimized instances.
Parameter volumeConfigurations
:
A VolumeConfigurations
object that describes the layer's
Amazon EBS volumes.
Implementation
Future<CreateLayerResult> createLayer({
required String name,
required String shortname,
required String stackId,
required LayerType type,
Map<LayerAttributesKeys, String>? attributes,
bool? autoAssignElasticIps,
bool? autoAssignPublicIps,
CloudWatchLogsConfiguration? cloudWatchLogsConfiguration,
String? customInstanceProfileArn,
String? customJson,
Recipes? customRecipes,
List<String>? customSecurityGroupIds,
bool? enableAutoHealing,
bool? installUpdatesOnBoot,
LifecycleEventConfiguration? lifecycleEventConfiguration,
List<String>? packages,
bool? useEbsOptimizedInstances,
List<VolumeConfiguration>? volumeConfigurations,
}) async {
ArgumentError.checkNotNull(name, 'name');
ArgumentError.checkNotNull(shortname, 'shortname');
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.CreateLayer'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'Name': name,
'Shortname': shortname,
'StackId': stackId,
'Type': type.toValue(),
if (attributes != null)
'Attributes': attributes.map((k, e) => MapEntry(k.toValue(), e)),
if (autoAssignElasticIps != null)
'AutoAssignElasticIps': autoAssignElasticIps,
if (autoAssignPublicIps != null)
'AutoAssignPublicIps': autoAssignPublicIps,
if (cloudWatchLogsConfiguration != null)
'CloudWatchLogsConfiguration': cloudWatchLogsConfiguration,
if (customInstanceProfileArn != null)
'CustomInstanceProfileArn': customInstanceProfileArn,
if (customJson != null) 'CustomJson': customJson,
if (customRecipes != null) 'CustomRecipes': customRecipes,
if (customSecurityGroupIds != null)
'CustomSecurityGroupIds': customSecurityGroupIds,
if (enableAutoHealing != null) 'EnableAutoHealing': enableAutoHealing,
if (installUpdatesOnBoot != null)
'InstallUpdatesOnBoot': installUpdatesOnBoot,
if (lifecycleEventConfiguration != null)
'LifecycleEventConfiguration': lifecycleEventConfiguration,
if (packages != null) 'Packages': packages,
if (useEbsOptimizedInstances != null)
'UseEbsOptimizedInstances': useEbsOptimizedInstances,
if (volumeConfigurations != null)
'VolumeConfigurations': volumeConfigurations,
},
);
return CreateLayerResult.fromJson(jsonResponse.body);
}