aws-cdk-lib.aws_opsworks.CfnLayer

class CfnLayer (construct)

LanguageType name
.NETAmazon.CDK.AWS.OpsWorks.CfnLayer
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsopsworks#CfnLayer
Javasoftware.amazon.awscdk.services.opsworks.CfnLayer
Pythonaws_cdk.aws_opsworks.CfnLayer
TypeScript aws-cdk-lib » aws_opsworks » CfnLayer

Implements IConstruct, IDependable, IInspectable

A CloudFormation AWS::OpsWorks::Layer.

Creates a layer. For more information, see How to Create a Layer .

You should use CreateLayer for noncustom layer types such as PHP App Server only if the stack does not have an existing layer of that type. A stack can have at most one instance of each noncustom layer; if you attempt to create a second instance, CreateLayer fails. A stack can have an arbitrary number of custom layers, so you can call CreateLayer as many times as you like for that layer type.

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 .

Example

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_opsworks as opsworks } from 'aws-cdk-lib';

declare const customJson: any;
const cfnLayer = new opsworks.CfnLayer(this, 'MyCfnLayer', {
  autoAssignElasticIps: false,
  autoAssignPublicIps: false,
  enableAutoHealing: false,
  name: 'name',
  shortname: 'shortname',
  stackId: 'stackId',
  type: 'type',

  // the properties below are optional
  attributes: {
    attributesKey: 'attributes',
  },
  customInstanceProfileArn: 'customInstanceProfileArn',
  customJson: customJson,
  customRecipes: {
    configure: ['configure'],
    deploy: ['deploy'],
    setup: ['setup'],
    shutdown: ['shutdown'],
    undeploy: ['undeploy'],
  },
  customSecurityGroupIds: ['customSecurityGroupIds'],
  installUpdatesOnBoot: false,
  lifecycleEventConfiguration: {
    shutdownEventConfiguration: {
      delayUntilElbConnectionsDrained: false,
      executionTimeout: 123,
    },
  },
  loadBasedAutoScaling: {
    downScaling: {
      cpuThreshold: 123,
      ignoreMetricsTime: 123,
      instanceCount: 123,
      loadThreshold: 123,
      memoryThreshold: 123,
      thresholdsWaitTime: 123,
    },
    enable: false,
    upScaling: {
      cpuThreshold: 123,
      ignoreMetricsTime: 123,
      instanceCount: 123,
      loadThreshold: 123,
      memoryThreshold: 123,
      thresholdsWaitTime: 123,
    },
  },
  packages: ['packages'],
  tags: [{
    key: 'key',
    value: 'value',
  }],
  useEbsOptimizedInstances: false,
  volumeConfigurations: [{
    encrypted: false,
    iops: 123,
    mountPoint: 'mountPoint',
    numberOfDisks: 123,
    raidLevel: 123,
    size: 123,
    volumeType: 'volumeType',
  }],
});

Initializer

new CfnLayer(scope: Construct, id: string, props: CfnLayerProps)

Parameters

  • scope Construct — - scope in which this resource is defined.
  • id string — - scoped id of the resource.
  • props CfnLayerProps — - resource properties.

Create a new AWS::OpsWorks::Layer.

Construct Props

NameTypeDescription
autoAssignElasticIpsboolean | IResolvableWhether to automatically assign an Elastic IP address to the layer's instances. For more information, see How to Edit a Layer .
autoAssignPublicIpsboolean | IResolvableFor stacks that are running in a VPC, whether to automatically assign a public IP address to the layer's instances.
enableAutoHealingboolean | IResolvableWhether to disable auto healing for the layer.
namestringThe layer name, which is used by the console.
shortnamestringFor 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.
stackIdstringThe layer stack ID.
typestringThe layer type.
attributes?IResolvable | { [string]: string }One or more user-defined key-value pairs to be added to the stack attributes.
customInstanceProfileArn?stringThe ARN of an IAM profile to be used for the layer's EC2 instances.
customJson?anyA JSON-formatted string containing custom stack configuration and deployment attributes to be installed on the layer's instances.
customRecipes?IResolvable | RecipesPropertyA LayerCustomRecipes object that specifies the layer custom recipes.
customSecurityGroupIds?string[]An array containing the layer custom security group IDs.
installUpdatesOnBoot?boolean | IResolvableWhether to install operating system and package updates when the instance boots.
lifecycleEventConfiguration?IResolvable | LifecycleEventConfigurationPropertyA 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.
loadBasedAutoScaling?IResolvable | LoadBasedAutoScalingPropertyThe load-based scaling configuration for the AWS OpsWorks layer.
packages?string[]An array of Package objects that describes the layer packages.
tags?CfnTag[]Specifies one or more sets of tags (key–value pairs) to associate with this AWS OpsWorks layer.
useEbsOptimizedInstances?boolean | IResolvableWhether to use Amazon EBS-optimized instances.
volumeConfigurations?IResolvable | IResolvable | VolumeConfigurationProperty[]A VolumeConfigurations object that describes the layer's Amazon EBS volumes.

autoAssignElasticIps

Type: boolean | IResolvable

Whether to automatically assign an Elastic IP address to the layer's instances. For more information, see How to Edit a Layer .


autoAssignPublicIps

Type: boolean | IResolvable

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 .


enableAutoHealing

Type: boolean | IResolvable

Whether to disable auto healing for the layer.


name

Type: string

The layer name, which is used by the console.

Layer names can be a maximum of 32 characters.


shortname

Type: string

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 32 characters, which are limited to the alphanumeric characters, '-', '_', and '.'.

Built-in layer short names are defined by AWS OpsWorks Stacks. For more information, see the Layer Reference .


stackId

Type: string

The layer stack ID.


type

Type: string

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.


attributes?

Type: IResolvable | { [string]: string } (optional)

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.


customInstanceProfileArn?

Type: string (optional)

The ARN of an IAM profile to be used for the layer's EC2 instances.

For more information about IAM ARNs, see Using Identifiers .


customJson?

Type: any (optional)

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 .


customRecipes?

Type: IResolvable | RecipesProperty (optional)

A LayerCustomRecipes object that specifies the layer custom recipes.


customSecurityGroupIds?

Type: string[] (optional)

An array containing the layer custom security group IDs.


installUpdatesOnBoot?

Type: boolean | IResolvable (optional)

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.

To ensure that your instances have the latest security updates, we strongly recommend using the default value of true .


lifecycleEventConfiguration?

Type: IResolvable | LifecycleEventConfigurationProperty (optional)

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.


loadBasedAutoScaling?

Type: IResolvable | LoadBasedAutoScalingProperty (optional)

The load-based scaling configuration for the AWS OpsWorks layer.


packages?

Type: string[] (optional)

An array of Package objects that describes the layer packages.


tags?

Type: CfnTag[] (optional)

Specifies one or more sets of tags (key–value pairs) to associate with this AWS OpsWorks layer.

Use tags to manage your resources.


useEbsOptimizedInstances?

Type: boolean | IResolvable (optional)

Whether to use Amazon EBS-optimized instances.


volumeConfigurations?

Type: IResolvable | IResolvable | VolumeConfigurationProperty[] (optional)

A VolumeConfigurations object that describes the layer's Amazon EBS volumes.

Properties

NameTypeDescription
autoAssignElasticIpsboolean | IResolvableWhether to automatically assign an Elastic IP address to the layer's instances. For more information, see How to Edit a Layer .
autoAssignPublicIpsboolean | IResolvableFor stacks that are running in a VPC, whether to automatically assign a public IP address to the layer's instances.
cfnOptionsICfnResourceOptionsOptions for this resource, such as condition, update policy etc.
cfnProperties{ [string]: any }
cfnResourceTypestringAWS resource type.
creationStackstring[]
customJsonanyA JSON-formatted string containing custom stack configuration and deployment attributes to be installed on the layer's instances.
enableAutoHealingboolean | IResolvableWhether to disable auto healing for the layer.
logicalIdstringThe logical ID for this CloudFormation stack element.
namestringThe layer name, which is used by the console.
nodeNodeThe tree node.
refstringReturn a string that will be resolved to a CloudFormation { Ref } for this element.
shortnamestringFor 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.
stackStackThe stack in which this element is defined.
stackIdstringThe layer stack ID.
tagsTagManagerSpecifies one or more sets of tags (key–value pairs) to associate with this AWS OpsWorks layer.
typestringThe layer type.
attributes?IResolvable | { [string]: string }One or more user-defined key-value pairs to be added to the stack attributes.
customInstanceProfileArn?stringThe ARN of an IAM profile to be used for the layer's EC2 instances.
customRecipes?IResolvable | RecipesPropertyA LayerCustomRecipes object that specifies the layer custom recipes.
customSecurityGroupIds?string[]An array containing the layer custom security group IDs.
installUpdatesOnBoot?boolean | IResolvableWhether to install operating system and package updates when the instance boots.
lifecycleEventConfiguration?IResolvable | LifecycleEventConfigurationPropertyA 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.
loadBasedAutoScaling?IResolvable | LoadBasedAutoScalingPropertyThe load-based scaling configuration for the AWS OpsWorks layer.
packages?string[]An array of Package objects that describes the layer packages.
useEbsOptimizedInstances?boolean | IResolvableWhether to use Amazon EBS-optimized instances.
volumeConfigurations?IResolvable | IResolvable | VolumeConfigurationProperty[]A VolumeConfigurations object that describes the layer's Amazon EBS volumes.
static CFN_RESOURCE_TYPE_NAMEstringThe CloudFormation resource type name for this resource class.

autoAssignElasticIps

Type: boolean | IResolvable

Whether to automatically assign an Elastic IP address to the layer's instances. For more information, see How to Edit a Layer .


autoAssignPublicIps

Type: boolean | IResolvable

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 .


cfnOptions

Type: ICfnResourceOptions

Options for this resource, such as condition, update policy etc.


cfnProperties

Type: { [string]: any }


cfnResourceType

Type: string

AWS resource type.


creationStack

Type: string[]


customJson

Type: any

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 .


enableAutoHealing

Type: boolean | IResolvable

Whether to disable auto healing for the layer.


logicalId

Type: string

The logical ID for this CloudFormation stack element.

The logical ID of the element is calculated from the path of the resource node in the construct tree.

To override this value, use overrideLogicalId(newLogicalId).


name

Type: string

The layer name, which is used by the console.

Layer names can be a maximum of 32 characters.


node

Type: Node

The tree node.


ref

Type: string

Return a string that will be resolved to a CloudFormation { Ref } for this element.

If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through Lazy.any({ produce: resource.ref }).


shortname

Type: string

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 32 characters, which are limited to the alphanumeric characters, '-', '_', and '.'.

Built-in layer short names are defined by AWS OpsWorks Stacks. For more information, see the Layer Reference .


stack

Type: Stack

The stack in which this element is defined.

CfnElements must be defined within a stack scope (directly or indirectly).


stackId

Type: string

The layer stack ID.


tags

Type: TagManager

Specifies one or more sets of tags (key–value pairs) to associate with this AWS OpsWorks layer.

Use tags to manage your resources.


type

Type: string

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.


attributes?

Type: IResolvable | { [string]: string } (optional)

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.


customInstanceProfileArn?

Type: string (optional)

The ARN of an IAM profile to be used for the layer's EC2 instances.

For more information about IAM ARNs, see Using Identifiers .


customRecipes?

Type: IResolvable | RecipesProperty (optional)

A LayerCustomRecipes object that specifies the layer custom recipes.


customSecurityGroupIds?

Type: string[] (optional)

An array containing the layer custom security group IDs.


installUpdatesOnBoot?

Type: boolean | IResolvable (optional)

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.

To ensure that your instances have the latest security updates, we strongly recommend using the default value of true .


lifecycleEventConfiguration?

Type: IResolvable | LifecycleEventConfigurationProperty (optional)

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.


loadBasedAutoScaling?

Type: IResolvable | LoadBasedAutoScalingProperty (optional)

The load-based scaling configuration for the AWS OpsWorks layer.


packages?

Type: string[] (optional)

An array of Package objects that describes the layer packages.


useEbsOptimizedInstances?

Type: boolean | IResolvable (optional)

Whether to use Amazon EBS-optimized instances.


volumeConfigurations?

Type: IResolvable | IResolvable | VolumeConfigurationProperty[] (optional)

A VolumeConfigurations object that describes the layer's Amazon EBS volumes.


static CFN_RESOURCE_TYPE_NAME

Type: string

The CloudFormation resource type name for this resource class.

Methods

NameDescription
addDeletionOverride(path)Syntactic sugar for addOverride(path, undefined).
addDependency(target)Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
addDependsOn(target)⚠️Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
addMetadata(key, value)Add a value to the CloudFormation Resource Metadata.
addOverride(path, value)Adds an override to the synthesized CloudFormation resource.
addPropertyDeletionOverride(propertyPath)Adds an override that deletes the value of a property from the resource definition.
addPropertyOverride(propertyPath, value)Adds an override to a resource property.
applyRemovalPolicy(policy?, options?)Sets the deletion policy of the resource based on the removal policy specified.
getAtt(attributeName, typeHint?)Returns a token for an runtime attribute of this resource.
getMetadata(key)Retrieve a value value from the CloudFormation Resource Metadata.
inspect(inspector)Examines the CloudFormation resource and discloses attributes.
obtainDependencies()Retrieves an array of resources this resource depends on.
obtainResourceDependencies()Get a shallow copy of dependencies between this resource and other resources in the same stack.
overrideLogicalId(newLogicalId)Overrides the auto-generated logical ID with a specific ID.
removeDependency(target)Indicates that this resource no longer depends on another resource.
replaceDependency(target, newTarget)Replaces one dependency with another.
toString()Returns a string representation of this construct.
protected renderProperties(props)

addDeletionOverride(path)

public addDeletionOverride(path: string): void

Parameters

  • path string — The path of the value to delete.

Syntactic sugar for addOverride(path, undefined).


addDependency(target)

public addDependency(target: CfnResource): void

Parameters

  • target CfnResource

Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.

This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.


addDependsOn(target)⚠️

public addDependsOn(target: CfnResource): void

⚠️ Deprecated: use addDependency

Parameters

  • target CfnResource

Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.


addMetadata(key, value)

public addMetadata(key: string, value: any): void

Parameters

  • key string
  • value any

Add a value to the CloudFormation Resource Metadata.

See also: [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html

Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html

Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.)


addOverride(path, value)

public addOverride(path: string, value: any): void

Parameters

  • path string — - The path of the property, you can use dot notation to override values in complex types.
  • value any — - The value.

Adds an override to the synthesized CloudFormation resource.

To add a property override, either use addPropertyOverride or prefix path with "Properties." (i.e. Properties.TopicName).

If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.

To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.

For example,

cfnResource.addOverride('Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes', ['myattribute']);
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.1.ProjectionType', 'INCLUDE');

would add the overrides

"Properties": {
  "GlobalSecondaryIndexes": [
    {
      "Projection": {
        "NonKeyAttributes": [ "myattribute" ]
        ...
      }
      ...
    },
    {
      "ProjectionType": "INCLUDE"
      ...
    },
  ]
  ...
}

The value argument to addOverride will not be processed or translated in any way. Pass raw JSON values in here with the correct capitalization for CloudFormation. If you pass CDK classes or structs, they will be rendered with lowercased key names, and CloudFormation will reject the template.


addPropertyDeletionOverride(propertyPath)

public addPropertyDeletionOverride(propertyPath: string): void

Parameters

  • propertyPath string — The path to the property.

Adds an override that deletes the value of a property from the resource definition.


addPropertyOverride(propertyPath, value)

public addPropertyOverride(propertyPath: string, value: any): void

Parameters

  • propertyPath string — The path of the property.
  • value any — The value.

Adds an override to a resource property.

Syntactic sugar for addOverride("Properties.<...>", value).


applyRemovalPolicy(policy?, options?)

public applyRemovalPolicy(policy?: RemovalPolicy, options?: RemovalPolicyOptions): void

Parameters

  • policy RemovalPolicy
  • options RemovalPolicyOptions

Sets the deletion policy of the resource based on the removal policy specified.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN). In some cases, a snapshot can be taken of the resource prior to deletion (RemovalPolicy.SNAPSHOT). A list of resources that support this policy can be found in the following link:

See also: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html#aws-attribute-deletionpolicy-options


getAtt(attributeName, typeHint?)

public getAtt(attributeName: string, typeHint?: ResolutionTypeHint): Reference

Parameters

  • attributeName string — The name of the attribute.
  • typeHint ResolutionTypeHint

Returns

  • Reference

Returns a token for an runtime attribute of this resource.

Ideally, use generated attribute accessors (e.g. resource.arn), but this can be used for future compatibility in case there is no generated attribute.


getMetadata(key)

public getMetadata(key: string): any

Parameters

  • key string

Returns

  • any

Retrieve a value value from the CloudFormation Resource Metadata.

See also: [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html

Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html

Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.)


inspect(inspector)

public inspect(inspector: TreeInspector): void

Parameters

  • inspector TreeInspector — - tree inspector to collect and process attributes.

Examines the CloudFormation resource and discloses attributes.


obtainDependencies()

public obtainDependencies(): Stack &#124; CfnResource[]

Returns

  • Stack | CfnResource[]

Retrieves an array of resources this resource depends on.

This assembles dependencies on resources across stacks (including nested stacks) automatically.


obtainResourceDependencies()

public obtainResourceDependencies(): CfnResource[]

Returns

  • CfnResource[]

Get a shallow copy of dependencies between this resource and other resources in the same stack.


overrideLogicalId(newLogicalId)

public overrideLogicalId(newLogicalId: string): void

Parameters

  • newLogicalId string — The new logical ID to use for this stack element.

Overrides the auto-generated logical ID with a specific ID.


removeDependency(target)

public removeDependency(target: CfnResource): void

Parameters

  • target CfnResource

Indicates that this resource no longer depends on another resource.

This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.


replaceDependency(target, newTarget)

public replaceDependency(target: CfnResource, newTarget: CfnResource): void

Parameters

  • target CfnResource — The dependency to replace.
  • newTarget CfnResource — The new dependency to add.

Replaces one dependency with another.


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.


protected renderProperties(props)

protected renderProperties(props: { [string]: any }): { [string]: any }

Parameters

  • props { [string]: any }

Returns

  • { [string]: any }