# SubscriptionProperty

Subscriptions define how MQTT messages can be exchanged between devices, functions, and connectors in the group, and with AWS IoT or the local shadow service.

A subscription defines a message source, message target, and a topic (or subject) that's used to route messages from the source to the target. A subscription defines the message flow in one direction, from the source to the target. For two-way communication, you must set up two subscriptions, one for each direction.

In an CloudFormation template, the `Subscriptions` property of the [`AWS::Greengrass::SubscriptionDefinitionVersion`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-greengrass-subscriptiondefinitionversion.html) resource contains a list of `Subscription` property types.

- Source: Generated at build time
- Type last changed: v2.93.0 · 23 Aug 2023

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_greengrass as greengrass } from 'aws-cdk-lib';
const subscriptionProperty: greengrass.CfnSubscriptionDefinitionVersion.SubscriptionProperty = {
  id: 'id',
  source: 'source',
  subject: 'subject',
  target: 'target',
};
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_greengrass as greengrass

subscription_property = greengrass.CfnSubscriptionDefinitionVersion.SubscriptionProperty(
    id="id",
    source="source",
    subject="subject",
    target="target"
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.greengrass.*;

SubscriptionProperty subscriptionProperty = SubscriptionProperty.builder()
        .id("id")
        .source("source")
        .subject("subject")
        .target("target")
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Greengrass;

var subscriptionProperty = new SubscriptionProperty {
    Id = "id",
    Source = "source",
    Subject = "subject",
    Target = "target"
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

subscriptionProperty := &SubscriptionProperty{
	Id: jsii.String("id"),
	Source: jsii.String("source"),
	Subject: jsii.String("subject"),
	Target: jsii.String("target"),
}
```

## Properties

- `id`: string (required) — A descriptive or arbitrary ID for the subscription.

  This value must be unique within the subscription definition version. Maximum length is 128 characters with pattern `[a-zA-Z0-9:_-]+` .

- `source`: string (required) — The originator of the message.

  The value can be a thing ARN, the ARN of a Lambda function alias (recommended) or version, a connector ARN, `cloud` (which represents the AWS IoT cloud), or `GGShadowService` .

- `subject`: string (required) — The MQTT topic used to route the message.

- `target`: string (required) — The destination of the message.

  The value can be a thing ARN, the ARN of a Lambda function alias (recommended) or version, a connector ARN, `cloud` (which represents the AWS IoT cloud), or `GGShadowService` .
