mardi 19 février 2019

Can I inject test data into

I've implemented a variation of Save AWS EC2 Cost by Automatically Stopping Idle Instance Using Lambda and CloudWatch but I want to be able to test it. After reading Introduction To AWS Lambda For Dummies I can do this by selecting "Configure test events" and adding:

{
  "detail": {
    "instance-id": "i-0123456789abcdef"
  }
}

with the id of a known EC2 instance. But what I want to be able to do is inject data that gets read by:

ec2 = boto3.resource('ec2')
instance = ec2.Instance(instance_id)
if instance.instance_type.endswith('xlarge'):
    put_cpu_alarm(instance_id)

So I don't have to have an EC2 instance running to test. Is this possible?

Aucun commentaire:

Enregistrer un commentaire