# GENERATE TEMPLATE

## Syntax <a href="#synopsis" id="synopsis"></a>

```sql
GENERATE TEMPLATE WITH (template_parameter = value [, ...]);
```

## Description

This command generates an AWS CloudFormation template for use in an AWS environment.

### Arguments <a href="#parameters" id="parameters"></a>

#### WITH (template\_parameter = value \[, …​ ])

This clause specifies [#changelog\_parameters](#changelog_parameters "mention") and any other template-specific parameters mentioned below.

### Template Parameters <a href="#changelog_parameters" id="changelog_parameters"></a>

| Parameter Name | Description                                                                                                                                                                                                                     |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `type`         | <p>Type of the CloudFormation template to generate.</p><p><strong>Required:</strong> Yes<br><strong>Valid values:</strong> <code>KAFKA\_IAM\_ROLE</code>, <code>KINESIS\_IAM\_ROLE</code>.<br><strong>Type:</strong> String</p> |

### Kafka IAM Template Parameters

| Parameter Name                              | Description                                                                                                                                                             |
| ------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `template.msk.allows.topic.prefixes.create` | <p>List of comma-separated topic prefixes to allow creating — for example, <code>'ds\_'</code></p><p><strong>Required:</strong> No<br><strong>Type:</strong> String</p> |
| `template.msk.allows.topic.prefixes.delete` | <p>List of comma-separated topic prefixes to allow deleting — for example, <code>'ds\_'</code></p><p><strong>Required:</strong> No<br><strong>Type:</strong> String</p> |
| `template.msk.allows.topic.prefixes.read`   | <p>List of comma-separated topic prefixes to allow reading — for example, <code>'my\*'</code></p><p><strong>Required:</strong> No<br><strong>Type:</strong> String</p>  |
| `template.msk.allows.topic.prefixes.write`  | <p>List of comma-separated topic prefixes to allow writing — for example, <code>'ds\_'</code></p><p><strong>Required:</strong> No<br><strong>Type:</strong> String</p>  |
| `template.msk.cluster.arn`                  | <p>The Amazon Resource Name (ARN) that uniquely identifies the MSK cluster.<br><br><strong>Required:</strong> Yes<br><strong>Type:</strong> String</p>                  |

### Kinesis IAM Template Parameters

| Parameter Name                           | Description                                                                                                                                                                                                                                |
| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `template.kinesis.allows.streams.read`   | <p>List of comma-separated name of data streams to give read access. This accepts wildcards in the names as well — for example,<code>deliveries,shipment\*</code></p><p><strong>Required:</strong> No<br><strong>Type:</strong> String</p> |
| `template.kinesis.allows.streams.write`  | <p>List of comma-separated name of data streams to give write access.</p><p><strong>Required:</strong> No<br><strong>Type:</strong> String</p>                                                                                             |
| `template.kinesis.allows.streams.create` | <p>List of comma-separated name of data streams to allow creating.</p><p><strong>Required:</strong> No<br><strong>Type:</strong> String</p>                                                                                                |
| `template.kinesis.allows.streams.delete` | <p>List of comma-separated name of data streams to allow deleting.</p><p><strong>Required:</strong> No<br><strong>Type:</strong> String</p>                                                                                                |
| `template.kinesis.allows.streams.list`   | <p>List of comma-separated name of data streams to allow deleting. Accepts wildcard as well — for example, <code>my\*</code></p><p><strong>Required:</strong> No<br><strong>Type:</strong> String</p>                                      |
| `template.kinesis.aws_account`           | <p>AWS account ID number for which the template is valid.<br><br><strong>Required:</strong> No<br><strong>Type:</strong> String</p>                                                                                                        |
| `template.kinesis.aws_region`            | <p>AWS region name for which the template is valid — for example, <code>us-east-2</code>.<br><br><strong>Required:</strong> No<br><strong>Type:</strong> String</p>                                                                        |

## Examples

#### Create a Kafka IAM role template

```sh
demodb.public/demostore# GENERATE TEMPLATE
> WITH (
> 'type' = KAFKA_IAM_ROLE,
> 'template.msk.allows.topic.prefixes.create' = 'ds_' ,
> 'template.msk.allows.topic.prefixes.delete' = 'ds_' ,
> 'template.msk.allows.topic.prefixes.read' = '*' ,
> 'template.msk.allows.topic.prefixes.write' = 'ds_' ,
> 'template.msk.cluster.arn' = 'arn:aws:kafka:us-east-1:0123456789019:cluster/SalesCluster/abcd1234-abcd-cafe-abab-9876543210ab-4' );
+------------------------------------------+
|  Template                                |
+==========================================+
| <CloudFormation template>                |
+------------------------------------------+
```

#### Create a Kinesis IAM role template

```sh
demodb.public/demostore# GENERATE TEMPLATE
> WITH (
> 'type' = KINESIS_IAM_ROLE,
> 'template.kinesis.allows.streams.read' = 'deliveries,shipment*',
> 'template.kinesis.allows.streams.write' = 'issueswrite',
> 'template.kinesis.allows.streams.create' = 'issuescreate',
> 'template.kinesis.allows.streams.delete' = 'issuesdelete',
> 'template.kinesis.allows.streams.list' = 'my*',
> 'template.kinesis.aws_account' = '854977439775',
> 'template.kinesis.aws_region' = 'us-east-2'
> );
+------------------------------------------+
|  Template                                |
+==========================================+
| <CloudFormation template>                |
+------------------------------------------+
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.deltastream.io/reference/sql-syntax/command/generate-template.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
