Stage
- class aws_cdk.core.Stage(scope, id, *, env=None, outdir=None)
Bases:
Construct
An abstract application modeling unit consisting of Stacks that should be deployed together.
Derive a subclass of
Stage
and use it to model a single instance of your application.You can then instantiate your subclass multiple times to model multiple copies of your application which should be be deployed to different environments.
- ExampleMetadata:
infused
Example:
# pipeline: pipelines.CodePipeline class MyOutputStage(Stage): def __init__(self, scope, id, *, env=None, outdir=None): super().__init__(scope, id, env=env, outdir=outdir) self.load_balancer_address = CfnOutput(self, "Output", value="value") lb_app = MyOutputStage(self, "MyApp") pipeline.add_stage(lb_app, post=[ pipelines.ShellStep("HitEndpoint", env_from_cfn_outputs={ # Make the load balancer address available as $URL inside the commands "URL": lb_app.load_balancer_address }, commands=["curl -Ssf $URL"] ) ] )
- Parameters:
scope (
Construct
) –id (
str
) –env (
Union
[Environment
,Dict
[str
,Any
],None
]) – Default AWS environment (account/region) forStack``s in this ``Stage
. Stacks defined inside thisStage
with eitherregion
oraccount
missing from its env will use the corresponding field given here. If eitherregion
oraccount``is is not configured for ``Stack
(either on theStack
itself or on the containingStage
), the Stack will be environment-agnostic. Environment-agnostic stacks can be deployed to any environment, may not be able to take advantage of all features of the CDK. For example, they will not be able to use environmental context lookups, will not automatically translate Service Principals to the right format based on the environment’s AWS partition, and other such enhancements. Default: - The environments should be configured on the ``Stack``s.outdir (
Optional
[str
]) – The output directory into which to emit synthesized artifacts. Can only be specified if this stage is the root stage (the app). If this is specified and this stage is nested within another stage, an error will be thrown. Default: - for nested stages, outdir will be determined as a relative directory to the outdir of the app. For apps, if outdir is not specified, a temporary directory will be created.
Methods
- synth(*, force=None, skip_validation=None, validate_on_synthesis=None)
Synthesize this stage into a cloud assembly.
Once an assembly has been synthesized, it cannot be modified. Subsequent calls will return the same assembly.
- Parameters:
force (
Optional
[bool
]) – Force a re-synth, even if the stage has already been synthesized. This is used by tests to allow for incremental verification of the output. Do not use in production. Default: falseskip_validation (
Optional
[bool
]) – Should we skip construct validation. Default: - falsevalidate_on_synthesis (
Optional
[bool
]) – Whether the stack should be validated after synthesis to check for error metadata. Default: - false
- Return type:
- to_string()
Returns a string representation of this construct.
- Return type:
str
Attributes
- account
The default account for all resources defined within this stage.
- artifact_id
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.
- asset_outdir
The cloud assembly asset output directory.
- node
The construct tree node associated with this construct.
- outdir
The cloud assembly output directory.
- parent_stage
The parent stage or
undefined
if this is the app.
- region
The default region for all resources defined within this stage.
- stage_name
The name of the stage.
Based on names of the parent stages separated by hypens.
Static Methods
- classmethod is_construct(x)
Return whether the given object is a Construct.
- Parameters:
x (
Any
) –- Return type:
bool
- classmethod is_stage(x)
Test whether the given construct is a stage.
- Parameters:
x (
Any
) –- Return type:
bool
- classmethod of(construct)
Return the stage this construct is contained with, if available.
If called on a nested stage, returns its parent.
- Parameters:
construct (
IConstruct
) –- Return type:
Optional
[Stage
]