

This is the new *CloudFormation Template Reference Guide*. Please update your bookmarks and links. For help getting started with CloudFormation, see the [AWS CloudFormation User Guide](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html).

# AWS::IoT::Logging
<a name="aws-resource-iot-logging"></a>

Configure logging.

**Note**  
If you already set the log function of AWS IoT Core, you can't deploy the AWS Cloud Development Kit (AWS CDK) to change the logging settings. You can change the logging settings by either:  
Importing the existing logging resource into your CloudFormation stack, such as with the [infrastructure as code generator (IaC generator)](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/generate-IaC.html).
Calling `aws iot set-v2-logging-options --disable-all-logs` before creating a new CloudFormation stack. This command disables all AWS IoT logging. As a result, no AWS IoT logs will be delivered to Amazon CloudWatch until you re-enable logging.

## Syntax
<a name="aws-resource-iot-logging-syntax"></a>

To declare this entity in your CloudFormation template, use the following syntax:

### JSON
<a name="aws-resource-iot-logging-syntax.json"></a>

```
{
  "Type" : "AWS::IoT::Logging",
  "Properties" : {
      "[AccountId](#cfn-iot-logging-accountid)" : String,
      "[DefaultLogLevel](#cfn-iot-logging-defaultloglevel)" : String,
      "[EventConfigurations](#cfn-iot-logging-eventconfigurations)" : [ EventConfiguration, ... ],
      "[RoleArn](#cfn-iot-logging-rolearn)" : String
    }
}
```

### YAML
<a name="aws-resource-iot-logging-syntax.yaml"></a>

```
Type: AWS::IoT::Logging
Properties:
  [AccountId](#cfn-iot-logging-accountid): String
  [DefaultLogLevel](#cfn-iot-logging-defaultloglevel): String
  [EventConfigurations](#cfn-iot-logging-eventconfigurations): 
    - EventConfiguration
  [RoleArn](#cfn-iot-logging-rolearn): String
```

## Properties
<a name="aws-resource-iot-logging-properties"></a>

`AccountId`  <a name="cfn-iot-logging-accountid"></a>
The account ID.  
*Required*: Yes  
*Type*: String  
*Pattern*: `^[0-9]{12}$`  
*Minimum*: `12`  
*Maximum*: `12`  
*Update requires*: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)

`DefaultLogLevel`  <a name="cfn-iot-logging-defaultloglevel"></a>
The default log level. Valid Values: `DEBUG | INFO | ERROR | WARN | DISABLED`  
*Required*: Yes  
*Type*: String  
*Allowed values*: `ERROR | WARN | INFO | DEBUG | DISABLED`  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`EventConfigurations`  <a name="cfn-iot-logging-eventconfigurations"></a>
Configurations for event-based logging that specifies which event types to log and their logging settings. Overrides account-level logging for the specified event.  
*Required*: No  
*Type*: Array of [EventConfiguration](aws-properties-iot-logging-eventconfiguration.md)  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`RoleArn`  <a name="cfn-iot-logging-rolearn"></a>
The role ARN used for the log.  
*Required*: Yes  
*Type*: String  
*Minimum*: `20`  
*Maximum*: `2048`  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

## Return values
<a name="aws-resource-iot-logging-return-values"></a>

### Ref
<a name="aws-resource-iot-logging-return-values-ref"></a>

When you pass the logical ID of this resource to the intrinsic `Ref` function, `Ref` returns the log ID. For example:

 `{"Ref": "Log-12345"}` 

# AWS::IoT::Logging EventConfiguration
<a name="aws-properties-iot-logging-eventconfiguration"></a>

Configuration for event-based logging that specifies which event types to log and their logging settings. Used for account-level logging overrides.

## Syntax
<a name="aws-properties-iot-logging-eventconfiguration-syntax"></a>

To declare this entity in your CloudFormation template, use the following syntax:

### JSON
<a name="aws-properties-iot-logging-eventconfiguration-syntax.json"></a>

```
{
  "[EventType](#cfn-iot-logging-eventconfiguration-eventtype)" : String,
  "[LogDestination](#cfn-iot-logging-eventconfiguration-logdestination)" : String,
  "[LogLevel](#cfn-iot-logging-eventconfiguration-loglevel)" : String
}
```

### YAML
<a name="aws-properties-iot-logging-eventconfiguration-syntax.yaml"></a>

```
  [EventType](#cfn-iot-logging-eventconfiguration-eventtype): String
  [LogDestination](#cfn-iot-logging-eventconfiguration-logdestination): String
  [LogLevel](#cfn-iot-logging-eventconfiguration-loglevel): String
```

## Properties
<a name="aws-properties-iot-logging-eventconfiguration-properties"></a>

`EventType`  <a name="cfn-iot-logging-eventconfiguration-eventtype"></a>
The type of event to log. These include event types like Connect, Publish, and Disconnect.  
*Required*: Yes  
*Type*: String  
*Minimum*: `1`  
*Maximum*: `512`  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`LogDestination`  <a name="cfn-iot-logging-eventconfiguration-logdestination"></a>
CloudWatch Log Group for event-based logging. Specifies where log events should be sent. The log destination for event-based logging overrides default Log Group for the specified event type and applies to all resources associated with that event.  
*Required*: No  
*Type*: String  
*Pattern*: `^(?!aws/)[a-zA-Z0-9_\-/.#]+$`  
*Minimum*: `1`  
*Maximum*: `512`  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`LogLevel`  <a name="cfn-iot-logging-eventconfiguration-loglevel"></a>
The logging level for the specified event type. Determines the verbosity of log messages generated for this event type. Valid Values: `ERROR | WARN | INFO | DEBUG | DISABLED`  
*Required*: No  
*Type*: String  
*Allowed values*: `ERROR | WARN | INFO | DEBUG | DISABLED`  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)