class Resource
Language | Type name |
---|---|
![]() | Amazon.CDK.Resource |
![]() | github.com/aws/aws-cdk-go/awscdk/v2#Resource |
![]() | software.amazon.awscdk.Resource |
![]() | aws_cdk.Resource |
![]() | aws-cdk-lib » Resource |
Implements
IConstruct
, IDependable
, IResource
Extends
Construct
Implemented by
App
, Branch
, Domain
, Auto
, Observability
, Service
, Vpc
, Vpc
, Api
, Base
, Cognito
, Deployment
, Domain
, Gateway
, Lambda
, Method
, Model
, Proxy
, Rate
, Request
, Request
, Resource
, Rest
, Spec
, Stage
, Step
, Token
, Usage
, Vpc
, Api
, Domain
, Http
, Http
, Http
, Http
, Http
, Vpc
, Web
, Web
, Web
, Web
, Web
, Application
, Deployment
, Environment
, Extension
, Scalable
, Gateway
, Mesh
, Route
, Virtual
, Virtual
, Virtual
, Virtual
, Appsync
, Channel
, Event
, Graphql
, Source
, Auto
, Lifecycle
, Scheduled
, Warm
, Backup
, Backup
, Backup
, Ecs
, Eks
, Fairshare
, Fargate
, Job
, Managed
, Managed
, Multi
, Unmanaged
, Certificate
, Dns
, Private
, Slack
, Edge
, Cache
, Cloud
, Distribution
, Function
, Function
, Key
, Key
, Origin
, Origin
, Public
, Realtime
, Response
, S3
, Vpc
, Trail
, Alarm
, Composite
, Dashboard
, Bit
, Fleet
, Git
, Git
, Pipeline
, Project
, Report
, Untrusted
, Repository
, Custom
, Ecs
, Ecs
, Ecs
, Lambda
, Lambda
, Lambda
, Server
, Server
, Server
, Profiling
, Pipeline
, Notification
, User
, User
, User
, User
, User
, User
, User
, User
, User
, User
, User
, Access
, Cloud
, Cloud
, Custom
, Custom
, Managed
, Cluster
, Database
, Database
, Database
, Table
, Table
, Bastion
, Client
, Client
, Client
, Flow
, Gateway
, Instance
, Interface
, Key
, Launch
, Network
, Network
, Placement
, Prefix
, Private
, Public
, Security
, Subnet
, Subnet
, Volume
, Vpc
, Vpc
, Vpn
, Vpn
, Repository
, Cluster
, Ec2
, Ec2
, External
, External
, Fargate
, Fargate
, Task
, Access
, File
, Access
, Addon
, Cluster
, Fargate
, Nodegroup
, Open
, Load
, Application
, Application
, Network
, Network
, Trust
, Trust
, Domain
, Api
, Archive
, Connection
, Event
, Event
, Rule
, Lustre
, Accelerator
, Endpoint
, Listener
, Access
, Group
, Instance
, Lazy
, Managed
, Open
, Policy
, Role
, Saml
, User
, Assessment
, Resource
, Stream
, Stream
, Delivery
, Alias
, Key
, Alias
, Code
, Docker
, Event
, Event
, Function
, Function
, Layer
, Singleton
, Version
, Nodejs
, Cross
, Log
, Log
, Metric
, Query
, Resource
, Subscription
, Domain
, Database
, Database
, Database
, Database
, Database
, Database
, Database
, Option
, Parameter
, Serverless
, Serverless
, Subnet
, ARecord
, Aaaa
, Caa
, Caa
, Cname
, Ds
, Health
, Hosted
, Key
, Mx
, Ns
, Private
, Public
, Record
, Srv
, Txt
, Zone
, Bucket
, Bucket
, Resource
, Rotation
, Secret
, Secret
, Cloud
, Portfolio
, Tag
, Alias
, Cname
, Http
, Ip
, Non
, Private
, Public
, Service
, Configuration
, Configuration
, Dedicated
, Email
, Receipt
, Receipt
, Receipt
, Vdm
, Signing
, Subscription
, Topic
, Topic
, Queue
, Queue
, String
, String
, Activity
, State
, Canary
, Aws
, Node
, Trigger
, Custom
, Ec2
, Git
, Identity
, Egress
, Internet
, Ipam
, Nat
, Route
, Route
, Subnet
, Transit
, Transit
, Transit
, Transit
, Transit
, Transit
, Transit
, VPCPeering
, VPNGateway
, Vpc
, Access
, Addon
, Cluster
, Fargate
, Nodegroup
, Open
, Alias
, Build
, Build
, Game
, Game
, Matchmaking
, Queued
, Script
, Standalone
, Connection
, Data
, Database
, External
, Py
, Py
, Py
, Python
, Ray
, S3
, Scala
, Scala
, Scala
, Security
, Table
, Workflow
, Account
, Logging
, Scheduled
, Topic
, Detector
, Input
, Channel
, Playback
, Recording
, Stream
, Application
, Delivery
, Go
, Python
, Python
, Geofence
, Map
, Place
, Route
, Tracker
, Cluster
, Serverless
, Cluster
, Database
, Database
, Parameter
, Subnet
, Pipe
, Cluster
, Cluster
, Cluster
, Database
, Firewall
, Firewall
, Firewall
, Access
, Endpoint
, Endpoint
, Model
, Group
, Schedule
, Schedule
, Application
, Attribute
A construct which represents an AWS resource.
Example
class MyConstruct extends Resource implements ITaggable {
public readonly tags = new TagManager(TagType.KEY_VALUE, 'Whatever::The::Type');
constructor(scope: Construct, id: string) {
super(scope, id);
new CfnResource(this, 'Resource', {
type: 'Whatever::The::Type',
properties: {
// ...
Tags: this.tags.renderedTags,
},
});
}
}
Initializer
new Resource(scope: Construct, id: string, props?: ResourceProps)
Parameters
- scope
Construct
- id
string
- props
Resource
Props
Properties
Name | Type | Description |
---|---|---|
env | Resource | The environment this resource belongs to. |
node | Node | The tree node. |
physical | string | Returns a string-encoded token that resolves to the physical name that should be passed to the CloudFormation resource. |
stack | Stack | The stack in which this resource is defined. |
env
Type:
Resource
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.
node
Type:
Node
The tree node.
physicalName
Type:
string
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.
stack
Type:
Stack
The stack in which this resource is defined.
Methods
Name | Description |
---|---|
apply | Apply the given removal policy to this resource. |
to | Returns a string representation of this construct. |
protected generate | |
protected get | Returns an environment-sensitive token that should be used for the resource's "ARN" attribute (e.g. bucket.bucketArn ). |
protected get | Returns an environment-sensitive token that should be used for the resource's "name" attribute (e.g. bucket.bucketName ). |
static is | Returns true if the construct was created by CDK, and false otherwise. |
static is | Check whether the given construct is a Resource. |
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
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
).
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
protected generatePhysicalName()
protected generatePhysicalName(): string
Returns
string
protected getResourceArnAttribute(arnAttr, arnComponents)
protected getResourceArnAttribute(arnAttr: string, arnComponents: ArnComponents): string
Parameters
- arnAttr
string
— The CFN attribute which resolves to the ARN of the resource. - arnComponents
Arn
— The format of the ARN of this resource.Components
Returns
string
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 reference
this.physicalName
in arnComponents
.
protected getResourceNameAttribute(nameAttr)
protected getResourceNameAttribute(nameAttr: string): string
Parameters
- nameAttr
string
— The CFN attribute which resolves to the resource's name.
Returns
string
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 to this.physicalName
,
which will be a concrete name.
static isOwnedResource(construct)
public static isOwnedResource(construct: IConstruct): boolean
Parameters
- construct
IConstruct
Returns
boolean
Returns true if the construct was created by CDK, and false otherwise.
static isResource(construct)
public static isResource(construct: IConstruct): boolean
Parameters
- construct
IConstruct
Returns
boolean
Check whether the given construct is a Resource.