Stack
- Implements: ITaggable
A root construct which represents a single ROS stack.
Initializers
import { Stack } from '@alicloud/ros-cdk-core'
new Stack(scope?: Construct, id?: string, props?: StackProps)
Name | Type | Description |
---|---|---|
scope |
Construct |
Parent of this stack, usually a Program instance. |
id |
string |
The construct ID of this stack. |
props |
StackProps |
Stack properties. |
scope
Optional
- Type: Construct
Parent of this stack, usually a Program instance.
id
Optional
- Type: string
The construct ID of this stack.
If stackName
is not explicitly
defined, this id (and any parent IDs) will be used to determine the
physical ID of the stack.
props
Optional
- Type: StackProps
Stack properties.
Methods
Name | Description |
---|---|
toString |
Returns a string representation of this construct. |
synthesize |
Allows this construct to emit artifacts into the cloud assembly during synthesis. |
addDependency |
Add a dependency between this stack and another stack. |
getLogicalId |
Allocates a stack-unique logical identity for a specific resource. |
renameLogicalId |
Rename a generated logical identities. |
resolve |
Resolve a tokenized value in the context of the current stack. |
toJsonString |
Convert an object, potentially containing tokens, to a JSON string. |
toString
public toString(): string
Returns a string representation of this construct.
synthesize
public synthesize(session: ISynthesisSession): void
Allows this construct to emit artifacts into the cloud assembly during synthesis.
This method is usually implemented by framework-level constructs such as Stack
and Asset
as they participate in synthesizing the cloud assembly.
- Type: ISynthesisSession
addDependency
public addDependency(target: Stack, reason?: string): void
Add a dependency between this stack and another stack.
This can be used to define dependencies between any two stacks within an app, and also supports nested stacks.
- Type: Stack
- Type: string
getLogicalId
public getLogicalId(element: RosElement): string
Allocates a stack-unique logical identity for a specific resource.
This method is called when a RosElement
is created and used to render the
initial logical identity of resources. Logical ID renames are applied at
this stage.
This method uses the protected method allocateLogicalId
to render the
logical ID for an element. To modify the naming scheme, extend the Stack
class and override this method.
- Type: RosElement
The ROS element for which a logical identity is needed.
renameLogicalId
public renameLogicalId(oldId: string, newId: string): void
Rename a generated logical identities.
To modify the naming scheme strategy, extend the Stack
class and
override the allocateLogicalId
method.
- Type: string
- Type: string
resolve
public resolve(obj: any): any
Resolve a tokenized value in the context of the current stack.
- Type: any
toJsonString
public toJsonString(obj: any, space?: number): string
Convert an object, potentially containing tokens, to a JSON string.
- Type: any
- Type: number
Static Functions
Name | Description |
---|---|
isConstruct |
Return whether the given object is a Construct. |
isStack |
Return whether the given object is a Stack. |
of |
Looks up the first stack scope in which construct is defined. |
isConstruct
import { Stack } from '@alicloud/ros-cdk-core'
Stack.isConstruct(x: any)
Return whether the given object is a Construct.
- Type: any
isStack
import { Stack } from '@alicloud/ros-cdk-core'
Stack.isStack(x: any)
Return whether the given object is a Stack.
We do attribute detection since we can't reliably use 'instanceof'.
- Type: any
of
import { Stack } from '@alicloud/ros-cdk-core'
Stack.of(construct: IConstruct)
Looks up the first stack scope in which construct
is defined.
Fails if there is no stack up the tree.
- Type: IConstruct
The construct to start the search from.
Properties
Name | Type | Description |
---|---|---|
node |
ConstructNode |
The construct tree node associated with this construct. |
account |
string |
The ALIYUN account into which this stack will be deployed. |
artifactId |
string |
The ID of the cloud assembly artifact for this stack. |
bundlingRequired |
boolean |
Indicates whether the stack requires bundling or not. |
dependencies |
Stack[] |
Return the stacks this stack depends on. |
enableResourcePropertyConstraint |
boolean |
No description. |
nested |
boolean |
Indicates if this is a nested stack, in which case parentStack will include a reference to it's parent. |
region |
string |
The ALIYUN region into which this stack will be deployed (e.g. cn-beijing ). |
stackId |
string |
The ID of the stack. |
stackName |
string |
The concrete ROS physical stack name. |
synthesizer |
IStackSynthesizer |
Synthesis method for this stack. |
tags |
TagManager |
Tags to be applied to the stack. |
templateFile |
string |
The name of the ROS template file emitted to the output directory during synthesis. |
templateOptions |
ITemplateOptions |
Options for ROS template (like version, description). |
nestedStackParent |
Stack |
If this is a nested stack, returns it's parent stack. |
nestedStackResource |
RosResource |
If this is a nested stack, this represents its ALIYUN::ROS::Stack resource. |
parentStack |
Stack |
Returns the parent of a nested stack. |
roles |
RamRoles |
No description. |
node
Required
public readonly node: ConstructNode;
- Type: ConstructNode
The construct tree node associated with this construct.
account
Required
public readonly account: string;
- Type: string
The ALIYUN account into which this stack will be deployed.
This value is resolved according to the following rules:
- The value provided to
env.account
when the stack is defined. This can either be a concrete account or theALIYUN.ACCOUNT_ID
token. ALIYUN.ACCOUNT_ID
, which represents the ROS intrinsic reference{ "Ref": "ALIYUN::AccountId" }
encoded as a string token.
Preferably, you should use the return value as an opaque string and not
attempt to parse it to implement your logic. If you do, you must first
check that it is a concrete value an not an unresolved token. If this
value is an unresolved token (Token.isUnresolved(stack.account)
returns
true
), this implies that the user wishes that this stack will synthesize
into a account-agnostic template. In this case, your code should either
fail (throw an error, emit a synth error using Annotations.of(construct).addError()
) or
implement some other region-agnostic behavior.
artifactId
Required
public readonly artifactId: string;
- Type: string
The ID of the cloud assembly artifact for this stack.
bundlingRequired
Required
public readonly bundlingRequired: boolean;
- Type: boolean
Indicates whether the stack requires bundling or not.
dependencies
Required
public readonly dependencies: Stack[];
- Type: Stack[]
Return the stacks this stack depends on.
enableResourcePropertyConstraint
Required
public readonly enableResourcePropertyConstraint: boolean;
- Type: boolean
nested
Required
public readonly nested: boolean;
- Type: boolean
Indicates if this is a nested stack, in which case parentStack
will include a reference to it's parent.
region
Required
public readonly region: string;
- Type: string
The ALIYUN region into which this stack will be deployed (e.g. cn-beijing
).
This value is resolved according to the following rules:
- The value provided to
env.region
when the stack is defined. This can either be a concrete region or theALIYUN.REGION
token. ALIYUN.REGION
, which is represents the ROS intrinsic reference{ "Ref": "ALIYUN::Region" }
encoded as a string token.
Preferably, you should use the return value as an opaque string and not
attempt to parse it to implement your logic. If you do, you must first
check that it is a concrete value an not an unresolved token. If this
value is an unresolved token (Token.isUnresolved(stack.region)
returns
true
), this implies that the user wishes that this stack will synthesize
into a region-agnostic template. In this case, your code should either
fail (throw an error, emit a synth error using Annotations.of(construct).addError()
) or
implement some other region-agnostic behavior.
stackId
Required
public readonly stackId: string;
- Type: string
The ID of the stack.
stackName
Required
public readonly stackName: string;
- Type: string
The concrete ROS physical stack name.
This is either the name defined explicitly in the stackName
prop or
allocated based on the stack's location in the construct tree. Stacks that
are directly defined under the app use their construct id
as their stack
name. Stacks that are defined deeper within the tree will use a hashed naming
scheme based on the construct path to ensure uniqueness.
synthesizer
Required
public readonly synthesizer: IStackSynthesizer;
- Type: IStackSynthesizer
Synthesis method for this stack.
tags
Required
public readonly tags: TagManager;
- Type: TagManager
Tags to be applied to the stack.
templateFile
Required
public readonly templateFile: string;
- Type: string
The name of the ROS template file emitted to the output directory during synthesis.
Example
MyStack.template.json
templateOptions
Required
public readonly templateOptions: ITemplateOptions;
- Type: ITemplateOptions
Options for ROS template (like version, description).
nestedStackParent
Optional
public readonly nestedStackParent: Stack;
- Type: Stack
If this is a nested stack, returns it's parent stack.
nestedStackResource
Optional
public readonly nestedStackResource: RosResource;
- Type: RosResource
If this is a nested stack, this represents its ALIYUN::ROS::Stack
resource.
undefined
for top-level (non-nested) stacks.
~~parentStack
~~Optional
- Deprecated: use
nestedStackParent
public readonly parentStack: Stack;
- Type: Stack
Returns the parent of a nested stack.
roles
Optional
public readonly roles: RamRoles;
- Type: RamRoles