AWS::Logs::LogGroup
The AWS::Logs::LogGroup resource creates an Amazon CloudWatch Logs log group that defines
common properties for log streams, such as their retention and access control rules.
Each log
stream must belong to one log group.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::Logs::LogGroup", "Properties" : { "LogGroupName" :String, "RetentionInDays" :Integer} }
YAML
Type: AWS::Logs::LogGroup Properties: LogGroupName:StringRetentionInDays:Integer
Properties
LogGroupName-
A name for the log group. If you don't specify a name, AWS CloudFormation generates a unique physical ID and uses that ID for the log group. For more information, see Name Type.
Important
If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name.
Required: No
Type: String
Update requires: Replacement
RetentionInDays-
The number of days log events are kept in CloudWatch Logs. When a log event expires, CloudWatch Logs automatically deletes it. For valid values, see PutRetentionPolicy in the Amazon CloudWatch Logs API Reference.
Required: No
Type: Integer
Update requires: No interruption
Return Values
Ref
When the logical ID of this resource is provided to the Ref intrinsic
function, Ref returns the resource name.
For more information about using the Ref function, see Ref.
Fn::GetAtt
Fn::GetAtt returns a value for a specified attribute of this type.
The following are the available attributes and sample return values.
Arn-
The Amazon resource name (ARN) of the CloudWatch Logs log group, such as
arn:aws:logs:us-east-1:123456789012:log-group:/mystack-testgroup-12ABC1AB12A1:*.
For more information about using Fn::GetAtt, see Fn::GetAtt.
Examples
The following example creates a CloudWatch Logs log group that retains events for 7 days.
JSON
"myLogGroup": { "Type": "AWS::Logs::LogGroup", "Properties": { "RetentionInDays": 7 } }
YAML
myLogGroup: Type: AWS::Logs::LogGroup Properties: RetentionInDays: 7
Additional Information
For an additional sample template, see Amazon CloudWatch Logs Template Snippets.
