Skip to content

Resource: awsOpsworksCustomLayer

Provides an OpsWorks custom layer resource.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.opsworksCustomLayer.OpsworksCustomLayer(this, "custlayer", {
  name: "My Awesome Custom Layer",
  shortName: "awesome",
  stackId: "${aws_opsworks_stack.main.id}",
});

Argument Reference

The following arguments are supported:

  • name - (Required) A human-readable name for the layer.
  • shortName - (Required) A short, machine-readable name for the layer, which will be used to identify it in the Chef node JSON.
  • stackId - (Required) ID of the stack the layer will belong to.
  • autoAssignElasticIps - (Optional) Whether to automatically assign an elastic IP address to the layer's instances.
  • autoAssignPublicIps - (Optional) For stacks belonging to a VPC, whether to automatically assign a public IP address to each of the layer's instances.
  • cloudwatchConfiguration - (Optional) Will create an EBS volume and connect it to the layer's instances. See Cloudwatch Configuration.
  • customInstanceProfileArn - (Optional) The ARN of an IAM profile that will be used for the layer's instances.
  • customSecurityGroupIds - (Optional) Ids for a set of security groups to apply to the layer's instances.
  • autoHealing - (Optional) Whether to enable auto-healing for the layer.
  • installUpdatesOnBoot - (Optional) Whether to install OS and package updates on each instance when it boots.
  • instanceShutdownTimeout - (Optional) The time, in seconds, that OpsWorks will wait for Chef to complete after triggering the Shutdown event.
  • elasticLoadBalancer - (Optional) Name of an Elastic Load Balancer to attach to this layer
  • drainElbOnShutdown - (Optional) Whether to enable Elastic Load Balancing connection draining.
  • loadBasedAutoScaling - (Optional) Load-based auto scaling configuration. See Load Based AutoScaling
  • systemPackages - (Optional) Names of a set of system packages to install on the layer's instances.
  • useEbsOptimizedInstances - (Optional) Whether to use EBS-optimized instances.
  • ebsVolume - (Optional) Will create an EBS volume and connect it to the layer's instances. See EBS Volume.
  • customJson - (Optional) Custom JSON attributes to apply to the layer.
  • tags - (Optional) A map of tags to assign to the resource. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

The following extra optional arguments, all lists of Chef recipe names, allow custom Chef recipes to be applied to layer instances at the five different lifecycle events, if custom cookbooks are enabled on the layer's stack:

  • customConfigureRecipes
  • customDeployRecipes
  • customSetupRecipes
  • customShutdownRecipes
  • customUndeployRecipes

EBS Volume

  • mountPoint - (Required) The path to mount the EBS volume on the layer's instances.
  • size - (Required) The size of the volume in gigabytes.
  • numberOfDisks - (Required) The number of disks to use for the EBS volume.
  • raidLevel - (Required) The RAID level to use for the volume.
  • type - (Optional) The type of volume to create. This may be standard (the default), io1 or gp2.
  • iops - (Optional) For PIOPS volumes, the IOPS per disk.
  • encrypted - (Optional) Encrypt the volume.

Cloudwatch Configuration

  • enabled - (Optional)
  • logStreams - (Optional) A block the specifies how an opsworks logs look like. See Log Streams.

Log Streams

  • file - (Required) Specifies log files that you want to push to CloudWatch Logs. File can point to a specific file or multiple files (by using wild card characters such as /var/log/system.log*).
  • logGroupName - (Required) Specifies the destination log group. A log group is created automatically if it doesn't already exist.
  • batchCount - (Optional) Specifies the max number of log events in a batch, up to 10000. The default value is 1000.
  • batchSize - (Optional) Specifies the maximum size of log events in a batch, in bytes, up to 1048576 bytes. The default value is 32768 bytes.
  • bufferDuration - (Optional) Specifies the time duration for the batching of log events. The minimum value is 5000 and default value is 5000.
  • datetimeFormat - (Optional) Specifies how the timestamp is extracted from logs. For more information, see the CloudWatch Logs Agent Reference (https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AgentReference.html).
  • encoding - (Optional) Specifies the encoding of the log file so that the file can be read correctly. The default is utf8.
  • fileFingerprintLines - (Optional) Specifies the range of lines for identifying a file. The valid values are one number, or two dash-delimited numbers, such as 1, 25. The default value is 1.
  • initialPosition - (Optional) Specifies where to start to read data (startOfFile or endOfFile). The default is startOfFile.
  • multilineStartPattern - (Optional) Specifies the pattern for identifying the start of a log message.
  • timeZone - (Optional) Specifies the time zone of log event time stamps.

Load Based Autoscaling

  • downscaling - (Optional) The downscaling settings, as defined below, used for load-based autoscaling
  • enable - (Optional) Whether load-based auto scaling is enabled for the layer.
  • upscaling - (Optional) The upscaling settings, as defined below, used for load-based autoscaling

The downscaling and upscaling blocks supports the following arguments:

Though the three thresholds are optional, at least one threshold must be set when using load-based autoscaling.

  • alarms - (Optional) Custom Cloudwatch auto scaling alarms, to be used as thresholds. This parameter takes a list of up to five alarm names, which are case sensitive and must be in the same region as the stack.
  • cpuThreshold - (Optional) The CPU utilization threshold, as a percent of the available CPU. A value of -1 disables the threshold.
  • ignoreMetricsTime - (Optional) The amount of time (in minutes) after a scaling event occurs that AWS OpsWorks Stacks should ignore metrics and suppress additional scaling events.
  • instanceCount - (Optional) The number of instances to add or remove when the load exceeds a threshold.
  • loadThreshold - (Optional) The load threshold. A value of -1 disables the threshold.
  • memoryThreshold - (Optional) The memory utilization threshold, as a percent of the available memory. A value of -1 disables the threshold.
  • thresholdsWaitTime - (Optional) The amount of time, in minutes, that the load must exceed a threshold before more instances are added or removed.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - The id of the layer.
  • arn - The Amazon Resource Name(ARN) of the layer.
  • tagsAll - A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.

Import

OpsWorks Custom Layers can be imported using the id, e.g.,

$ terraform import aws_opsworks_custom_layer.bar 00000000-0000-0000-0000-000000000000