Skip to content

Commit

Permalink
aws
Browse files Browse the repository at this point in the history
  • Loading branch information
lmorillas committed Sep 4, 2023
1 parent edfa00f commit 61174ea
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
11 changes: 11 additions & 0 deletions content/es/sesion-4/aws/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: "AWS"
linkTitle: "AWS"
description: >
Amazon Web Services - Recursos para el curso de Python para IoT
weight: 30
---




40 changes: 40 additions & 0 deletions content/es/sesion-4/aws/ec2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: "EC2"

description: >
Creación y accesos a instancias EC2
weight: 30
---

{{% pageinfo %}}
## Documentación
* https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EC2_GetStarted.html
{{% /pageinfo %}}

## Qué es EC2
EC2 es un servicio de computación en la nube de Amazon Web Services. Permite crear instancias de máquinas virtuales en la nube. Las instancias se organizan en regiones.

## Acceso a una instancia EC2

```python
import boto3

ec2 = boto3.resource('ec2')

# Describe instances
instances = ec2.instances.filter(
Filters=[{'Name': 'instance-state-name', 'Values': ['running']}])

for instance in instances:
print(instance.id, instance.instance_type)

# stop instance
ec2.instances.filter(InstanceIds=['i-1234567890abcdef0']).stop()

# start instance
ec2.instances.filter(InstanceIds=['i-1234567890abcdef0']).start()

# terminate instance
ec2.instances.filter(InstanceIds=['i-1234567890abcdef0']).terminate()
```
43 changes: 43 additions & 0 deletions content/es/sesion-4/aws/s3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: "S3"

description: >
Creación de un bucket S3
weight: 30
---

{{% pageinfo %}}
## Documentación
* https://docs.aws.amazon.com/AmazonS3/latest/userguide/GetStartedWithS3.html
* https://docs.aws.amazon.com/AmazonS3/latest/userguide/HostingWebsiteOnS3Setup.html
* https://realpython.com/python-boto3-aws-s3/
{{% /pageinfo %}}

## Qué es S3
S3 es un servicio de almacenamiento de objetos de Amazon Web Services. Los objetos son archivos y sus metadatos. Los objetos se organizan en buckets. Los buckets se organizan en regiones.

## Creación de un bucket S3
* https://docs.aws.amazon.com/AmazonS3/latest/userguide/creating-bucket.html

## Uso con Python

```python
import boto3

# Retrieve the list of existing buckets
s3 = boto3.client('s3')
response = s3.list_buckets()

# Output the bucket names
print('Existing buckets:')
for bucket in response['Buckets']:
print(f' {bucket["Name"]}')


# upload file
# s3_client.upload_file(file_name, bucket, object_name)
s3.upload_file('test.txt', 'curso-py-iot', 'test.txt')

```

0 comments on commit 61174ea

Please sign in to comment.