Class Resource
- All Implemented Interfaces:
IResource,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
- Direct Known Subclasses:
Accelerator,AccessEntry,AccessEntry,AccessKey,AccessPoint,AccessPoint,AccountAuditConfiguration,Activity,Addon,Addon,AgentAliasBase,AgentBase,AlarmBase,Alias,AliasBase,ApiBase,ApiDestination,ApiKey,ApiKey,ApiKey,ApiMapping,App,Application,Application,Application,AppsyncFunction,Archive,AssessmentTemplate,AttributeGroup,Authorizer,AutoScalingConfiguration,AutoScalingGroup,BackupPlan,BackupSelection,BackupVault,BaseDeploymentConfig,BaseListener,BaseLoadBalancer,BasePathMapping,BaseService,BastionHostLinux,BitBucketSourceCredentials,Branch,BrowserCustomBase,BucketBase,BucketPolicy,BuildBase,CachePolicy,Canary,Certificate,Channel,ChannelNamespace,ClientVpnAuthorizationRule,ClientVpnEndpoint,ClientVpnRoute,CloudFrontWebDistribution,Cluster,Cluster,Cluster,Cluster,ClusterBase,ClusterParameterGroup,ClusterParameterGroup,ClusterParameterGroup,ClusterSubnetGroup,CodeInterpreterCustomBase,CodeSigningConfig,ConfigurationSet,ConfigurationSetEventDestination,Connection,Connection,CrossAccountDestination,CustomLambdaDeploymentConfig,CustomPolicy,CustomResource,CustomRule,Dashboard,Database,DatabaseCluster,DatabaseClusterBase,DatabaseClusterBase,DatabaseInstance,DatabaseInstanceBase,DatabaseInstanceBase,DatabaseProxy,DatabaseProxyEndpoint,DataQualityRuleset,DedicatedIpPool,DeliveryStream,Deployment,DeploymentStrategy,DetectorModel,Distribution,DnsValidatedCertificate,Domain,Domain,Domain,DomainName,DomainName,Ec2Environment,EcsApplication,EcsDeploymentGroup,EcsJobDefinition,EdgeFunction,EgressOnlyInternetGateway,EksJobDefinition,EmailIdentity,Endpoint,EndpointConfig,EndpointGroup,Environment,EventBus,EventBusPolicy,EventInvokeConfig,EventSourceMapping,Extension,FairshareSchedulingPolicy,FargateComputeEnvironment,FileSystem,FileSystemBase,FirewallDomainList,FirewallRuleGroup,FirewallRuleGroupAssociation,Fleet,FleetBase,FlowLog,Function,FunctionBase,FunctionUrl,FunctionUrlOriginAccessControl,GameServerGroupBase,GameSessionQueueBase,GatewayResponse,GatewayRoute,GeofenceCollection,GitHubEnterpriseSourceCredentials,GitHubRepository,GitHubSourceCredentials,GraphqlApiBase,Group,GuardrailBase,HealthCheck,HostedZone,HttpApi,HttpAuthorizer,HttpIntegration,HttpNamespace,HttpRoute,HttpStage,IdentityPool,InferenceProfileBase,Input,Instance,InstanceBase,InstanceProfile,InternetGateway,Ipam,JobBase,JobQueue,Key,KeyGroup,KeyPair,KeySigningKey,KeyValueStore,LambdaApplication,LambdaDeploymentGroup,LaunchTemplate,LayerVersion,LazyRole,LifecycleHook,Listener,LoadBalancer,Logging,LogGroup,LogStream,ManagedEc2EcsComputeEnvironment,ManagedEc2EksComputeEnvironment,ManagedPolicy,ManagedRule,Map,MatchmakingConfigurationBase,MatchmakingRuleSetBase,Mesh,Method,MetricFilter,Model,Model,MultiNodeJobDefinition,Namespace,NatGateway,NetworkAcl,NetworkAclEntry,Nodegroup,Nodegroup,NotificationRule,ObservabilityConfiguration,OidcProviderNative,OpenIdConnectProvider,OptionGroup,OriginAccessIdentity,OriginRequestPolicy,ParameterGroup,ParameterGroup,Pipe,Pipeline,PlaceIndex,PlacementGroup,PlaybackKeyPair,Policy,Portfolio,PrefixList,PrivateCertificate,PrivateDnsNamespace,Product,ProfilingGroup,Project,PromptBase,PublicDnsNamespace,PublicKey,QueryDefinition,QueueBase,QueuePolicy,RateLimitedApiKey,RateLimitedApiKey,RealtimeLogConfig,ReceiptFilter,ReceiptRule,ReceiptRuleSet,RecordingConfiguration,RecordSet,ReportGroup,Repository,RepositoryBase,RequestValidator,ResourceBase,ResourcePolicy,ResourcePolicy,ResourcePolicy,ResponseHeadersPolicy,RestApiBase,Role,RotationSchedule,Route,Route,RouteCalculator,RouteTable,Rule,RuntimeBase,RuntimeEndpointBase,S3OriginAccessControl,SamlProvider,ScalableTarget,Schedule,ScheduledAction,ScheduledAudit,ScheduleGroup,ScriptBase,Secret,SecretTargetAttachment,SecurityConfiguration,SecurityGroup,ServerApplication,ServerDeploymentGroup,ServerlessCacheBase,ServerlessCluster,ServerlessClusterFromSnapshot,Service,Service,SigningProfile,SlackChannelConfiguration,SourceApiAssociation,StageBase,StateMachine,Stream,StreamConsumer,StreamKey,StringListParameter,StringParameter,Subnet,SubnetGroup,SubnetGroup,SubnetNetworkAclAssociation,SubnetV2,Subscription,SubscriptionFilter,Table,TableBase,TableBase,TableBaseV2,TableBucket,TableBucketPolicy,TablePolicy,TagOptions,TaskDefinition,TopicBase,TopicPolicy,TopicRule,Tracker,Trail,Transformer,TransitGateway,TransitGatewayBlackholeRoute,TransitGatewayRoute,TransitGatewayRouteTable,TransitGatewayRouteTableAssociation,TransitGatewayRouteTablePropagation,TransitGatewayVpcAttachment,TrustStore,TrustStoreRevocation,UnmanagedComputeEnvironment,UsagePlan,UsagePlan,User,UserBase,UserGroupBase,UserPool,UserPoolClient,UserPoolDomain,UserPoolGroup,UserPoolIdentityProviderAmazon,UserPoolIdentityProviderApple,UserPoolIdentityProviderFacebook,UserPoolIdentityProviderGoogle,UserPoolIdentityProviderOidc,UserPoolIdentityProviderSaml,UserPoolResourceServer,VdmAttributes,VirtualGateway,VirtualNode,VirtualRouter,VirtualService,Volume,Vpc,VpcConnector,VpcEndpoint,VpcEndpointService,VpcIngressConnection,VpcLink,VpcLink,VpcOrigin,VPCPeeringConnection,VpcV2Base,VpnConnectionBase,VpnGateway,VPNGatewayV2,WarmPool,WebSocketApi,WebSocketAuthorizer,WebSocketIntegration,WebSocketRoute,WebSocketStage,WorkflowBase
Example:
public class MyConstruct extends Resource implements ITaggable {
public final Object tags;
public MyConstruct(Construct scope, String id) {
super(scope, id);
CfnResource.Builder.create(this, "Resource")
.type("Whatever::The::Type")
.properties(Map.of(
// ...
"Tags", this.tags.getRenderedTags()))
.build();
}
}
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.IResource
IResource.Jsii$Default -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedResource(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedResource(software.amazon.jsii.JsiiObjectRef objRef) protectedprotectedResource(software.constructs.Construct scope, String id, ResourceProps props) -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyRemovalPolicy(RemovalPolicy policy) Apply the given removal policy to this resource.protected StringgetEnv()The environment this resource belongs to.protected StringReturns a string-encoded token that resolves to the physical name that should be passed to the CloudFormation resource.protected StringgetResourceArnAttribute(String arnAttr, ArnComponents arnComponents) Returns an environment-sensitive token that should be used for the resource's "ARN" attribute (e.g.protected StringgetResourceNameAttribute(String nameAttr) Returns an environment-sensitive token that should be used for the resource's "name" attribute (e.g.getStack()The stack in which this resource is defined.static BooleanisOwnedResource(software.constructs.IConstruct construct) Returns true if the construct was created by CDK, and false otherwise.static BooleanisResource(software.constructs.IConstruct construct) Check whether the given construct is a Resource.Methods inherited from class software.constructs.Construct
getNode, isConstruct, toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.constructs.IConstruct
getNodeMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
Resource
protected Resource(software.amazon.jsii.JsiiObjectRef objRef) -
Resource
protected Resource(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
Resource
@Stability(Stable) protected Resource(@NotNull software.constructs.Construct scope, @NotNull String id, @Nullable ResourceProps props) - Parameters:
scope- This parameter is required.id- This parameter is required.props-
-
Resource
@Stability(Stable) protected Resource(@NotNull software.constructs.Construct scope, @NotNull String id) - Parameters:
scope- This parameter is required.id- This parameter is required.
-
-
Method Details
-
isOwnedResource
@Stability(Stable) @NotNull public static Boolean isOwnedResource(@NotNull software.constructs.IConstruct construct) Returns true if the construct was created by CDK, and false otherwise.- Parameters:
construct- This parameter is required.
-
isResource
@Stability(Stable) @NotNull public static Boolean isResource(@NotNull software.constructs.IConstruct construct) Check whether the given construct is a Resource.- Parameters:
construct- This parameter is required.
-
applyRemovalPolicy
Apply the given removal policy to this resource.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).- Specified by:
applyRemovalPolicyin interfaceIResource- Parameters:
policy- This parameter is required.
-
generatePhysicalName
-
getResourceArnAttribute
@Stability(Stable) @NotNull protected String getResourceArnAttribute(@NotNull String arnAttr, @NotNull ArnComponents arnComponents) Returns an environment-sensitive token that should be used for the resource's "ARN" attribute (e.g.bucket.bucketArn).Normally, this token will resolve to
arnAttr, but if the resource is referenced across environments,arnComponentswill be used to synthesize a concrete ARN with the resource's physical name. Make sure to referencethis.physicalNameinarnComponents.- Parameters:
arnAttr- The CFN attribute which resolves to the ARN of the resource. This parameter is required.arnComponents- The format of the ARN of this resource. This parameter is required.
-
getResourceNameAttribute
Returns an environment-sensitive token that should be used for the resource's "name" attribute (e.g.bucket.bucketName).Normally, this token will resolve to
nameAttr, but if the resource is referenced across environments, it will be resolved tothis.physicalName, which will be a concrete name.- Parameters:
nameAttr- The CFN attribute which resolves to the resource's name. This parameter is required.
-
getEnv
The environment this resource belongs to.For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
-
getPhysicalName
Returns a string-encoded token that resolves to the physical name that should be passed to the CloudFormation resource.This value will resolve to one of the following:
- a concrete value (e.g.
"my-awesome-bucket") undefined, when a name should be generated by CloudFormation- a concrete name generated automatically during synthesis, in cross-environment scenarios.
- a concrete value (e.g.
-
getStack
The stack in which this resource is defined.
-