Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
software-development-docs
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pem
software-development-docs
Commits
37aec8e6
Commit
37aec8e6
authored
Apr 23, 2025
by
Denis Armenta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Paso a paso configuracion localstack
Paso a paso configuracion localstack
parent
b472e485
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
213 additions
and
0 deletions
+213
-0
2000-2005.tif
docs/guides/sections/localstack_raster_project/2000-2005.tif
+0
-0
docker-compose.yml
...des/sections/localstack_raster_project/docker-compose.yml
+16
-0
list_and_download_raster.py
...ons/localstack_raster_project/list_and_download_raster.py
+33
-0
localstack-setup.md
...es/sections/localstack_raster_project/localstack-setup.md
+138
-0
requirements.txt
...uides/sections/localstack_raster_project/requirements.txt
+3
-0
upload_raster.py
...uides/sections/localstack_raster_project/upload_raster.py
+23
-0
No files found.
docs/guides/sections/localstack_raster_project/2000-2005.tif
0 → 100644
View file @
37aec8e6
This diff was suppressed by a .gitattributes entry.
docs/guides/sections/localstack_raster_project/docker-compose.yml
0 → 100644
View file @
37aec8e6
version
:
"
3.8"
services
:
localstack
:
container_name
:
"
${LOCALSTACK_DOCKER_NAME:-localstack-main}"
image
:
localstack/localstack
ports
:
-
"
127.0.0.1:4566:4566"
-
"
127.0.0.1:4510-4559:4510-4559"
environment
:
-
DEBUG=${DEBUG:-1}
-
SERVICES=${SERVICES:-s3}
-
DOCKER_HOST=unix:///var/run/docker.sock
volumes
:
-
"
${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
-
"
/var/run/docker.sock:/var/run/docker.sock"
docs/guides/sections/localstack_raster_project/list_and_download_raster.py
0 → 100644
View file @
37aec8e6
import
boto3
import
os
# Configurar cliente S3 apuntando a LocalStack
s3
=
boto3
.
client
(
"s3"
,
endpoint_url
=
"http://localhost:4566"
,
aws_access_key_id
=
"test"
,
aws_secret_access_key
=
"test"
,
region_name
=
"us-east-1"
)
bucket_name
=
"mi-bucket-raster"
download_folder
=
"descargas"
# Crear carpeta si no existe
os
.
makedirs
(
download_folder
,
exist_ok
=
True
)
# Listar objetos en el bucket
response
=
s3
.
list_objects_v2
(
Bucket
=
bucket_name
)
if
'Contents'
in
response
:
print
(
"Archivos encontrados:"
)
for
obj
in
response
[
'Contents'
]:
key
=
obj
[
'Key'
]
print
(
f
"- {key}"
)
# Descargar archivo
local_path
=
os
.
path
.
join
(
download_folder
,
os
.
path
.
basename
(
key
))
with
open
(
local_path
,
'wb'
)
as
f
:
s3
.
download_fileobj
(
bucket_name
,
key
,
f
)
print
(
f
"Descargado: {local_path}"
)
else
:
print
(
"No se encontraron archivos en el bucket."
)
docs/guides/sections/localstack_raster_project/localstack-setup.md
0 → 100644
View file @
37aec8e6
# 📦 Configuración de LocalStack para guardar archivos Raster
Este documento explica cómo configurar
**LocalStack**
localmente para emular S3 y guardar archivos raster (por ejemplo,
`.tif`
).
---
## ✅ Requisitos
Asegúrate de tener lo siguiente instalado:
-
Docker
-
Python 3
-
Adicional preferible utilizar conda
-
Dependencias en
`requirements.txt`
:
```
bash
pip install
-r
requirements.txt
```
---
## 📂 requirements.txt
```
text
boto3 # Librería oficial de AWS para Python. Se usa para interactuar con servicios como S3.
awscli # Interfaz de línea de comandos para AWS. Permite interactuar con servicios como S3 desde el terminal.
```
---
## 🧱 1. Levantar LocalStack con Docker
Utiliza este
`docker-compose.yml`
:
```
yaml
version
:
"
3.8"
services
:
localstack
:
container_name
:
"
${LOCALSTACK_DOCKER_NAME:-localstack-main}"
image
:
localstack/localstack
ports
:
-
"
127.0.0.1:4566:4566"
-
"
127.0.0.1:4510-4559:4510-4559"
environment
:
-
DEBUG=${DEBUG:-1}
-
SERVICES=${SERVICES:-s3}
-
DOCKER_HOST=unix:///var/run/docker.sock
volumes
:
-
"
${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
-
"
/var/run/docker.sock:/var/run/docker.sock"
```
Luego ejecuta:
```
bash
docker-compose up
-d
```
Esto iniciará LocalStack con el servicio S3 habilitado en
`http://localhost:4566`
.
---
## 🪣 2. Configurar AWS CLI para usar LocalStack
1.
Configura AWS CLI:
```
bash
aws configure
```
Puedes usar valores ficticios:
-
Access Key ID:
`test`
-
Secret Access Key:
`test`
-
Region:
`us-east-1`
2.
Crea un bucket S3 en LocalStack:
```
bash
aws
--endpoint-url
=
http://localhost:4566 s3 mb s3://mi-bucket-raster
```
---
## 🗂️ 3. Subir un archivo raster al bucket
```
bash
aws
--endpoint-url
=
http://localhost:4566 s3 cp 2000-2005.tif s3://mi-bucket-raster/
```
---
## 🐍 4. (Opcional) Subir raster con Python (`boto3`)
Se genero un codigo para realizar la prueba de upload del raster desde python.
```
python upload_raster.py
```
---
## 🧪 Verifica el contenido del bucket
```
bash
aws
--endpoint-url
=
http://localhost:4566 s3
ls
s3://mi-bucket-raster/
```
---
## 🧼 Detener LocalStack
```
bash
docker-compose down
```
---
## 📝 Notas adicionales
-
LocalStack guarda los datos localmente en
`./volume`
.
-
Puedes emular más servicios de AWS agregándolos a la variable
`SERVICES`
en el
`docker-compose.yml`
.
---
## 📥 (Opcional) Consultar y descargar archivos con Python (`boto3`)
Se genero un codigo para realizar la prueba de listar y descargar del raster desde python.
```
python list_and_download_raster.py
```
docs/guides/sections/localstack_raster_project/requirements.txt
0 → 100644
View file @
37aec8e6
boto3
awscli
docs/guides/sections/localstack_raster_project/upload_raster.py
0 → 100644
View file @
37aec8e6
import
boto3
# Configurar cliente S3 apuntando a LocalStack
s3
=
boto3
.
client
(
"s3"
,
endpoint_url
=
"http://localhost:4566"
,
aws_access_key_id
=
"test"
,
aws_secret_access_key
=
"test"
,
region_name
=
"us-east-1"
)
bucket_name
=
"mi-bucket-raster"
raster_path
=
"2000-2005.tif"
raster_key
=
"raster/2000-2005.tif"
# Crear bucket (si no existe)
s3
.
create_bucket
(
Bucket
=
bucket_name
)
# Subir archivo
with
open
(
raster_path
,
"rb"
)
as
f
:
s3
.
upload_fileobj
(
f
,
bucket_name
,
raster_key
)
print
(
f
"Archivo subido como s3://{bucket_name}/{raster_key}"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment