Skip to content

Instantly share code, notes, and snippets.

@Kelvinskell
Kelvinskell / config.json
Last active December 10, 2023 13:58
AWS CloudWatch Agent coniguration File
{
"agent": {
"metrics_collection_interval": 30,
"run_as_user": "root"
},
"metrics": {
"aggregation_dimensions": [
[
"InstanceId"
]
@Kelvinskell
Kelvinskell / lambda_function.py
Last active August 26, 2022 10:08
An AWS lambda_function that will stop running ec2 instances when triggered.
import json
import boto3
import logging
from botocore.exceptions import ClientError
ec2 = boto3.client('ec2')
logger = logging.getLogger()
logger.setLevel(logging.INFO)
send_sns = False
import boto3
import uuid
import json
import random
import logging
from datetime import datetime
logging.basicConfig(format="[%(levelname)s] [%(name)s] [%(asctime)s]: %(message)s",
level="INFO")
logger = logging.getLogger(__name__)