CloudAssembly
- class aws_cdk.cx_api.CloudAssembly(directory, *, skip_enum_check=None, skip_version_check=None, topo_sort=None)
Bases:
objectRepresents a deployable cloud application.
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.cx_api as cx_api cloud_assembly = cx_api.CloudAssembly("directory", skip_enum_check=False, skip_version_check=False, topo_sort=False )
Reads a cloud assembly from the specified directory.
- Parameters:
directory (
str) – The root directory of the assembly.skip_enum_check (
Optional[bool]) – Skip enum checks. This means you may read enum values you don’t know about yet. Make sure to always check the values of enums you encounter in the manifest. Default: falseskip_version_check (
Optional[bool]) – Skip the version check. This means you may read a newer cloud assembly than the CX API is designed to support, and your application may not be aware of all features that in use in the Cloud Assembly. Default: falsetopo_sort (
Optional[bool]) – Topologically sort all artifacts. This parameter is only respected by the constructor ofCloudAssembly. The property lives here for backwards compatibility reasons. Default: true
Methods
- get_nested_assembly(artifact_id)
Returns a nested assembly.
- Parameters:
artifact_id (
str) – The artifact ID of the nested assembly.- Return type:
- get_nested_assembly_artifact(artifact_id)
Returns a nested assembly artifact.
- Parameters:
artifact_id (
str) – The artifact ID of the nested assembly.- Return type:
- get_stack(stack_name)
(deprecated) Returns a CloudFormation stack artifact by name from this assembly.
- Parameters:
stack_name (
str)- Deprecated:
renamed to
getStackByName(orgetStackArtifact(id))- Stability:
deprecated
- Return type:
- get_stack_artifact(artifact_id)
Returns a CloudFormation stack artifact from this assembly.
- Parameters:
artifact_id (
str) – the artifact id of the stack (can be obtained throughstack.artifactId).- Return type:
- Returns:
a
CloudFormationStackArtifactobject.- Throws:
if there is no stack artifact with that id
- get_stack_by_name(stack_name)
Returns a CloudFormation stack artifact from this assembly.
Will only search the current assembly.
- Parameters:
stack_name (
str) – the name of the CloudFormation stack.- Return type:
- Returns:
a
CloudFormationStackArtifactobject.- Throws:
if there is more than one stack with the same stack name. You can use
getStackArtifact(stack.artifactId)instead.
- tree()
Returns the tree metadata artifact from this assembly.
- Return type:
Optional[TreeCloudArtifact]- Returns:
a
TreeCloudArtifactobject if there is one defined in the manifest,undefinedotherwise.- Throws:
if there is no metadata artifact by that name
- try_get_artifact(id)
Attempts to find an artifact with a specific identity.
- Parameters:
id (
str) – The artifact ID.- Return type:
Optional[CloudArtifact]- Returns:
A
CloudArtifactobject orundefinedif the artifact does not exist in this assembly.
Attributes
- artifacts
All artifacts included in this assembly.
- directory
The root directory of the cloud assembly.
- manifest
The raw assembly manifest.
- nested_assemblies
The nested assembly artifacts in this assembly.
- runtime
Runtime information such as module versions used to synthesize this assembly.
- stacks
all the CloudFormation stack artifacts that are included in this assembly.
- Type:
return
- stacks_recursively
Returns all the stacks, including the ones in nested assemblies.
- version
The schema version of the assembly manifest.
Static Methods
- classmethod cleanup_temporary_directories()
Cleans up any temporary assembly directories that got created in this process.
If a Cloud Assembly is emitted to a temporary directory, its directory gets added to a list. This function iterates over that list and deletes each directory in it, to free up disk space.
This function will normally be called automatically during Node process exit and so you don’t need to call this. However, some test environments do not properly trigger Node’s
exitevent. Notably: Jest does not trigger theexitevent (https://github.com/jestjs/jest/issues/10927).Cleaning up temporary directories in jest
For Jest, you have to make sure this function is called at the end of the test suite instead:
import { CloudAssembly } from 'aws-cdk-lib/cx-api'; afterAll(CloudAssembly.cleanupTemporaryDirectories);
Alternatively, you can use the
setupFilesAfterEnvfeature and use a provided helper script to automatically inject the above into every test file, so you don’t have to do it by hand:$ npx jest --setupFilesAfterEnv aws-cdk-lib/testhelpers/jest-autoclean
Or put the following into
jest.config.js:module.exports = { // ... setupFilesAfterEnv: ['aws-cdk-lib/testhelpers/jest-cleanup'], };
- Return type:
None
- classmethod is_cloud_assembly(x)
Return whether the given object is a CloudAssembly.
We do attribute detection since we can’t reliably use ‘instanceof’.
- Parameters:
x (
Any)- Return type:
bool