Skip to content
v2.273.0

Environment L2 construct ​

An AWS AppConfig environment.

[disable-awslint:no-grants]

Example ​

ts
const app = new appconfig.Application(this, 'MyApp');
const env = new appconfig.Environment(this, 'MyEnv', {
  application: app,
});

new appconfig.HostedConfiguration(this, 'MyFirstHostedConfig', {
  application: app,
  deployTo: [env],
  content: appconfig.ConfigurationContent.fromInlineText('This is my first configuration content.'),
});

new appconfig.HostedConfiguration(this, 'MySecondHostedConfig', {
  application: app,
  deployTo: [env],
  content: appconfig.ConfigurationContent.fromInlineText('This is my second configuration content.'),
});
python
app = appconfig.Application(self, "MyApp")
env = appconfig.Environment(self, "MyEnv",
    application=app
)

appconfig.HostedConfiguration(self, "MyFirstHostedConfig",
    application=app,
    deploy_to=[env],
    content=appconfig.ConfigurationContent.from_inline_text("This is my first configuration content.")
)

appconfig.HostedConfiguration(self, "MySecondHostedConfig",
    application=app,
    deploy_to=[env],
    content=appconfig.ConfigurationContent.from_inline_text("This is my second configuration content.")
)
java
Application app = new Application(this, "MyApp");
Environment env = Environment.Builder.create(this, "MyEnv")
        .application(app)
        .build();

HostedConfiguration.Builder.create(this, "MyFirstHostedConfig")
        .application(app)
        .deployTo(List.of(env))
        .content(ConfigurationContent.fromInlineText("This is my first configuration content."))
        .build();

HostedConfiguration.Builder.create(this, "MySecondHostedConfig")
        .application(app)
        .deployTo(List.of(env))
        .content(ConfigurationContent.fromInlineText("This is my second configuration content."))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
var app = new Application(this, "MyApp");
var env = new Environment(this, "MyEnv", new EnvironmentProps {
    Application = app
});

new HostedConfiguration(this, "MyFirstHostedConfig", new HostedConfigurationProps {
    Application = app,
    DeployTo = new [] { env },
    Content = ConfigurationContent.FromInlineText("This is my first configuration content.")
});

new HostedConfiguration(this, "MySecondHostedConfig", new HostedConfigurationProps {
    Application = app,
    DeployTo = new [] { env },
    Content = ConfigurationContent.FromInlineText("This is my second configuration content.")
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
app := appconfig.NewApplication(this, jsii.String("MyApp"))
env := appconfig.NewEnvironment(this, jsii.String("MyEnv"), &EnvironmentProps{
	Application: app,
})

appconfig.NewHostedConfiguration(this, jsii.String("MyFirstHostedConfig"), &HostedConfigurationProps{
	Application: app,
	DeployTo: []IEnvironment{
		env,
	},
	Content: appconfig.ConfigurationContent_FromInlineText(jsii.String("This is my first configuration content.")),
})

appconfig.NewHostedConfiguration(this, jsii.String("MySecondHostedConfig"), &HostedConfigurationProps{
	Application: app,
	DeployTo: []IEnvironment{
		env,
	},
	Content: appconfig.ConfigurationContent_*FromInlineText(jsii.String("This is my second configuration content.")),
})

Initializer ​

ts
new Environment(scope: Construct, id: string, props: EnvironmentProps)
python
Environment(scope: Construct, id: str, props: EnvironmentProps)
java
new Environment(Construct scope, String id, EnvironmentProps props)
csharp
new Environment(Construct scope, string id, EnvironmentProps props)
go
NewEnvironment(Scope Construct, Id *string, Props EnvironmentProps)

Construct Props ​

applicationIApplicationapplicationIApplicationapplicationIApplicationApplicationIApplicationApplicationIApplicationrequired#
The application to be associated with the environment.
deletionProtectionCheckDeletionProtectionCheckdeletion_protection_checkDeletionProtectionCheckdeletionProtectionCheckDeletionProtectionCheckDeletionProtectionCheckDeletionProtectionCheckDeletionProtectionCheckDeletionProtectionCheck= undefined - AppConfig default is…#
A property to prevent accidental deletion of active environments.
default

Default: undefined - AppConfig default is ACCOUNT_DEFAULT

descriptionstringdescriptionstrdescriptionStringDescriptionstringDescription*string= No description.#
The description of the environment.
environmentNamestringenvironment_namestrenvironmentNameStringEnvironmentNamestringEnvironmentName*string= A name is generated.#
The name of the environment.
monitorsMonitor[]monitorstyping.List[Monitor]monitorsList<Monitor>MonitorsMonitor[]Monitors*[]Monitor= No monitors.#
The monitors for the environment.

Properties ​

applicationIApplicationapplicationIApplicationapplicationIApplicationApplicationIApplicationApplicationIApplication#
The application associated with the environment.
applicationIdstringapplication_idstrapplicationIdStringApplicationIdstringApplicationId*stringrequired#
The ID of the environment.
descriptionstringdescriptionstrdescriptionStringDescriptionstringDescription*string#
The description of the environment.
The environment this resource belongs to.
notes

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.

environmentArnstringenvironment_arnstrenvironmentArnStringEnvironmentArnstringEnvironmentArn*stringrequired#
The Amazon Resource Name (ARN) of the environment.
environmentIdstringenvironment_idstrenvironmentIdStringEnvironmentIdstringEnvironmentId*stringrequired#
The ID of the environment.
environmentRefEnvironmentReferenceenvironment_refEnvironmentReferenceenvironmentRefEnvironmentReferenceEnvironmentRefEnvironmentReferenceEnvironmentRefEnvironmentReferencerequired#
A reference to a Environment resource.
monitorsMonitor[]monitorstyping.List[Monitor]monitorsList<Monitor>MonitorsMonitor[]Monitors*[]Monitor#
The monitors for the environment.
namestringnamestrnameStringNamestringName*string#
The name of the environment.
nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#
Uniquely identifies this class.
stackStackstackStackstackStackStackStackStackStackrequired#
The stack in which this resource is defined.

Methods ​

addDeployment(configuration: IConfiguration): voiddef add_deployment(self, configuration: IConfiguration) -> Nonepublic void addDeployment(IConfiguration configuration)public void AddDeployment(IConfiguration configuration)func AddDeployment(Configuration IConfiguration)#
Creates a deployment of the supplied configuration to this environment.
notes

Note that you can only deploy one configuration at a time to an environment. However, you can deploy one configuration each to different environments at the same time. If more than one deployment is requested for this environment, they will occur in the same order they were provided.

addDeployments(...configurations: IConfiguration[]): voiddef add_deployments(self, configurations: IConfiguration) -> Nonepublic void addDeployments(IConfiguration configurations)public void AddDeployments(IConfiguration configurations)func AddDeployments(Configurations IConfiguration)#
Creates a deployment for each of the supplied configurations to this environment.

These configurations will be deployed in the same order as the input array.

addExtension(extension: IExtension): voiddef add_extension(self, extension: IExtension) -> Nonepublic void addExtension(IExtension extension)public void AddExtension(IExtension extension)func AddExtension(Extension IExtension)#
Adds an extension association to the environment.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#
Override the cross-stack reference strength for this resource.
notes · 1 parameter

When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.

Parameters

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#
Apply the given removal policy to this resource.
notes

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

atDeploymentTick(eventDestination: IEventDestination, options?: ExtensionOptions): voiddef at_deployment_tick(self, event_destination: IEventDestination, options: typing.Optional[ExtensionOptions] = None) -> Nonepublic void atDeploymentTick(IEventDestination eventDestination, ExtensionOptions options)public void AtDeploymentTick(IEventDestination eventDestination, ExtensionOptions? options = null)func AtDeploymentTick(EventDestination IEventDestination, Options ExtensionOptions)#
Adds an AT_DEPLOYMENT_TICK extension with the provided event destination and also creates an extension association to an application.
fromEnvironmentArn(scope: Construct, id: string, environmentArn: string): IEnvironment@staticmethod def from_environment_arn(scope: Construct, id: str, environment_arn: str) -> IEnvironmentpublic static IEnvironment fromEnvironmentArn(Construct scope, String id, String environmentArn)public static IEnvironment FromEnvironmentArn(Construct scope, string id, string environmentArn)func FromEnvironmentArn(Scope Construct, Id *string, EnvironmentArn *string) IEnvironmentstatic#
Imports an environment into the CDK using its Amazon Resource Name (ARN).
3 parameters

Parameters

  • scopescopescopescopeScope — The parent construct.
  • ididididId — The name of the environment construct.
  • environmentArnenvironment_arnenvironmentArnenvironmentArnEnvironmentArn — The Amazon Resource Name (ARN) of the environment.
fromEnvironmentAttributes(scope: Construct, id: string, attrs: EnvironmentAttributes): IEnvironment@staticmethod def from_environment_attributes(scope: Construct, id: str, attrs: EnvironmentAttributes) -> IEnvironmentpublic static IEnvironment fromEnvironmentAttributes(Construct scope, String id, EnvironmentAttributes attrs)public static IEnvironment FromEnvironmentAttributes(Construct scope, string id, EnvironmentAttributes attrs)func FromEnvironmentAttributes(Scope Construct, Id *string, Attrs EnvironmentAttributes) IEnvironmentstatic#
Imports an environment into the CDK from its attributes.
3 parameters

Parameters

  • scopescopescopescopeScope — The parent construct.
  • ididididId — The name of the environment construct.
  • attrsattrsattrsattrsAttrs — The attributes of the environment.
grant(grantee: IGrantable, ...actions: string[]): Grantdef grant(self, grantee: IGrantable, actions: str) -> Grantpublic Grant grant(IGrantable grantee, String actions)public Grant Grant(IGrantable grantee, string actions)func Grant(Grantee IGrantable, Actions *string) Grant#
[disable-awslint:no-grants].
grantReadConfig(identity: IGrantable): Grantdef grant_read_config(self, identity: IGrantable) -> Grantpublic Grant grantReadConfig(IGrantable identity)public Grant GrantReadConfig(IGrantable identity)func GrantReadConfig(Identity IGrantable) Grant#
[disable-awslint:no-grants].
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct 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 class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof 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 the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#
Returns true if the construct was created by CDK, and false otherwise.
isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#
Check whether the given construct is a Resource.
on(actionPoint: ActionPoint, eventDestination: IEventDestination, options?: ExtensionOptions): voiddef on(self, action_point: ActionPoint, event_destination: IEventDestination, options: typing.Optional[ExtensionOptions] = None) -> Nonepublic void on(ActionPoint actionPoint, IEventDestination eventDestination, ExtensionOptions options)public void On(ActionPoint actionPoint, IEventDestination eventDestination, ExtensionOptions? options = null)func On(ActionPoint ActionPoint, EventDestination IEventDestination, Options ExtensionOptions)#
Adds an extension defined by the action point and event destination and also creates an extension association to the environment.
onDeploymentBaking(eventDestination: IEventDestination, options?: ExtensionOptions): voiddef on_deployment_baking(self, event_destination: IEventDestination, options: typing.Optional[ExtensionOptions] = None) -> Nonepublic void onDeploymentBaking(IEventDestination eventDestination, ExtensionOptions options)public void OnDeploymentBaking(IEventDestination eventDestination, ExtensionOptions? options = null)func OnDeploymentBaking(EventDestination IEventDestination, Options ExtensionOptions)#
Adds an ON_DEPLOYMENT_BAKING extension with the provided event destination and also creates an extension association to the environment.
onDeploymentComplete(eventDestination: IEventDestination, options?: ExtensionOptions): voiddef on_deployment_complete(self, event_destination: IEventDestination, options: typing.Optional[ExtensionOptions] = None) -> Nonepublic void onDeploymentComplete(IEventDestination eventDestination, ExtensionOptions options)public void OnDeploymentComplete(IEventDestination eventDestination, ExtensionOptions? options = null)func OnDeploymentComplete(EventDestination IEventDestination, Options ExtensionOptions)#
Adds an ON_DEPLOYMENT_COMPLETE extension with the provided event destination and also creates an extension association to the environment.
onDeploymentRolledBack(eventDestination: IEventDestination, options?: ExtensionOptions): voiddef on_deployment_rolled_back(self, event_destination: IEventDestination, options: typing.Optional[ExtensionOptions] = None) -> Nonepublic void onDeploymentRolledBack(IEventDestination eventDestination, ExtensionOptions options)public void OnDeploymentRolledBack(IEventDestination eventDestination, ExtensionOptions? options = null)func OnDeploymentRolledBack(EventDestination IEventDestination, Options ExtensionOptions)#
Adds an ON_DEPLOYMENT_ROLLED_BACK extension with the provided event destination and also creates an extension association to the environment.
onDeploymentStart(eventDestination: IEventDestination, options?: ExtensionOptions): voiddef on_deployment_start(self, event_destination: IEventDestination, options: typing.Optional[ExtensionOptions] = None) -> Nonepublic void onDeploymentStart(IEventDestination eventDestination, ExtensionOptions options)public void OnDeploymentStart(IEventDestination eventDestination, ExtensionOptions? options = null)func OnDeploymentStart(EventDestination IEventDestination, Options ExtensionOptions)#
Adds an ON_DEPLOYMENT_START extension with the provided event destination and also creates an extension association to the environment.
onDeploymentStep(eventDestination: IEventDestination, options?: ExtensionOptions): voiddef on_deployment_step(self, event_destination: IEventDestination, options: typing.Optional[ExtensionOptions] = None) -> Nonepublic void onDeploymentStep(IEventDestination eventDestination, ExtensionOptions options)public void OnDeploymentStep(IEventDestination eventDestination, ExtensionOptions? options = null)func OnDeploymentStep(EventDestination IEventDestination, Options ExtensionOptions)#
Adds an ON_DEPLOYMENT_STEP extension with the provided event destination and also creates an extension association to the environment.
preCreateHostedConfigurationVersion(eventDestination: IEventDestination, options?: ExtensionOptions): voiddef pre_create_hosted_configuration_version(self, event_destination: IEventDestination, options: typing.Optional[ExtensionOptions] = None) -> Nonepublic void preCreateHostedConfigurationVersion(IEventDestination eventDestination, ExtensionOptions options)public void PreCreateHostedConfigurationVersion(IEventDestination eventDestination, ExtensionOptions? options = null)func PreCreateHostedConfigurationVersion(EventDestination IEventDestination, Options ExtensionOptions)#
Adds a PRE_CREATE_HOSTED_CONFIGURATION_VERSION extension with the provided event destination and also creates an extension association to the environment.
preStartDeployment(eventDestination: IEventDestination, options?: ExtensionOptions): voiddef pre_start_deployment(self, event_destination: IEventDestination, options: typing.Optional[ExtensionOptions] = None) -> Nonepublic void preStartDeployment(IEventDestination eventDestination, ExtensionOptions options)public void PreStartDeployment(IEventDestination eventDestination, ExtensionOptions? options = null)func PreStartDeployment(EventDestination IEventDestination, Options ExtensionOptions)#
Adds a PRE_START_DEPLOYMENT extension with the provided event destination and also creates an extension association to the environment.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) 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.