# TopicGrants

Collection of grant methods for a ITopicRef.

Obtainable from: TopicGrants.fromTopic

- Source: Generated at build time
- Type last changed: v2.244.0 · 19 Mar 2026

## Example

TypeScript:

```ts
const topic = new sns.Topic(this, 'Topic');

// This would work the same way if topic was a CfnTopic (L1)
sns.TopicGrants.fromTopic(topic).subscribe(new iam.AnyPrincipal());
```

Python:

```python
topic = sns.Topic(self, "Topic")

# This would work the same way if topic was a CfnTopic (L1)
sns.TopicGrants.from_topic(topic).subscribe(iam.AnyPrincipal())
```

Java:

```java
Topic topic = new Topic(this, "Topic");

// This would work the same way if topic was a CfnTopic (L1)
TopicGrants.fromTopic(topic).subscribe(new AnyPrincipal());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var topic = new Topic(this, "Topic");

// This would work the same way if topic was a CfnTopic (L1)
TopicGrants.FromTopic(topic).Subscribe(new AnyPrincipal());
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
topic := sns.NewTopic(this, jsii.String("Topic"))

// This would work the same way if topic was a CfnTopic (L1)
sns.TopicGrants_FromTopic(topic).Subscribe(iam.NewAnyPrincipal())
```

## Methods

- `actions(grantee: IGrantable, actions: string[], options?: EncryptedPermissionsOptions): Grant` — Grant the given identity custom permissions.

- `fromTopic(resource: ITopicRef): TopicGrants // chainable` (static) — Creates grants for TopicGrants.

- `publish(grantee: IGrantable): Grant` — Grant topic publishing permissions to the given identity.

- `subscribe(grantee: IGrantable): Grant` — Grant topic subscribing permissions to the given identity.
