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());
 
  • Method Details

    • getAccount

      @Stability(Stable) @NotNull String 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::AccountId intrinsic), make sure to use Token.compareStrings() instead of comparing the values with direct string equality.

    • getRegion

      @Stability(Stable) @NotNull String getRegion()
      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.

    • builder

      @Stability(Stable) static ResourceEnvironment.Builder builder()
      Returns:
      a ResourceEnvironment.Builder of ResourceEnvironment