# CfnStack

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-opsworks-stack.html.

Extends: [Construct](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.Construct.html) › [CfnElement](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.CfnElement.html) › [CfnRefElement](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.CfnRefElement.html) › [CfnResource](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.CfnResource.html) › CfnStack
Implements: [IInspectable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IInspectable.html), [ITaggable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.ITaggable.html), [IEnvironmentAware](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.IEnvironmentAware.html), [IStackRef](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_opsworks.IStackRef.html), [IConstruct](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.IConstruct.html), IDependable

- CloudFormation: [`AWS::OpsWorks::Stack`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-opsworks-stack.html)
- Source: Generated at build time
- Type last changed: v2.264.0 · 10 Aug 2026

## Example

TypeScript:

```ts
// 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 cfnStack = new opsworks.CfnStack(this, 'MyCfnStack', {
  defaultInstanceProfileArn: 'defaultInstanceProfileArn',
  name: 'name',
  serviceRoleArn: 'serviceRoleArn',

  // the properties below are optional
  agentVersion: 'agentVersion',
  attributes: {
    attributesKey: 'attributes',
  },
  chefConfiguration: {
    berkshelfVersion: 'berkshelfVersion',
    manageBerkshelf: false,
  },
  cloneAppIds: ['cloneAppIds'],
  clonePermissions: false,
  configurationManager: {
    name: 'name',
    version: 'version',
  },
  customCookbooksSource: {
    password: 'password',
    revision: 'revision',
    sshKey: 'sshKey',
    type: 'type',
    url: 'url',
    username: 'username',
  },
  customJson: customJson,
  defaultAvailabilityZone: 'defaultAvailabilityZone',
  defaultOs: 'defaultOs',
  defaultRootDeviceType: 'defaultRootDeviceType',
  defaultSshKeyName: 'defaultSshKeyName',
  defaultSubnetId: 'defaultSubnetId',
  ecsClusterArn: 'ecsClusterArn',
  elasticIps: [{
    ip: 'ip',

    // the properties below are optional
    name: 'name',
  }],
  hostnameTheme: 'hostnameTheme',
  rdsDbInstances: [{
    dbPassword: 'dbPassword',
    dbUser: 'dbUser',
    rdsDbInstanceArn: 'rdsDbInstanceArn',
  }],
  sourceStackId: 'sourceStackId',
  tags: [{
    key: 'key',
    value: 'value',
  }],
  useCustomCookbooks: false,
  useOpsworksSecurityGroups: false,
  vpcId: 'vpcId',
});
```

Python:

```python
from aws_cdk import CfnTag
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_opsworks as opsworks

# custom_json: Any

cfn_stack = opsworks.CfnStack(self, "MyCfnStack",
    default_instance_profile_arn="defaultInstanceProfileArn",
    name="name",
    service_role_arn="serviceRoleArn",

    # the properties below are optional
    agent_version="agentVersion",
    attributes={
        "attributes_key": "attributes"
    },
    chef_configuration=opsworks.CfnStack.ChefConfigurationProperty(
        berkshelf_version="berkshelfVersion",
        manage_berkshelf=False
    ),
    clone_app_ids=["cloneAppIds"],
    clone_permissions=False,
    configuration_manager=opsworks.CfnStack.StackConfigurationManagerProperty(
        name="name",
        version="version"
    ),
    custom_cookbooks_source=opsworks.CfnStack.SourceProperty(
        password="password",
        revision="revision",
        ssh_key="sshKey",
        type="type",
        url="url",
        username="username"
    ),
    custom_json=custom_json,
    default_availability_zone="defaultAvailabilityZone",
    default_os="defaultOs",
    default_root_device_type="defaultRootDeviceType",
    default_ssh_key_name="defaultSshKeyName",
    default_subnet_id="defaultSubnetId",
    ecs_cluster_arn="ecsClusterArn",
    elastic_ips=[opsworks.CfnStack.ElasticIpProperty(
        ip="ip",

        # the properties below are optional
        name="name"
    )],
    hostname_theme="hostnameTheme",
    rds_db_instances=[opsworks.CfnStack.RdsDbInstanceProperty(
        db_password="dbPassword",
        db_user="dbUser",
        rds_db_instance_arn="rdsDbInstanceArn"
    )],
    source_stack_id="sourceStackId",
    tags=[CfnTag(
        key="key",
        value="value"
    )],
    use_custom_cookbooks=False,
    use_opsworks_security_groups=False,
    vpc_id="vpcId"
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.opsworks.*;

Object customJson;

CfnStack cfnStack = CfnStack.Builder.create(this, "MyCfnStack")
        .defaultInstanceProfileArn("defaultInstanceProfileArn")
        .name("name")
        .serviceRoleArn("serviceRoleArn")

        // the properties below are optional
        .agentVersion("agentVersion")
        .attributes(Map.of(
                "attributesKey", "attributes"))
        .chefConfiguration(ChefConfigurationProperty.builder()
                .berkshelfVersion("berkshelfVersion")
                .manageBerkshelf(false)
                .build())
        .cloneAppIds(List.of("cloneAppIds"))
        .clonePermissions(false)
        .configurationManager(StackConfigurationManagerProperty.builder()
                .name("name")
                .version("version")
                .build())
        .customCookbooksSource(SourceProperty.builder()
                .password("password")
                .revision("revision")
                .sshKey("sshKey")
                .type("type")
                .url("url")
                .username("username")
                .build())
        .customJson(customJson)
        .defaultAvailabilityZone("defaultAvailabilityZone")
        .defaultOs("defaultOs")
        .defaultRootDeviceType("defaultRootDeviceType")
        .defaultSshKeyName("defaultSshKeyName")
        .defaultSubnetId("defaultSubnetId")
        .ecsClusterArn("ecsClusterArn")
        .elasticIps(List.of(ElasticIpProperty.builder()
                .ip("ip")

                // the properties below are optional
                .name("name")
                .build()))
        .hostnameTheme("hostnameTheme")
        .rdsDbInstances(List.of(RdsDbInstanceProperty.builder()
                .dbPassword("dbPassword")
                .dbUser("dbUser")
                .rdsDbInstanceArn("rdsDbInstanceArn")
                .build()))
        .sourceStackId("sourceStackId")
        .tags(List.of(CfnTag.builder()
                .key("key")
                .value("value")
                .build()))
        .useCustomCookbooks(false)
        .useOpsworksSecurityGroups(false)
        .vpcId("vpcId")
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.OpsWorks;

var customJson;

var cfnStack = new CfnStack(this, "MyCfnStack", new CfnStackProps {
    DefaultInstanceProfileArn = "defaultInstanceProfileArn",
    Name = "name",
    ServiceRoleArn = "serviceRoleArn",

    // the properties below are optional
    AgentVersion = "agentVersion",
    Attributes = new Dictionary<string, string> {
        { "attributesKey", "attributes" }
    },
    ChefConfiguration = new ChefConfigurationProperty {
        BerkshelfVersion = "berkshelfVersion",
        ManageBerkshelf = false
    },
    CloneAppIds = new [] { "cloneAppIds" },
    ClonePermissions = false,
    ConfigurationManager = new StackConfigurationManagerProperty {
        Name = "name",
        Version = "version"
    },
    CustomCookbooksSource = new SourceProperty {
        Password = "password",
        Revision = "revision",
        SshKey = "sshKey",
        Type = "type",
        Url = "url",
        Username = "username"
    },
    CustomJson = customJson,
    DefaultAvailabilityZone = "defaultAvailabilityZone",
    DefaultOs = "defaultOs",
    DefaultRootDeviceType = "defaultRootDeviceType",
    DefaultSshKeyName = "defaultSshKeyName",
    DefaultSubnetId = "defaultSubnetId",
    EcsClusterArn = "ecsClusterArn",
    ElasticIps = new [] { new ElasticIpProperty {
        Ip = "ip",

        // the properties below are optional
        Name = "name"
    } },
    HostnameTheme = "hostnameTheme",
    RdsDbInstances = new [] { new RdsDbInstanceProperty {
        DbPassword = "dbPassword",
        DbUser = "dbUser",
        RdsDbInstanceArn = "rdsDbInstanceArn"
    } },
    SourceStackId = "sourceStackId",
    Tags = new [] { new CfnTag {
        Key = "key",
        Value = "value"
    } },
    UseCustomCookbooks = false,
    UseOpsworksSecurityGroups = false,
    VpcId = "vpcId"
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

var customJson interface{}

cfnStack := awscdk.Aws_opsworks.NewCfnStack(this, jsii.String("MyCfnStack"), &CfnStackProps{
	DefaultInstanceProfileArn: jsii.String("defaultInstanceProfileArn"),
	Name: jsii.String("name"),
	ServiceRoleArn: jsii.String("serviceRoleArn"),

	// the properties below are optional
	AgentVersion: jsii.String("agentVersion"),
	Attributes: map[string]*string{
		"attributesKey": jsii.String("attributes"),
	},
	ChefConfiguration: &ChefConfigurationProperty{
		BerkshelfVersion: jsii.String("berkshelfVersion"),
		ManageBerkshelf: jsii.Boolean(false),
	},
	CloneAppIds: []*string{
		jsii.String("cloneAppIds"),
	},
	ClonePermissions: jsii.Boolean(false),
	ConfigurationManager: &StackConfigurationManagerProperty{
		Name: jsii.String("name"),
		Version: jsii.String("version"),
	},
	CustomCookbooksSource: &SourceProperty{
		Password: jsii.String("password"),
		Revision: jsii.String("revision"),
		SshKey: jsii.String("sshKey"),
		Type: jsii.String("type"),
		Url: jsii.String("url"),
		Username: jsii.String("username"),
	},
	CustomJson: customJson,
	DefaultAvailabilityZone: jsii.String("defaultAvailabilityZone"),
	DefaultOs: jsii.String("defaultOs"),
	DefaultRootDeviceType: jsii.String("defaultRootDeviceType"),
	DefaultSshKeyName: jsii.String("defaultSshKeyName"),
	DefaultSubnetId: jsii.String("defaultSubnetId"),
	EcsClusterArn: jsii.String("ecsClusterArn"),
	ElasticIps: []interface{}{
		&ElasticIpProperty{
			Ip: jsii.String("ip"),

			// the properties below are optional
			Name: jsii.String("name"),
		},
	},
	HostnameTheme: jsii.String("hostnameTheme"),
	RdsDbInstances: []interface{}{
		&RdsDbInstanceProperty{
			DbPassword: jsii.String("dbPassword"),
			DbUser: jsii.String("dbUser"),
			RdsDbInstanceArn: jsii.String("rdsDbInstanceArn"),
		},
	},
	SourceStackId: jsii.String("sourceStackId"),
	Tags: []CfnTag{
		&CfnTag{
			Key: jsii.String("key"),
			Value: jsii.String("value"),
		},
	},
	UseCustomCookbooks: jsii.Boolean(false),
	UseOpsworksSecurityGroups: jsii.Boolean(false),
	VpcId: jsii.String("vpcId"),
})
```

## Initializer

TypeScript:

```ts
new CfnStack(scope: Construct, id: string, props: CfnStackProps)
```

Python:

```python
CfnStack(scope: Construct, id: str, props: CfnStackProps)
```

Java:

```java
new CfnStack(Construct scope, String id, CfnStackProps props)
```

C# / .NET:

```csharp
new CfnStack(Construct scope, string id, CfnStackProps props)
```

Golang:

```go
NewCfnStack(Scope Construct, Id *string, Props CfnStackProps)
```

## Construct Props

- `agentVersion`: string — The default OpsWorks Stacks agent version. You have the following options:.

  - Auto-update - Set this parameter to `LATEST` . OpsWorks Stacks automatically installs new agent versions on the stack's instances as soon as they are available.
  - Fixed version - Set this parameter to your preferred agent version. To update the agent version, you must edit the stack configuration and specify a new version. OpsWorks Stacks installs that version on the stack's instances.

  The default setting is the most recent release of the agent. To specify an agent version, you must use the complete version number, not the abbreviated number shown on the console. For a list of available agent version numbers, call `DescribeAgentVersions` . AgentVersion cannot be set to Chef 12.2.

  > You can also specify an agent version when you create or update an instance, which overrides the stack's default setting.

- `attributes`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | { [key: string]: string } — One or more user-defined key-value pairs to be added to the stack attributes.

- `chefConfiguration`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnStack.ChefConfigurationProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_opsworks.CfnStack.ChefConfigurationProperty.html) — A `ChefConfiguration` object that specifies whether to enable Berkshelf and the Berkshelf version on Chef 11.10 stacks. For more information, see [Create a New Stack](https://docs.aws.amazon.com/opsworks/latest/userguide/workingstacks-creating.html) .

- `cloneAppIds`: string[] — If you're cloning an OpsWorks stack, a list of OpsWorks application stack IDs from the source stack to include in the cloned stack.

- `clonePermissions`: boolean | [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) — If you're cloning an OpsWorks stack, indicates whether to clone the source stack's permissions.

- `configurationManager`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnStack.StackConfigurationManagerProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_opsworks.CfnStack.StackConfigurationManagerProperty.html) — The configuration manager.

  When you create a stack we recommend that you use the configuration manager to specify the Chef version: 12, 11.10, or 11.4 for Linux stacks, or 12.2 for Windows stacks. The default value for Linux stacks is currently 12.

- `customCookbooksSource`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnStack.SourceProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_opsworks.CfnStack.SourceProperty.html) — Contains the information required to retrieve an app or cookbook from a repository.

  For more information, see [Adding Apps](https://docs.aws.amazon.com/opsworks/latest/userguide/workingapps-creating.html) or [Cookbooks and Recipes](https://docs.aws.amazon.com/opsworks/latest/userguide/workingcookbook.html) .

- `customJson`: any — A string that contains user-defined, custom JSON.

  It can be used to override the corresponding default stack configuration attribute values or to pass data to recipes. The string should be in the following format:

  `"{\"key1\": \"value1\", \"key2\": \"value2\",...}"`

  For more information about custom JSON, see [Use Custom JSON to Modify the Stack Configuration Attributes](https://docs.aws.amazon.com/opsworks/latest/userguide/workingstacks-json.html) .

- `defaultAvailabilityZone`: string — The stack's default Availability Zone, which must be in the specified region.

  For more information, see [Regions and Endpoints](https://docs.aws.amazon.com/general/latest/gr/rande.html) . If you also specify a value for `DefaultSubnetId` , the subnet must be in the same zone. For more information, see the `VpcId` parameter description.

- `defaultInstanceProfileArn`: string (required) — The Amazon Resource Name (ARN) of an IAM profile that is the default profile for all of the stack's EC2 instances.

  For more information about IAM ARNs, see [Using Identifiers](https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html) .

- `defaultOs`: string — The stack's default operating system, which is installed on every instance unless you specify a different operating system when you create the instance.

  You can specify one of the following.

  - A supported Linux operating system: An Amazon Linux version, such as `Amazon Linux 2` , `Amazon Linux 2018.03` , `Amazon Linux 2017.09` , `Amazon Linux 2017.03` , `Amazon Linux 2016.09` , `Amazon Linux 2016.03` , `Amazon Linux 2015.09` , or `Amazon Linux 2015.03` .
  - A supported Ubuntu operating system, such as `Ubuntu 18.04 LTS` , `Ubuntu 16.04 LTS` , `Ubuntu 14.04 LTS` , or `Ubuntu 12.04 LTS` .
  - `CentOS Linux 7`
  - `Red Hat Enterprise Linux 7`
  - A supported Windows operating system, such as `Microsoft Windows Server 2012 R2 Base` , `Microsoft Windows Server 2012 R2 with SQL Server Express` , `Microsoft Windows Server 2012 R2 with SQL Server Standard` , or `Microsoft Windows Server 2012 R2 with SQL Server Web` .
  - A custom AMI: `Custom` . You specify the custom AMI you want to use when you create instances. For more information, see [Using Custom AMIs](https://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-custom-ami.html) .

  The default option is the current Amazon Linux version. Not all operating systems are supported with all versions of Chef. For more information about supported operating systems, see [OpsWorks Stacks Operating Systems](https://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-os.html) .

- `defaultRootDeviceType`: string — The default root device type.

  This value is the default for all instances in the stack, but you can override it when you create an instance. The default option is `instance-store` . For more information, see [Storage for the Root Device](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ComponentsAMIs.html#storage-for-the-root-device) .

- `defaultSshKeyName`: string — A default Amazon EC2 key pair name.

  The default value is none. If you specify a key pair name, OpsWorks installs the public key on the instance and you can use the private key with an SSH client to log in to the instance. For more information, see [Using SSH to Communicate with an Instance](https://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-ssh.html) and [Managing SSH Access](https://docs.aws.amazon.com/opsworks/latest/userguide/security-ssh-access.html) . You can override this setting by specifying a different key pair, or no key pair, when you [create an instance](https://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-add.html) .

- `defaultSubnetId`: string — The stack's default subnet ID.

  All instances are launched into this subnet unless you specify another subnet ID when you create the instance. This parameter is required if you specify a value for the `VpcId` parameter. If you also specify a value for `DefaultAvailabilityZone` , the subnet must be in that zone.

- `ecsClusterArn`: string — The Amazon Resource Name (ARN) of the ( Amazon ECS ) cluster to register with the OpsWorks stack.

  > If you specify a cluster that's registered with another OpsWorks stack, CloudFormation deregisters the existing association before registering the cluster.

- `elasticIps`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnStack.ElasticIpProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_opsworks.CfnStack.ElasticIpProperty.html)[] — A list of Elastic IP addresses to register with the OpsWorks stack.

  > If you specify an IP address that's registered with another OpsWorks stack, CloudFormation deregisters the existing association before registering the IP address.

- `hostnameTheme`: string — The stack's host name theme, with spaces replaced by underscores.

  The theme is used to generate host names for the stack's instances. By default, `HostnameTheme` is set to `Layer_Dependent` , which creates host names by appending integers to the layer's short name. The other themes are:

  - `Baked_Goods`
  - `Clouds`
  - `Europe_Cities`
  - `Fruits`
  - `Greek_Deities_and_Titans`
  - `Legendary_creatures_from_Japan`
  - `Planets_and_Moons`
  - `Roman_Deities`
  - `Scottish_Islands`
  - `US_Cities`
  - `Wild_Cats`

  To obtain a generated host name, call `GetHostNameSuggestion` , which returns a host name based on the current theme.

- `name`: string (required) — The stack name.

  Stack names can be a maximum of 64 characters.

- `rdsDbInstances`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnStack.RdsDbInstanceProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_opsworks.CfnStack.RdsDbInstanceProperty.html)[] — The Amazon Relational Database Service ( Amazon RDS ) database instance to register with the OpsWorks stack.

  > If you specify a database instance that's registered with another OpsWorks stack, CloudFormation deregisters the existing association before registering the database instance.

- `serviceRoleArn`: string (required) — The stack's IAM role, which allows OpsWorks Stacks to work with AWS resources on your behalf.

  You must set this parameter to the Amazon Resource Name (ARN) for an existing IAM role. For more information about IAM ARNs, see [Using Identifiers](https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html) .

- `sourceStackId`: string — If you're cloning an OpsWorks stack, the stack ID of the source OpsWorks stack to clone.

- `tags`: [CfnTag](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.CfnTag.html)[] — A map that contains tag keys and tag values that are attached to a stack or layer.

  - The key cannot be empty.
  - The key can be a maximum of 127 characters, and can contain only Unicode letters, numbers, or separators, or the following special characters: `+ - = . _ : /`
  - The value can be a maximum 255 characters, and contain only Unicode letters, numbers, or separators, or the following special characters: `+ - = . _ : /`
  - Leading and trailing white spaces are trimmed from both the key and value.
  - A maximum of 40 tags is allowed for any resource.

- `useCustomCookbooks`: boolean | [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) — Whether the stack uses custom cookbooks.

- `useOpsworksSecurityGroups`: boolean | [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) — Whether to associate the OpsWorks Stacks built-in security groups with the stack's layers.

  OpsWorks Stacks provides a standard set of built-in security groups, one for each layer, which are associated with layers by default. With `UseOpsworksSecurityGroups` you can instead provide your own custom security groups. `UseOpsworksSecurityGroups` has the following settings:

  - True - OpsWorks Stacks automatically associates the appropriate built-in security group with each layer (default setting). You can associate additional security groups with a layer after you create it, but you cannot delete the built-in security group.
  - False - OpsWorks Stacks does not associate built-in security groups with layers. You must create appropriate EC2 security groups and associate a security group with each layer that you create. However, you can still manually associate a built-in security group with a layer on creation; custom security groups are required only for those layers that need custom settings.

  For more information, see [Create a New Stack](https://docs.aws.amazon.com/opsworks/latest/userguide/workingstacks-creating.html) .

- `vpcId`: string — The ID of the VPC that the stack is to be launched into.

  The VPC must be in the stack's region. All instances are launched into this VPC. You cannot change the ID later.

  - If your account supports EC2-Classic, the default value is `no VPC` .
  - If your account does not support EC2-Classic, the default value is the default VPC for the specified region.

  If the VPC ID corresponds to a default VPC and you have specified either the `DefaultAvailabilityZone` or the `DefaultSubnetId` parameter only, OpsWorks Stacks infers the value of the other parameter. If you specify neither parameter, OpsWorks Stacks sets these parameters to the first valid Availability Zone for the specified region and the corresponding default VPC subnet ID, respectively.

  If you specify a nondefault VPC ID, note the following:

  - It must belong to a VPC in your account that is in the specified region.
  - You must specify a value for `DefaultSubnetId` .

  For more information about how to use OpsWorks Stacks with a VPC, see [Running a Stack in a VPC](https://docs.aws.amazon.com/opsworks/latest/userguide/workingstacks-vpc.html) . For more information about default VPC and EC2-Classic, see [Supported Platforms](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-supported-platforms.html) .

## Properties

- `agentVersion`: string — The default OpsWorks Stacks agent version.

  You have the following options:.

- `attributes`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | { [key: string]: string } — One or more user-defined key-value pairs to be added to the stack attributes.

- `CFN_RESOURCE_TYPE_NAME`: string (static) — The CloudFormation resource type name for this resource class.

- `cfnOptions`: [ICfnResourceOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.ICfnResourceOptions.html) — Options for this resource, such as condition, update policy etc.

- `cfnResourceType`: string — AWS resource type.

- `chefConfiguration`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnStack.ChefConfigurationProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_opsworks.CfnStack.ChefConfigurationProperty.html) — A `ChefConfiguration` object that specifies whether to enable Berkshelf and the Berkshelf version on Chef 11.10 stacks. For more information, see [Create a New Stack](https://docs.aws.amazon.com/opsworks/latest/userguide/workingstacks-creating.html) .

- `cloneAppIds`: string[] — If you're cloning an OpsWorks stack, a list of OpsWorks application stack IDs from the source stack to include in the cloned stack.

- `clonePermissions`: boolean | [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) — If you're cloning an OpsWorks stack, indicates whether to clone the source stack's permissions.

- `configurationManager`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnStack.StackConfigurationManagerProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_opsworks.CfnStack.StackConfigurationManagerProperty.html) — The configuration manager.

- `creationStack`: string[]

- `customCookbooksSource`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnStack.SourceProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_opsworks.CfnStack.SourceProperty.html) — Contains the information required to retrieve an app or cookbook from a repository.

- `customJson`: any — A string that contains user-defined, custom JSON.

- `defaultAvailabilityZone`: string — The stack's default Availability Zone, which must be in the specified region.

- `defaultInstanceProfileArn`: string — The Amazon Resource Name (ARN) of an IAM profile that is the default profile for all of the stack's EC2 instances.

- `defaultOs`: string — The stack's default operating system, which is installed on every instance unless you specify a different operating system when you create the instance.

- `defaultRootDeviceType`: string — The default root device type.

- `defaultSshKeyName`: string — A default Amazon EC2 key pair name.

- `defaultSubnetId`: string — The stack's default subnet ID.

- `ecsClusterArn`: string — The Amazon Resource Name (ARN) of the ( Amazon ECS ) cluster to register with the OpsWorks stack.

- `elasticIps`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnStack.ElasticIpProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_opsworks.CfnStack.ElasticIpProperty.html)[] — A list of Elastic IP addresses to register with the OpsWorks stack.

- `env`: [ResourceEnvironment](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html)

- `hostnameTheme`: string — The stack's host name theme, with spaces replaced by underscores.

- `logicalId`: 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`: string — The stack name.

- `node`: [Node](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.Node.html) — The tree node.

- `rdsDbInstances`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnStack.RdsDbInstanceProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_opsworks.CfnStack.RdsDbInstanceProperty.html)[] — The Amazon Relational Database Service ( Amazon RDS ) database instance to register with the OpsWorks stack.

- `ref`: 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 })`.

- `serviceRoleArn`: string — The stack's IAM role, which allows OpsWorks Stacks to work with AWS resources on your behalf.

- `sourceStackId`: string — If you're cloning an OpsWorks stack, the stack ID of the source OpsWorks stack to clone.

- `stack`: [Stack](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Stack.html) — The stack in which this element is defined.

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

- `stackRef`: [StackReference](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_opsworks.StackReference.html) — A reference to a Stack resource.

- `tags`: [TagManager](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.TagManager.html) — Tag Manager which manages the tags for this resource.

- `tagsRaw`: [CfnTag](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.CfnTag.html)[] — A map that contains tag keys and tag values that are attached to a stack or layer.

- `useCustomCookbooks`: boolean | [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) — Whether the stack uses custom cookbooks.

- `useOpsworksSecurityGroups`: boolean | [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) — Whether to associate the OpsWorks Stacks built-in security groups with the stack's layers.

- `vpcId`: string — The ID of the VPC that the stack is to be launched into.

## Methods

- `addDeletionOverride(path: string): void` — Syntactic sugar for `addOverride(path, undefined)`.

  **Parameters**

  - `path` — The path of the value to delete.

- `addDependency(target: CfnResource): void` — Use `addResourceDependency` instead.

  This method has been renamed to `addResourceDependency` to more clearly
  set it apart from `construct.node.addDependency`. See the documentation
  of that function for more details.

- `addDependsOn(target: CfnResource): void` — Use `addResourceDependency` instead.

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

  This method has been renamed to `addResourceDependency`, which makes it
  more clear that this method operates at a different level from the
  construct-level `construct.node.addDependency()` mechanism.

- `addMetadata(key: string, value: any): void` — Add a value to the CloudFormation Resource Metadata.

- `addOverride(path: string, value: any): void` — 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,
  ```typescript
  cfnResource.addOverride('Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes', ['myattribute']);
  cfnResource.addOverride('Properties.GlobalSecondaryIndexes.1.ProjectionType', 'INCLUDE');
  ```
  would add the overrides
  ```json
  "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.

  **Parameters**

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

- `addPropertyDeletionOverride(propertyPath: string): void` — Adds an override that deletes the value of a property from the resource definition.

  **Parameters**

  - `propertyPath` — The path to the property.

- `addPropertyOverride(propertyPath: string, value: any): void` — Adds an override to a resource property.

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

  **Parameters**

  - `propertyPath` — The path of the property.
  - `value` — The value.

- `addResourceDependency(target: CfnResource, reason?: string): void` — 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.

  This method only adds dependencies between L1 resources. If you are
  looking for a generic construct-to-construct dependency mechanism that works
  for all constructs including L2s, use `construct.node.addDependency` instead.

- `applyCrossStackReferenceStrength(strength: ReferenceStrength): void` — Sets the cross-stack reference strength for this resource.

  When set, any cross-stack reference to this resource will use the specified
  strength instead of the global default from the consuming stack's context.

  **Parameters**

  - `strength` — - The reference strength to use for this resource.

- `applyRemovalPolicy(policy?: RemovalPolicy, options?: RemovalPolicyOptions): void` — 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:

- `cfnPropertyName(cdkPropertyName: string): string`

- `getAtt(attributeName: string, typeHint?: ResolutionTypeHint): 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.

  **Parameters**

  - `attributeName` — The name of the attribute.

- `getMetadata(key: string): any` — Retrieve a value value from the CloudFormation Resource Metadata.

- `inspect(inspector: TreeInspector): void` — Examines the CloudFormation resource and discloses attributes.

  **Parameters**

  - `inspector` — tree inspector to collect and process attributes.

- `isCfnElement(x: any): boolean` (static) — Returns `true` if a construct is a stack element (i.e. part of the synthesized cloudformation template).

  Uses duck-typing instead of `instanceof` to allow stack elements from different
  versions of this library to be included in the same stack.

  **Returns:** The construct as a stack element or undefined if it is not a stack element.

- `isCfnResource(x: any): boolean` (static) — Check whether the given object is a CfnResource.

- `isCfnStack(x: any): boolean` (static) — Checks whether the given object is a CfnStack.

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `obtainDependencies(): Stack | CfnResource[]` — Retrieves an array of resources and stacks this resource depends on.

  For resources depended on directly, returns the `CfnResource` object. For
  dependencies on other stacks, returns the `Stack` object. The order of the
  array is not guaranteed.

- `overrideLogicalId(newLogicalId: string): void` — Overrides the auto-generated logical ID with a specific ID.

  **Parameters**

  - `newLogicalId` — The new logical ID to use for this stack element.

- `removeDependency(target: CfnResource): void` — Use `removeResourceDependency` instead

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

- `removeResourceDependency(target: CfnResource): void` — 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: CfnResource, newTarget: CfnResource): void` — Replaces one dependency with another.

  **Parameters**

  - `target` — The dependency to replace.
  - `newTarget` — The new dependency to add.

- `toString(): string` — Returns a string representation of this construct.

  **Returns:** a string representation of this resource

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.
