Class Resource
- All Implemented Interfaces:
IResource
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
,software.constructs.IDependable
- Direct Known Subclasses:
Accelerator
,AccessEntry
,AccessKey
,AccessPoint
,AccessPoint
,AccountAuditConfiguration
,Activity
,Addon
,AlarmBase
,Alias
,AliasBase
,ApiDestination
,ApiKey
,ApiMapping
,App
,Application
,Application
,Application
,AppsyncFunction
,Archive
,AttributeGroup
,Authorizer
,AutoScalingConfiguration
,AutoScalingGroup
,BackupPlan
,BackupSelection
,BackupVault
,BaseDeploymentConfig
,BaseListener
,BaseLoadBalancer
,BasePathMapping
,BaseService
,BastionHostLinux
,BitBucketSourceCredentials
,Branch
,BucketBase
,BucketPolicy
,BuildBase
,CachePolicy
,Canary
,Certificate
,Channel
,ClientVpnAuthorizationRule
,ClientVpnEndpoint
,ClientVpnRoute
,CloudFrontWebDistribution
,Cluster
,Cluster
,Cluster
,Cluster
,ClusterParameterGroup
,ClusterParameterGroup
,ClusterParameterGroup
,ClusterSubnetGroup
,CodeSigningConfig
,ConfigurationSet
,ConfigurationSetEventDestination
,Connection
,Connection
,CrossAccountDestination
,CustomLambdaDeploymentConfig
,CustomPolicy
,CustomResource
,CustomRule
,Dashboard
,Database
,DatabaseCluster
,DatabaseClusterBase
,DatabaseClusterBase
,DatabaseInstance
,DatabaseInstanceBase
,DatabaseInstanceBase
,DatabaseProxy
,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
,Group
,HealthCheck
,HostedZone
,HttpApi
,HttpAuthorizer
,HttpIntegration
,HttpNamespace
,HttpRoute
,HttpStage
,IdentityPool
,IdentityPoolRoleAttachment
,Input
,Instance
,InstanceBase
,InstanceProfile
,InternetGateway
,Ipam
,Job
,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
,NatGateway
,NetworkAcl
,NetworkAclEntry
,Nodegroup
,NotificationRule
,ObservabilityConfiguration
,OpenIdConnectProvider
,OptionGroup
,OriginAccessIdentity
,OriginRequestPolicy
,ParameterGroup
,ParameterGroup
,Pipe
,Pipeline
,PlaceIndex
,PlacementGroup
,PlaybackKeyPair
,Policy
,Portfolio
,PrefixList
,PrivateCertificate
,PrivateDnsNamespace
,Product
,ProfilingGroup
,Project
,PublicDnsNamespace
,PublicKey
,QueryDefinition
,QueueBase
,QueuePolicy
,RateLimitedApiKey
,RealtimeLogConfig
,ReceiptFilter
,ReceiptRule
,ReceiptRuleSet
,RecordingConfiguration
,RecordSet
,ReportGroup
,Repository
,RepositoryBase
,RequestValidator
,ResourceBase
,ResourcePolicy
,ResourcePolicy
,ResourcePolicy
,ResponseHeadersPolicy
,RestApiBase
,Role
,RotationSchedule
,Route
,Route
,RouteCalculator
,RouteTable
,Rule
,S3OriginAccessControl
,SamlProvider
,ScalableTarget
,Schedule
,ScheduledAction
,ScheduledAudit
,ScriptBase
,Secret
,SecretTargetAttachment
,SecurityConfiguration
,SecurityGroup
,ServerApplication
,ServerDeploymentGroup
,ServerlessCluster
,ServerlessClusterFromSnapshot
,Service
,Service
,SigningProfile
,SlackChannelConfiguration
,SourceApiAssociation
,StageBase
,StateMachine
,Stream
,StreamKey
,StringListParameter
,StringParameter
,Subnet
,SubnetGroup
,SubnetGroup
,SubnetNetworkAclAssociation
,SubnetV2
,Subscription
,SubscriptionFilter
,TableBase
,TableBase
,TableBaseV2
,TagOptions
,TaskDefinition
,TopicBase
,TopicPolicy
,TopicRule
,Tracker
,Trail
,TrustStore
,TrustStoreRevocation
,UnmanagedComputeEnvironment
,UsagePlan
,User
,UserPool
,UserPoolClient
,UserPoolDomain
,UserPoolGroup
,UserPoolIdentityProviderAmazon
,UserPoolIdentityProviderApple
,UserPoolIdentityProviderFacebook
,UserPoolIdentityProviderGoogle
,UserPoolIdentityProviderOidc
,UserPoolIdentityProviderSaml
,UserPoolResourceServer
,VdmAttributes
,VirtualGateway
,VirtualNode
,VirtualRouter
,VirtualService
,Volume
,Vpc
,VpcConnector
,VpcEndpoint
,VpcEndpointService
,VpcIngressConnection
,VpcLink
,VpcLink
,VPCPeeringConnection
,VpcV2Base
,VpnConnectionBase
,VpnGateway
,VPNGatewayV2
,WarmPool
,WebSocketApi
,WebSocketAuthorizer
,WebSocketIntegration
,WebSocketRoute
,WebSocketStage
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.InitializationMode
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.IResource
IResource.Jsii$Default
-
Constructor Summary
ModifierConstructorDescriptionprotected
Resource
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
Resource
(software.amazon.jsii.JsiiObjectRef objRef) protected
protected
Resource
(software.constructs.Construct scope, String id, ResourceProps props) -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyRemovalPolicy
(RemovalPolicy policy) Apply the given removal policy to this resource.protected String
getEnv()
The environment this resource belongs to.protected String
Returns a string-encoded token that resolves to the physical name that should be passed to the CloudFormation resource.protected String
getResourceArnAttribute
(String arnAttr, ArnComponents arnComponents) Returns an environment-sensitive token that should be used for the resource's "ARN" attribute (e.g.protected String
getResourceNameAttribute
(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 Boolean
isOwnedResource
(software.constructs.IConstruct construct) Returns true if the construct was created by CDK, and false otherwise.static Boolean
isResource
(software.constructs.IConstruct construct) Check whether the given construct is a Resource.Methods inherited from class software.constructs.Construct
getNode, isConstruct, toString
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.constructs.IConstruct
getNode
Methods 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:
applyRemovalPolicy
in 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,arnComponents
will be used to synthesize a concrete ARN with the resource's physical name. Make sure to referencethis.physicalName
inarnComponents
.- 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.
-