Skip to content

Commit

Permalink
adde ddynamo stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
vallard committed Feb 22, 2020
1 parent e4b01da commit be025f3
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 42 deletions.
3 changes: 3 additions & 0 deletions segment07-integrations/dynamo-example/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM tiangolo/uwsgi-nginx-flask:python3.6-alpine3.7
COPY templates /app/templates
COPY app.py /app/main.py
13 changes: 13 additions & 0 deletions segment07-integrations/dynamo-example/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.phony: build push

all: build push
#CMD := $(shell aws ecr get-login --no-include-email --region us-east-1)

build:
docker build -t vallard/eksdynamo .

push:
#${CMD}
docker tag vallard/eksdynamo:latest
docker push

28 changes: 28 additions & 0 deletions segment07-integrations/dynamo-example/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python
from flask import Flask, render_template
import os
import boto3 # required for getting AWS resources
import botocore

dynamodb = boto3.resource('dynamodb') # dynamo client
app = Flask(__name__)
@app.route('/')
def index():

table = dynamodb.Table(os.getenv('DYNAMODB_TABLE', 'dynamoUsers'))
results = []
error = ""
try:
results = table.scan()
except botocore.exceptions.ClientError as e:
error = str(e)
print("client error: ", e)
pass

print(results)
return render_template('index.html',
error = error,
items = results['Items'])

if __name__ == '__main__':
app.run(debug = True)
51 changes: 51 additions & 0 deletions segment07-integrations/dynamo-example/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">

<title>Dynamo Kubernetes Example</title>
</head>
<body>
<nav class="navbar navbar-light bg-light">
<span class="navbar-brand mb-0 h1">Dynamo - Kubernetes on AWS</span>
</nav>
<div class="container">
{% if error != "" %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endif %}
<h1 class="display-1">Users</h1>
<p class="lead">These are the entries in our users table</p>
<table class=table>
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Name</th>
<th scope="col">Email</th>
</tr>
</thead>
<tbody>
{% for item in items %}
<tr>
<td>{{ item['id'] }}</td>
<td>{{ item['name'] }}</td>
<td>{{ item['email'] }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>

<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</body>
</html>
42 changes: 0 additions & 42 deletions segment07-integrations/dynamo/dynamo/Dynamo.py

This file was deleted.

Empty file.
Binary file not shown.
Binary file not shown.

0 comments on commit be025f3

Please sign in to comment.