Class: AWSCDK::CXAPI::CloudAssembly

Inherits:
Jsii::Object
  • Object
show all
Includes:
AWSCDK::CloudAssemblySchema::ICloudAssembly
Defined in:
cxapi/cloud_assembly.rb

Overview

Represents a deployable cloud application.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(directory, load_options = nil) ⇒ CloudAssembly

Reads a cloud assembly from the specified directory.

Parameters:



13
14
15
16
17
18
# File 'cxapi/cloud_assembly.rb', line 13

def initialize(directory, load_options = nil)
  load_options = load_options.is_a?(Hash) ? ::AWSCDK::CloudAssemblySchema::LoadManifestOptions.new(**load_options.transform_keys(&:to_sym)) : load_options
  Jsii::Type.check_type(directory, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "directory")
  Jsii::Type.check_type(load_options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5jbG91ZF9hc3NlbWJseV9zY2hlbWEuTG9hZE1hbmlmZXN0T3B0aW9ucyJ9")), "loadOptions") unless load_options.nil?
  Jsii::Object.instance_method(:initialize).bind(self).call(directory, load_options)
end

Class Method Details

.cleanup_temporary_directoriesvoid

This method returns an undefined value.

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 exit event. Notably: Jest does not trigger the exit event (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 setup_files_after_env feature 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'],
};


79
80
81
# File 'cxapi/cloud_assembly.rb', line 79

def self.cleanup_temporary_directories()
  Jsii::Kernel.instance.call_static("aws-cdk-lib.cx_api.CloudAssembly", "cleanupTemporaryDirectories", [])
end

.is_cloud_assembly(x) ⇒ Boolean

Return whether the given object is a CloudAssembly.

We do attribute detection since we can't reliably use 'instanceof'.

Parameters:

  • x (Object)

Returns:

  • (Boolean)


89
90
91
92
# File 'cxapi/cloud_assembly.rb', line 89

def self.is_cloud_assembly(x)
  Jsii::Type.check_type(x, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJhbnkifQ==")), "x")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.cx_api.CloudAssembly", "isCloudAssembly", [x])
end

.jsii_overridable_methodsObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'cxapi/cloud_assembly.rb', line 20

def self.jsii_overridable_methods
  {
    :artifacts => { kind: :property, name: "artifacts", is_optional: false },
    :directory => { kind: :property, name: "directory", is_optional: false },
    :manifest => { kind: :property, name: "manifest", is_optional: false },
    :nested_assemblies => { kind: :property, name: "nestedAssemblies", is_optional: false },
    :runtime => { kind: :property, name: "runtime", is_optional: false },
    :stacks => { kind: :property, name: "stacks", is_optional: false },
    :stacks_recursively => { kind: :property, name: "stacksRecursively", is_optional: false },
    :version => { kind: :property, name: "version", is_optional: false },
    :get_nested_assembly => { kind: :method, name: "getNestedAssembly", is_optional: false },
    :get_nested_assembly_artifact => { kind: :method, name: "getNestedAssemblyArtifact", is_optional: false },
    :get_stack_artifact => { kind: :method, name: "getStackArtifact", is_optional: false },
    :get_stack_by_name => { kind: :method, name: "getStackByName", is_optional: false },
    :tree => { kind: :method, name: "tree", is_optional: false },
    :try_get_artifact => { kind: :method, name: "tryGetArtifact", is_optional: false },
  }
end

Instance Method Details

#artifactsArray<AWSCDK::CXAPI::CloudArtifact>

All artifacts included in this assembly.

Returns:



97
98
99
# File 'cxapi/cloud_assembly.rb', line 97

def artifacts()
  jsii_get_property("artifacts")
end

#directoryString

The root directory of the cloud assembly.

Returns:

  • (String)


104
105
106
# File 'cxapi/cloud_assembly.rb', line 104

def directory()
  jsii_get_property("directory")
end

#get_nested_assembly(artifact_id) ⇒ AWSCDK::CXAPI::CloudAssembly

Returns a nested assembly.

Parameters:

  • artifact_id (String)
    • The artifact ID of the nested assembly.

Returns:

  • (AWSCDK::CXAPI::CloudAssembly)


152
153
154
155
# File 'cxapi/cloud_assembly.rb', line 152

def get_nested_assembly(artifact_id)
  Jsii::Type.check_type(artifact_id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "artifactId")
  jsii_call_method("getNestedAssembly", [artifact_id])
end

#get_nested_assembly_artifact(artifact_id) ⇒ AWSCDK::CXAPI::NestedCloudAssemblyArtifact

Returns a nested assembly artifact.

Parameters:

  • artifact_id (String)
    • The artifact ID of the nested assembly.

Returns:



161
162
163
164
# File 'cxapi/cloud_assembly.rb', line 161

def get_nested_assembly_artifact(artifact_id)
  Jsii::Type.check_type(artifact_id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "artifactId")
  jsii_call_method("getNestedAssemblyArtifact", [artifact_id])
end

#get_stack_artifact(artifact_id) ⇒ AWSCDK::CXAPI::CloudFormationStackArtifact

Returns a CloudFormation stack artifact from this assembly.

Parameters:

  • artifact_id (String)
    • the artifact id of the stack (can be obtained through stack.artifactId).

Returns:



170
171
172
173
# File 'cxapi/cloud_assembly.rb', line 170

def get_stack_artifact(artifact_id)
  Jsii::Type.check_type(artifact_id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "artifactId")
  jsii_call_method("getStackArtifact", [artifact_id])
end

#get_stack_by_name(stack_name) ⇒ AWSCDK::CXAPI::CloudFormationStackArtifact

Returns a CloudFormation stack artifact from this assembly.

Will only search the current assembly.

Parameters:

  • stack_name (String)
    • the name of the CloudFormation stack.

Returns:



181
182
183
184
# File 'cxapi/cloud_assembly.rb', line 181

def get_stack_by_name(stack_name)
  Jsii::Type.check_type(stack_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "stackName")
  jsii_call_method("getStackByName", [stack_name])
end

#manifestAWSCDK::CloudAssemblySchema::AssemblyManifest

The raw assembly manifest.



111
112
113
# File 'cxapi/cloud_assembly.rb', line 111

def manifest()
  jsii_get_property("manifest")
end

#nested_assembliesArray<AWSCDK::CXAPI::NestedCloudAssemblyArtifact>

The nested assembly artifacts in this assembly.



118
119
120
# File 'cxapi/cloud_assembly.rb', line 118

def nested_assemblies()
  jsii_get_property("nestedAssemblies")
end

#runtimeAWSCDK::CloudAssemblySchema::RuntimeInfo

Runtime information such as module versions used to synthesize this assembly.



125
126
127
# File 'cxapi/cloud_assembly.rb', line 125

def runtime()
  jsii_get_property("runtime")
end

#stacksArray<AWSCDK::CXAPI::CloudFormationStackArtifact>



130
131
132
# File 'cxapi/cloud_assembly.rb', line 130

def stacks()
  jsii_get_property("stacks")
end

#stacks_recursivelyArray<AWSCDK::CXAPI::CloudFormationStackArtifact>

Returns all the stacks, including the ones in nested assemblies.



137
138
139
# File 'cxapi/cloud_assembly.rb', line 137

def stacks_recursively()
  jsii_get_property("stacksRecursively")
end

#treeAWSCDK::CXAPI::TreeCloudArtifact?

Returns the tree metadata artifact from this assembly.

Returns:



189
190
191
# File 'cxapi/cloud_assembly.rb', line 189

def tree()
  jsii_call_method("tree", [])
end

#try_get_artifact(id) ⇒ AWSCDK::CXAPI::CloudArtifact?

Attempts to find an artifact with a specific identity.

Parameters:

  • id (String)
    • The artifact ID.

Returns:



197
198
199
200
# File 'cxapi/cloud_assembly.rb', line 197

def try_get_artifact(id)
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  jsii_call_method("tryGetArtifact", [id])
end

#versionString

The schema version of the assembly manifest.

Returns:

  • (String)


144
145
146
# File 'cxapi/cloud_assembly.rb', line 144

def version()
  jsii_get_property("version")
end