Interface ResourceEnvironment
- All Superinterfaces:
software.amazon.jsii.JsiiSerializable
- All Known Implementing Classes:
ResourceEnvironment.Jsii$Proxy
@Generated(value="jsii-pacmak/1.127.0 (build 2117ad5)",
date="2026-03-19T12:55:15.239Z")
@Stability(Stable)
public interface ResourceEnvironment
extends software.amazon.jsii.JsiiSerializable
Represents the environment a given resource lives in.
Used as the return value for the IEnvironmentAware.env property.
Example:
import software.amazon.awscdk.CfnResource;
import software.amazon.awscdk.services.iam.IResourcePolicyFactory;
import software.amazon.awscdk.services.iam.IResourceWithPolicyV2;
import software.amazon.awscdk.services.iam.PolicyStatement;
import software.amazon.awscdk.services.iam.ResourceWithPolicies;
import software.constructs.Construct;
import software.constructs.IConstruct;
Construct scope;
public class MyFactory implements IResourcePolicyFactory {
public IResourceWithPolicyV2 forResource(CfnResource resource) {
return Map.of(
"env", resource.getEnv(),
public Map<String, Object> addToResourcePolicy(PolicyStatement statement) {
// custom implementation to add the statement to the resource policy
return AddToResourcePolicyResult.builder()"statementAdded", true"policyDependable", resource.build();
});
}
}
ResourceWithPolicies.register(scope, "AWS::KMS::Key", new MyFactory());
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classA builder forResourceEnvironmentstatic final classAn implementation forResourceEnvironment -
Method Summary
Modifier and TypeMethodDescriptionstatic ResourceEnvironment.Builderbuilder()The AWS Account ID that this resource belongs to.The AWS Region that this resource belongs to.Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Method Details
-
getAccount
The AWS Account ID that this resource belongs to.Since this can be a Token (for example, when the account is CloudFormation's
AWS::AccountIdintrinsic), make sure to useToken.compareStrings()instead of comparing the values with direct string equality. -
getRegion
The AWS Region that this resource belongs to.Since this can be a Token (for example, when the region is CloudFormation's
AWS::Regionintrinsic), make sure to useToken.compareStrings()instead of comparing the values with direct string equality. -
builder
- Returns:
- a
ResourceEnvironment.BuilderofResourceEnvironment
-