interface ResourceEnvironment
| Language | Type name |
|---|---|
.NET | Amazon.CDK.Interfaces.ResourceEnvironment |
Go | github.com/aws/aws-cdk-go/awscdk/v2/interfaces#ResourceEnvironment |
Java | software.amazon.awscdk.interfaces.ResourceEnvironment |
Python | aws_cdk.interfaces.ResourceEnvironment |
TypeScript (source) | aws-cdk-lib » interfaces » ResourceEnvironment |
Represents the environment a given resource lives in.
Used as the return value for the IEnvironmentAware.env property.
Example
import { CfnResource } from 'aws-cdk-lib';
import { IResourcePolicyFactory, IResourceWithPolicyV2, PolicyStatement, ResourceWithPolicies } from 'aws-cdk-lib/aws-iam';
import { Construct, IConstruct } from 'constructs';
declare const scope: Construct;
class MyFactory implements IResourcePolicyFactory {
forResource(resource: CfnResource): IResourceWithPolicyV2 {
return {
env: resource.env,
addToResourcePolicy(statement: PolicyStatement) {
// custom implementation to add the statement to the resource policy
return { statementAdded: true, policyDependable: resource };
}
}
}
}
ResourceWithPolicies.register(scope, 'AWS::KMS::Key', new MyFactory());
Properties
| Name | Type | Description |
|---|---|---|
| account | string | The AWS Account ID that this resource belongs to. |
| region | string | The AWS Region that this resource belongs to. |
account
Type:
string
The AWS Account ID that this resource belongs to.
Since this can be a Token (for example, when the account is
CloudFormation's AWS::AccountId intrinsic), make sure to use
Token.compareStrings() instead of comparing the values with direct
string equality.
region
Type:
string
The AWS Region that this resource belongs to.
Since this can be a Token (for example, when the region is CloudFormation's
AWS::Region intrinsic), make sure to use Token.compareStrings() instead
of comparing the values with direct string equality.

.NET
Go
Java
Python
TypeScript (