How to generate a new loggroup in CloudWatch using python within Lambda

Overview

Create a new log group in CloudWatch on AWS. I tried to verify if Lambda could do that.

Simply generate a log group

make


import boto3

logs = boto3.client('logs')
response = logs.create_log_group(
 logGroupName = "log/group/name"
)
Grant log retention period

make


response = logs.put_retention_policy(
#Log group name you want to give
  logGroupName = "log/group/name",
#Retention period(Day)The set
  retentionInDays = 14
)

Referenced site

[CloudWatch Logs in Boto 3 Documentation] (https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/logs.html#CloudWatchLogs.Client.create_log_group)

Recommended Posts

How to generate a new loggroup in CloudWatch using python within Lambda
How to get a value from a parameter store in lambda (using python)
How to execute a command using subprocess in Python
How to generate a query using the IN operator in Django
How to get a stacktrace in python
How to create an instance of a particular class from dict using __new__ () in python
Tweet in Chama Slack Bot ~ How to make a Slack Bot using AWS Lambda ~
How to clear tuples in a list (Python)
How to generate permutations in Python and C ++
How to embed a variable in a python string
How to create a JSON file in Python
How to generate a Python object from JSON
How to notify a Discord channel in Python
[Python] How to draw a histogram in Matplotlib
How to convert / restore a string with [] in python
How to set up a Python environment using pyenv
[Python] How to expand variables in a character string
How to make a Python package using VS Code
How to exit when using Python in Terminal (Mac)
How to retrieve multiple arrays using slice in python.
How to develop in Python
How to use Python lambda
[GCF + Python] How to upload Excel to GCS and create a new table in BigQuery
How to unit test a function containing the current time using freezegun in python
How to host web app backend processing in Python using a rental server subdomain
How to build a new python virtual environment on Ubuntu
How to slice a block multiple array from a multiple array in Python
How to import Python library set up in EFS to Lambda
How to run a Python program from within a shell script
A story about how to specify a relative path in python.
How to use the __call__ method in a Python class
How to import a file anywhere you like in Python
How to transpose a 2D array using only python [Note]
How to generate exponential pulse time series data in python
How to define multiple variables in a python for statement
I tried "How to get a method decorated in Python"
How to develop in a virtual environment of Python [Memo]
To return char * in a callback function using ctypes in Python
How to get the last (last) value in a list in Python
How to get a list of built-in exceptions in python
I tried to make a stopwatch using tkinter in python
How to install python using anaconda
How to write a Python class
[Python] How to do PCA in Python
How to collect images in Python
How to use SQLite in Python
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
How to use PubChem in Python
How to handle Japanese in Python
How to determine the existence of a selenium element in Python
How to pass arguments to a Python script in SPSS Modeler Batch
How to make a string into an array or an array into a string in Python
[Introduction to Python] How to output a character string in a Print statement
[Python 3.8 ~] How to define a recursive function smartly with a lambda expression
How to check the memory size of a variable in Python
How to get a string from a command line argument in python
How to create a heatmap with an arbitrary domain in Python
[Introduction to Python] How to use the in operator in a for statement?
How to check the memory size of a dictionary in Python