class CfnLayer (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.OpsWorks.CfnLayer |
![]() | software.amazon.awscdk.services.opsworks.CfnLayer |
![]() | aws_cdk.aws_opsworks.CfnLayer |
![]() | @aws-cdk/aws-opsworks » CfnLayer |
Implements
IConstruct
, 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 * as opsworks from '@aws-cdk/aws-opsworks';
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
Cfn
— - resource properties.Layer Props
Create a new AWS::OpsWorks::Layer
.
Construct Props
Name | Type | Description |
---|---|---|
auto | boolean | IResolvable | Whether to automatically assign an Elastic IP address to the layer's instances. For more information, see How to Edit a Layer . |
auto | boolean | IResolvable | For stacks that are running in a VPC, whether to automatically assign a public IP address to the layer's instances. |
enable | boolean | IResolvable | Whether to disable auto healing for the layer. |
name | string | The layer name, which is used by the console. |
shortname | 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. |
stack | string | The layer stack ID. |
type | string | The layer type. |
attributes? | IResolvable | { [string]: string } | One or more user-defined key-value pairs to be added to the stack attributes. |
custom | string | The ARN of an IAM profile to be used for the layer's EC2 instances. |
custom | any | A JSON-formatted string containing custom stack configuration and deployment attributes to be installed on the layer's instances. |
custom | IResolvable | Recipes | A LayerCustomRecipes object that specifies the layer custom recipes. |
custom | string[] | An array containing the layer custom security group IDs. |
install | boolean | IResolvable | Whether to install operating system and package updates when the instance boots. |
lifecycle | IResolvable | Lifecycle | 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. |
load | IResolvable | Load | The load-based scaling configuration for the AWS OpsWorks layer. |
packages? | string[] | An array of Package objects that describes the layer packages. |
tags? | Cfn [] | Specifies one or more sets of tags (key–value pairs) to associate with this AWS OpsWorks layer. |
use | boolean | IResolvable | Whether to use Amazon EBS-optimized instances. |
volume | IResolvable | IResolvable | Volume [] | 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
|
Recipes
(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
|
Lifecycle
(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
|
Load
(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:
Cfn
[]
(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
|
Volume
[]
(optional)
A VolumeConfigurations
object that describes the layer's Amazon EBS volumes.
Properties
Name | Type | Description |
---|---|---|
auto | boolean | IResolvable | Whether to automatically assign an Elastic IP address to the layer's instances. For more information, see How to Edit a Layer . |
auto | boolean | IResolvable | For stacks that are running in a VPC, whether to automatically assign a public IP address to the layer's instances. |
cfn | ICfn | Options for this resource, such as condition, update policy etc. |
cfn | { [string]: any } | |
cfn | string | AWS resource type. |
creation | string[] | |
custom | any | A JSON-formatted string containing custom stack configuration and deployment attributes to be installed on the layer's instances. |
enable | boolean | IResolvable | Whether to disable auto healing for the layer. |
logical | string | The logical ID for this CloudFormation stack element. |
name | string | The layer name, which is used by the console. |
node | Construct | The construct tree node associated with this construct. |
ref | string | Return a string that will be resolved to a CloudFormation { Ref } for this element. |
shortname | 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. |
stack | Stack | The stack in which this element is defined. |
stack | string | The layer stack ID. |
tags | Tag | Specifies one or more sets of tags (key–value pairs) to associate with this AWS OpsWorks layer. |
type | string | The layer type. |
attributes? | IResolvable | { [string]: string } | One or more user-defined key-value pairs to be added to the stack attributes. |
custom | string | The ARN of an IAM profile to be used for the layer's EC2 instances. |
custom | IResolvable | Recipes | A LayerCustomRecipes object that specifies the layer custom recipes. |
custom | string[] | An array containing the layer custom security group IDs. |
install | boolean | IResolvable | Whether to install operating system and package updates when the instance boots. |
lifecycle | IResolvable | Lifecycle | 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. |
load | IResolvable | Load | The load-based scaling configuration for the AWS OpsWorks layer. |
packages? | string[] | An array of Package objects that describes the layer packages. |
use | boolean | IResolvable | Whether to use Amazon EBS-optimized instances. |
volume | IResolvable | IResolvable | Volume [] | A VolumeConfigurations object that describes the layer's Amazon EBS volumes. |
static CFN_RESOURCE_TYPE_NAME | string | The 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:
ICfn
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:
Construct
The construct tree node associated with this construct.
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:
Tag
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
|
Recipes
(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
|
Lifecycle
(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
|
Load
(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
|
Volume
[]
(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
Name | Description |
---|---|
add | Syntactic sugar for addOverride(path, undefined) . |
add | Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned. |
add | Add a value to the CloudFormation Resource Metadata. |
add | Adds an override to the synthesized CloudFormation resource. |
add | Adds an override that deletes the value of a property from the resource definition. |
add | Adds an override to a resource property. |
apply | Sets the deletion policy of the resource based on the removal policy specified. |
get | Returns a token for an runtime attribute of this resource. |
get | Retrieve a value value from the CloudFormation Resource Metadata. |
inspect(inspector) | Examines the CloudFormation resource and discloses attributes. |
override | Overrides the auto-generated logical ID with a specific ID. |
to | Returns a string representation of this construct. |
protected render |
addDeletionOverride(path)
public addDeletionOverride(path: string): void
Parameters
- path
string
— The path of the value to delete.
Syntactic sugar for addOverride(path, undefined)
.
addDependsOn(target)
public addDependsOn(target: CfnResource): void
Parameters
- target
Cfn
Resource
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.
addMetadata(key, value)
public addMetadata(key: string, value: any): void
Parameters
- key
string
- value
any
Add a value to the CloudFormation Resource Metadata.
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
Removal
Policy - options
Removal
Policy Options
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
).
getAtt(attributeName)
public getAtt(attributeName: string): Reference
Parameters
- attributeName
string
— The name of the attribute.
Returns
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.
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
Tree
— - tree inspector to collect and process attributes.Inspector
Examines the CloudFormation resource and discloses attributes.
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.
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 }