Show / Hide Table of Contents

Class Resource

A construct which represents an AWS resource.

Inheritance
object
Resource
ApiKey
Authorizer
BasePathMapping
Deployment
DomainName_
GatewayResponse
Method
Model
RateLimitedApiKey
RequestValidator
ResourceBase
RestApiBase
StageBase
UsagePlan
VpcLink
App
Branch
Domain
ApiMapping
DomainName
HttpApi
HttpAuthorizer
HttpIntegration
HttpRoute
HttpStage
VpcLink
WebSocketApi
WebSocketAuthorizer
WebSocketIntegration
WebSocketRoute
WebSocketStage
Application
DeploymentStrategy
Environment
Extension
GatewayRoute
Mesh
Route
VirtualGateway
VirtualNode
VirtualRouter
VirtualService
AutoScalingConfiguration
ObservabilityConfiguration
Service
VpcConnector
VpcIngressConnection
ApiBase
AppsyncFunction
ChannelNamespace
GraphqlApiBase
SourceApiAssociation
ScalableTarget
AutoScalingGroup
LifecycleHook
ScheduledAction
WarmPool
BackupPlan
BackupSelection
BackupVault
EcsJobDefinition
EksJobDefinition
FairshareSchedulingPolicy
FargateComputeEnvironment
JobQueue
ManagedEc2EcsComputeEnvironment
ManagedEc2EksComputeEnvironment
MultiNodeJobDefinition
UnmanagedComputeEnvironment
AgentAliasBase
AgentBase
Certificate
DnsValidatedCertificate
PrivateCertificate
SlackChannelConfiguration
Ec2Environment
CachePolicy
CloudFrontWebDistribution
Distribution
EdgeFunction
Function
FunctionUrlOriginAccessControl
KeyGroup
KeyValueStore
OriginAccessIdentity
OriginRequestPolicy
PublicKey
RealtimeLogConfig
ResponseHeadersPolicy
S3OriginAccessControl
VpcOrigin
Trail
AlarmBase
Dashboard
BitBucketSourceCredentials
Fleet
GitHubEnterpriseSourceCredentials
GitHubSourceCredentials
Project
ReportGroup
Repository
BaseDeploymentConfig
CustomLambdaDeploymentConfig
EcsApplication
EcsDeploymentGroup
LambdaApplication
LambdaDeploymentGroup
ServerApplication
ServerDeploymentGroup
ProfilingGroup
Pipeline
NotificationRule
GitHubRepository
IdentityPool
UserPool
UserPoolClient
UserPoolDomain
UserPoolGroup
UserPoolIdentityProviderAmazon
UserPoolIdentityProviderApple
UserPoolIdentityProviderFacebook
UserPoolIdentityProviderGoogle
UserPoolIdentityProviderOidc
UserPoolIdentityProviderSaml
UserPoolResourceServer
CustomPolicy
CustomRule
ManagedRule
ClusterParameterGroup
DatabaseCluster
DatabaseInstance
TableBase
TableBaseV2
BastionHostLinux
ClientVpnAuthorizationRule
ClientVpnEndpoint
ClientVpnRoute
FlowLog
Instance_
KeyPair
LaunchTemplate
NetworkAcl
NetworkAclEntry
PlacementGroup
PrefixList
SecurityGroup
Subnet
SubnetNetworkAclAssociation
Volume
Vpc
VpcEndpoint
VpcEndpointService
VpnConnectionBase
VpnGateway
RepositoryBase
BaseService
Cluster
TaskDefinition
AccessPoint
FileSystem
AccessEntry
Addon
Cluster
Nodegroup
AccessEntry
Addon
Cluster
Nodegroup
LoadBalancer
BaseListener
BaseLoadBalancer
TrustStore
TrustStoreRevocation
Domain
ApiDestination
Archive
Connection
EventBus
EventBusPolicy
Rule
FileSystemBase
AliasBase
BuildBase
FleetBase
GameServerGroupBase
GameSessionQueueBase
MatchmakingConfigurationBase
MatchmakingRuleSetBase
ScriptBase
Accelerator
EndpointGroup
Listener
Connection
DataQualityRuleset
Database
JobBase
SecurityConfiguration
TableBase
WorkflowBase
AccessKey
Group
InstanceProfile
LazyRole
ManagedPolicy
OidcProviderNative
OpenIdConnectProvider
Policy
Role
SamlProvider
User
AssessmentTemplate
AccountAuditConfiguration
Logging
ScheduledAudit
TopicRule
DetectorModel
Input
Channel
PlaybackKeyPair
RecordingConfiguration
StreamKey
Alias
Key
ResourcePolicy
Stream
StreamConsumer
DeliveryStream
Application
CodeSigningConfig
EventInvokeConfig
EventSourceMapping
FunctionBase
FunctionUrl
LayerVersion
ApiKey
GeofenceCollection
Map
PlaceIndex
RouteCalculator
Tracker
CrossAccountDestination
LogGroup
LogStream
MetricFilter
QueryDefinition
ResourcePolicy
SubscriptionFilter
ClusterBase
ClusterParameterGroup
DatabaseClusterBase
DatabaseInstanceBase
ParameterGroup
SubnetGroup
Domain
Pipe
DatabaseClusterBase
DatabaseInstanceBase
DatabaseProxy
OptionGroup
ParameterGroup
ServerlessCluster
ServerlessClusterFromSnapshot
SubnetGroup
Cluster
ClusterParameterGroup
ClusterSubnetGroup
HealthCheck
HostedZone
KeySigningKey
RecordSet
FirewallDomainList
FirewallRuleGroup
FirewallRuleGroupAssociation
BucketBase
BucketPolicy
AccessPoint
TableBucket
TableBucketPolicy
ConfigurationSet
ConfigurationSetEventDestination
DedicatedIpPool
EmailIdentity
ReceiptFilter
ReceiptRule
ReceiptRuleSet
VdmAttributes
Subscription
TopicBase
TopicPolicy
QueueBase
QueuePolicy
StringListParameter
StringParameter
Endpoint
EndpointConfig
Model
Schedule
ScheduleGroup
ResourcePolicy
RotationSchedule
Secret
SecretTargetAttachment
HttpNamespace
InstanceBase
PrivateDnsNamespace
PublicDnsNamespace
Service
Portfolio
Product
TagOptions
Application
AttributeGroup
SigningProfile
Activity
StateMachine
Canary
EgressOnlyInternetGateway
InternetGateway
Ipam
NatGateway
Route
RouteTable
SubnetV2
TransitGateway
TransitGatewayBlackholeRoute
TransitGatewayRoute
TransitGatewayRouteTable
TransitGatewayRouteTableAssociation
TransitGatewayRouteTablePropagation
TransitGatewayVpcAttachment
VPCPeeringConnection
VPNGatewayV2
VpcV2Base
CustomResource
Implements
IResource
IConstruct
IDependable
Namespace: Amazon.CDK
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public abstract class Resource : Construct, IResource, IConstruct, IDependable
Syntax (vb)
Public MustInherit Class Resource Inherits Construct Implements IResource, IConstruct, IDependable
Remarks

ExampleMetadata: infused

Examples
class MyConstruct : Resource, ITaggable
            {
                public readonly void Tags = new TagManager(TagType.KEY_VALUE, "Whatever::The::Type");

                public MyConstruct(Construct scope, string id) : base(scope, id)
                {

                    new CfnResource(this, "Resource", new CfnResourceProps {
                        Type = "Whatever::The::Type",
                        Properties = new Dictionary<string, object> {
                            // ...
                            { "Tags", Tags.RenderedTags }
                        }
                    });
                }
            }

Synopsis

Constructors

Resource(Construct, string, IResourceProps?)

A construct which represents an AWS resource.

Properties

Env

The environment this resource belongs to.

PhysicalName

Returns a string-encoded token that resolves to the physical name that should be passed to the CloudFormation resource.

Stack

The stack in which this resource is defined.

Methods

ApplyRemovalPolicy(RemovalPolicy)

Apply the given removal policy to this resource.

GeneratePhysicalName()

A construct which represents an AWS resource.

GetResourceArnAttribute(string, IArnComponents)

Returns an environment-sensitive token that should be used for the resource's "ARN" attribute (e.g. bucket.bucketArn).

GetResourceNameAttribute(string)

Returns an environment-sensitive token that should be used for the resource's "name" attribute (e.g. bucket.bucketName).

IsOwnedResource(IConstruct)

Returns true if the construct was created by CDK, and false otherwise.

IsResource(IConstruct)

Check whether the given construct is a Resource.

Constructors

Resource(Construct, string, IResourceProps?)

A construct which represents an AWS resource.

protected Resource(Construct scope, string id, IResourceProps? props = null)
Parameters
scope Construct
id string
props IResourceProps
Remarks

ExampleMetadata: infused

Examples
class MyConstruct : Resource, ITaggable
            {
                public readonly void Tags = new TagManager(TagType.KEY_VALUE, "Whatever::The::Type");

                public MyConstruct(Construct scope, string id) : base(scope, id)
                {

                    new CfnResource(this, "Resource", new CfnResourceProps {
                        Type = "Whatever::The::Type",
                        Properties = new Dictionary<string, object> {
                            // ...
                            { "Tags", Tags.RenderedTags }
                        }
                    });
                }
            }

Properties

Env

The environment this resource belongs to.

public virtual IResourceEnvironment Env { get; }
Property Value

IResourceEnvironment

Remarks

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.

PhysicalName

Returns a string-encoded token that resolves to the physical name that should be passed to the CloudFormation resource.

protected virtual string PhysicalName { get; }
Property Value

string

Remarks

This value will resolve to one of the following:

    Stack

    The stack in which this resource is defined.

    public virtual Stack Stack { get; }
    Property Value

    Stack

    Remarks

    ExampleMetadata: infused

    Methods

    ApplyRemovalPolicy(RemovalPolicy)

    Apply the given removal policy to this resource.

    public virtual void ApplyRemovalPolicy(RemovalPolicy policy)
    Parameters
    policy RemovalPolicy
    Remarks

    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).

    GeneratePhysicalName()

    A construct which represents an AWS resource.

    protected virtual string GeneratePhysicalName()
    Returns

    string

    Remarks

    ExampleMetadata: infused

    Examples
    class MyConstruct : Resource, ITaggable
                {
                    public readonly void Tags = new TagManager(TagType.KEY_VALUE, "Whatever::The::Type");
    
                    public MyConstruct(Construct scope, string id) : base(scope, id)
                    {
    
                        new CfnResource(this, "Resource", new CfnResourceProps {
                            Type = "Whatever::The::Type",
                            Properties = new Dictionary<string, object> {
                                // ...
                                { "Tags", Tags.RenderedTags }
                            }
                        });
                    }
                }

    GetResourceArnAttribute(string, IArnComponents)

    Returns an environment-sensitive token that should be used for the resource's "ARN" attribute (e.g. bucket.bucketArn).

    protected virtual string GetResourceArnAttribute(string arnAttr, IArnComponents arnComponents)
    Parameters
    arnAttr string

    The CFN attribute which resolves to the ARN of the resource.

    arnComponents IArnComponents

    The format of the ARN of this resource.

    Returns

    string

    Remarks

    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.

    GetResourceNameAttribute(string)

    Returns an environment-sensitive token that should be used for the resource's "name" attribute (e.g. bucket.bucketName).

    protected virtual string GetResourceNameAttribute(string nameAttr)
    Parameters
    nameAttr string

    The CFN attribute which resolves to the resource's name.

    Returns

    string

    Remarks

    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.

    IsOwnedResource(IConstruct)

    Returns true if the construct was created by CDK, and false otherwise.

    public static bool IsOwnedResource(IConstruct construct)
    Parameters
    construct IConstruct
    Returns

    bool

    Remarks

    ExampleMetadata: infused

    IsResource(IConstruct)

    Check whether the given construct is a Resource.

    public static bool IsResource(IConstruct construct)
    Parameters
    construct IConstruct
    Returns

    bool

    Remarks

    ExampleMetadata: infused

    Implements

    IResource
    Constructs.IConstruct
    Constructs.IDependable
    Back to top Generated by DocFX