---
# System prepended metadata

title: demo_lambda_activitat_academy

---

# demo_lambda_activitat_academy
Instància a aturar :)
![](https://i.imgur.com/DkuEHHW.png)

invoquem la URL associada a la lambda
![](https://i.imgur.com/xZ7vRhF.png)

Instància aturada :)
![](https://i.imgur.com/UR3AHo8.png)

Desfibrilador!!!
![](https://i.imgur.com/FnklIgN.png)

That's it!!
![](https://i.imgur.com/bOX6NiJ.png)

...important!!! les funcions!!!
![](https://i.imgur.com/TSyMIgh.png)

Engegar la instància
```python=
import boto3
region = 'us-east-1'
instances = ['i-0f23cbc4073194f08']
ec2 = boto3.client('ec2', region_name=region)
def lambda_handler(event, context):
    ec2.start_instances(InstanceIds=instances)
    print('Engegades les  instancies: ' + str(instances))```

```

Aturar la instància
```python=
import boto3
region = 'us-east-1'
instances = ['i-0f23cbc4073194f08']
ec2 = boto3.client('ec2', region_name=region)
def lambda_handler(event, context):
    ec2.stop_instances(InstanceIds=instances)
    print('aturades les instances: ' + str(instances))

```