Linkable
Reference doc for the `sst.Linkable` component.
The Linkable
component and the Linkable.wrap
method lets you link any resources in your
app; not just the built-in SST components. It also lets you modify the links SST creates.
Linking any value
The Linkable
component takes a list of properties that you want to link. These can be
outputs from other resources or constants.
You can also use this to combine multiple resources into a single linkable resource. And optionally include permissions or bindings for the linked resource.
You can now link this resource to your frontend or a function.
Then use the SDK to access it at runtime.
Linking any resource
You can also wrap any Pulumi Resource class to make it linkable.
Now you create an instance of aws.dynamodb.Table
and link it in your app like any other SST
component.
And use the SDK to access it at runtime.
Your function will also have the permissions defined above.
Modify built-in links
You can also modify how SST creates links. For example, you might want to change the permissions of a linkable resource.
This overrides the built-in link and lets you create your own.
Constructor
Parameters
-
name
string
-
definition
Definition
Properties
name
Type Output
<
string
>
properties
Type Record
<
string
, any
>
Methods
static wrap
Parameters
The resource class to wrap.cls
Constructor
A callback that returns the definition for the linkable resource.cb
(resource:
Resource
) =>Definition
Returns void
Wrap any resource class to make it linkable. Behind the scenes this modifies the prototype of the given class.
Here we are wrapping the aws.dynamodb.Table
class to make it linkable.
It’s defining the properties that we want made accessible at runtime and the permissions that the linked resource should have.
Now you can link any aws.dynamodb.Table
instances in your app just like any other SST
component.
Since this applies to any resource, you can also use it to wrap SST components and modify how they are linked.
This overrides the built-in link and lets you create your own.
In the above example, we’re modifying the permissions to access a linked sst.aws.Bucket
in our app.
Definition
include?
Type (
sst.aws.permission
|
sst.cloudflare.binding
)[]
Include AWS permissions or Cloudflare bindings for the linkable resource. The linked resource will have these permissions or bindings.
Include AWS permissions.
Include Cloudflare bindings.
properties
Type Record
<
string
, any
>
Define values that the linked resource can access at runtime. These can be outputs from other resources or constants.