Stage
- class aws_cdk.Stage(scope, id, *, env=None, outdir=None, permissions_boundary=None, policy_validation_beta1=None, stage_name=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 preprod = MyApplicationStage(self, "PreProd") prod = MyApplicationStage(self, "Prod") pipeline.add_stage(preprod, post=[ pipelines.ShellStep("Validate Endpoint", commands=["curl -Ssf https://my.webservice.com/"] ) ] ) pipeline.add_stage(prod, pre=[pipelines.ManualApprovalStep("PromoteToProd")] )
- 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.permissions_boundary (
Optional
[PermissionsBoundary
]) – Options for applying a permissions boundary to all IAM Roles and Users created within this Stage. Default: - no permissions boundary is appliedpolicy_validation_beta1 (
Optional
[Sequence
[IPolicyValidationPluginBeta1
]]) – Validation plugins to run during synthesis. If any plugin reports any violation, synthesis will be interrupted and the report displayed to the user. Default: - no validation plugins are usedstage_name (
Optional
[str
]) – Name of this stage. Default: - Derived from the id.
Methods
- synth(*, error_on_duplicate_synth=None, 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:
error_on_duplicate_synth (
Optional
[bool
]) – Whether or not to throw a warning instead of an error if the construct tree has been mutated since the last synth. Default: trueforce (
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 tree node.
- outdir
The cloud assembly output directory.
- parent_stage
The parent stage or
undefined
if this is the app.
- policy_validation_beta1
Validation plugins to run during synthesis.
If any plugin reports any violation, synthesis will be interrupted and the report displayed to the user.
- Default:
no validation plugins are used
- 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)
Checks if
x
is a construct.Use this method instead of
instanceof
to properly detectConstruct
instances, even when the construct library is symlinked.Explanation: in JavaScript, multiple copies of the
constructs
library on disk are seen as independent, completely different libraries. As a consequence, the classConstruct
in each copy of theconstructs
library is seen as a different class, and an instance of one class will not test asinstanceof
the other class.npm install
will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of theconstructs
library can be accidentally installed, andinstanceof
will behave unpredictably. It is safest to avoid usinginstanceof
, and using this type-testing method instead.- Parameters:
x (
Any
) – Any object.- Return type:
bool
- Returns:
true if
x
is an object created from a class which extendsConstruct
.
- 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
]