-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
--- | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
|
||
``` | ||
|