Class: AWSCDK::App

Inherits:
Stage
  • Object
show all
Defined in:
app.rb

Overview

A construct which represents an entire CDK app. This construct is normally the root of the construct tree.

You would normally define an App instance in your program's entrypoint, then define constructs where the app is used as the parent scope.

After all the child constructs are defined within the app, you should call app.synth() which will emit a "cloud assembly" from this app into the directory specified by outdir. Cloud assemblies includes artifacts such as CloudFormation templates and assets that are needed to deploy this app into the AWS cloud.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(props = nil) ⇒ App

Initializes a CDK application.

Parameters:

  • props (AWSCDK::AppProps, nil) (defaults to: nil)

    initialization properties.



22
23
24
25
26
# File 'app.rb', line 22

def initialize(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::AppProps.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5BcHBQcm9wcyJ9")), "props") unless props.nil?
  Jsii::Object.instance_method(:initialize).bind(self).call(props)
end

Class Method Details

.is_app(obj) ⇒ Boolean

Checks if an object is an instance of the App class.

Parameters:

  • obj (Object)

    The object to evaluate.

Returns:

  • (Boolean)

    true if obj is an App.



58
59
60
61
# File 'app.rb', line 58

def self.is_app(obj)
  Jsii::Type.check_type(obj, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJhbnkifQ==")), "obj")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.App", "isApp", [obj])
end

.jsii_overridable_methodsObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app.rb', line 28

def self.jsii_overridable_methods
  {
    :node => { kind: :property, name: "node", is_optional: false },
    :artifact_id => { kind: :property, name: "artifactId", is_optional: false },
    :asset_outdir => { kind: :property, name: "assetOutdir", is_optional: false },
    :outdir => { kind: :property, name: "outdir", is_optional: false },
    :policy_validation_beta1 => { kind: :property, name: "policyValidationBeta1", is_optional: false },
    :stage_name => { kind: :property, name: "stageName", is_optional: false },
    :account => { kind: :property, name: "account", is_optional: true },
    :parent_stage => { kind: :property, name: "parentStage", is_optional: true },
    :region => { kind: :property, name: "region", is_optional: true },
    :to_string => { kind: :method, name: "toString", is_optional: false },
    :with => { kind: :method, name: "with", is_optional: false },
    :synth => { kind: :method, name: "synth", is_optional: false },
  }
end

.of(construct) ⇒ AWSCDK::Stage?

Return the app that is the root of the construct tree, if available.

Parameters:

  • construct (Constructs::IConstruct)

Returns:



49
50
51
52
# File 'app.rb', line 49

def self.of(construct)
  Jsii::Type.check_type(construct, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklDb25zdHJ1Y3QifQ==")), "construct")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.App", "of", [construct])
end

Instance Method Details

#accountString?

The default account for all resources defined within this stage.

Returns:

  • (String, nil)


117
118
119
# File 'app.rb', line 117

def ()
  jsii_get_property("account")
end

#artifact_idString

Artifact ID of the assembly if it is a nested stage. The root stage (app) will return an empty string.

Derived from the construct path.

Returns:

  • (String)


75
76
77
# File 'app.rb', line 75

def artifact_id()
  jsii_get_property("artifactId")
end

#asset_outdirString

The cloud assembly asset output directory.

Returns:

  • (String)


82
83
84
# File 'app.rb', line 82

def asset_outdir()
  jsii_get_property("assetOutdir")
end

#nodeConstructs::Node

The tree node.

Returns:

  • (Constructs::Node)


66
67
68
# File 'app.rb', line 66

def node()
  jsii_get_property("node")
end

#outdirString

The cloud assembly output directory.

Returns:

  • (String)


89
90
91
# File 'app.rb', line 89

def outdir()
  jsii_get_property("outdir")
end

#parent_stageAWSCDK::Stage?

The parent stage or undefined if this is the app.

*

Returns:



126
127
128
# File 'app.rb', line 126

def parent_stage()
  jsii_get_property("parentStage")
end

#policy_validation_beta1Array<AWSCDK::IPolicyValidationPluginBeta1>

Note:

Default: - no validation plugins are used

Validation plugins to run during synthesis.

If any plugin reports any violation, synthesis will be interrupted and the report displayed to the user.



100
101
102
# File 'app.rb', line 100

def policy_validation_beta1()
  jsii_get_property("policyValidationBeta1")
end

#regionString?

The default region for all resources defined within this stage.

Returns:

  • (String, nil)


133
134
135
# File 'app.rb', line 133

def region()
  jsii_get_property("region")
end

#stage_nameString

The name of the stage.

Based on names of the parent stages separated by hypens.

Returns:

  • (String)


110
111
112
# File 'app.rb', line 110

def stage_name()
  jsii_get_property("stageName")
end

#synth(options = nil) ⇒ AWSCDK::CXAPI::CloudAssembly

Synthesize this App into a cloud assembly.

Once an assembly has been synthesized, it cannot be modified. Subsequent calls will return the same assembly.

Parameters:

Returns:



167
168
169
170
171
# File 'app.rb', line 167

def synth(options = nil)
  options = options.is_a?(Hash) ? ::AWSCDK::StageSynthesisOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TdGFnZVN5bnRoZXNpc09wdGlvbnMifQ==")), "options") unless options.nil?
  jsii_call_method("synth", [options])
end

#to_stringString

Returns a string representation of this construct.

Returns:

  • (String)


140
141
142
# File 'app.rb', line 140

def to_string()
  jsii_call_method("toString", [])
end

#with(*mixins) ⇒ Constructs::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.

Parameters:

  • mixins (Array<Constructs::IMixin>)

    The mixins to apply.

Returns:

  • (Constructs::IConstruct)

    This construct for chaining



153
154
155
156
157
158
# File 'app.rb', line 153

def with(*mixins)
  mixins.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklNaXhpbiJ9")), "mixins[#{index}]")
  end
  jsii_call_method("with", [*mixins])
end