This file contains hidden or 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
| FROM public.ecr.aws/lambda/python:3.9 | |
| # Install the function's dependencies using file requirements.txt | |
| # from your project folder. | |
| COPY requirements.txt . | |
| RUN pip3 install -r requirements.txt --target "${LAMBDA_TASK_ROOT}" | |
| # Copy function code | |
| COPY main.py ${LAMBDA_TASK_ROOT} |
This file contains hidden or 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
| variable "env_name" { | |
| description = "Environment name" | |
| } | |
| data "aws_ecr_repository" "profile_faker_ecr_repo" { | |
| name = "profile-faker" | |
| } | |
| resource "aws_lambda_function" "profile_faker_function" { | |
| function_name = "profile-faker-${var.env_name}" |
This file contains hidden or 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
| terraform { | |
| required_providers { | |
| aws = { | |
| source = "hashicorp/aws" | |
| version = "~> 4.0" | |
| } | |
| } | |
| } | |
| provider "aws" { |
This file contains hidden or 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
| import json | |
| from faker import Faker | |
| fake = Faker() | |
| def handler(event, context): | |
| return { | |
| "statusCode": 200, | |
| "headers": {"Content-Type": "application/json"}, |
This file contains hidden or 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
| name: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 |
This file contains hidden or 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
| import redis | |
| import time | |
| # Establish a connection to the Redis database 1 at | |
| # redis://localhost:6379 | |
| r = redis.Redis(host='localhost', port=6379, db=1) | |
| # SET hello world | |
| r.set('hello', 'world') # True | |
| # GET hello | |
| world = r.get('hello') | |
| print(world.decode()) # "world" |
This file contains hidden or 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
| import redisx | |
| r = redisx.Redis(db=1) | |
| r.set('hello', 'world') # True | |
| value = r.get('hello') | |
| print(value) # 'world' | |
| r.delete('hello') # True | |
| print(r.get('hello')) # None |
This file contains hidden or 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
| """ | |
| An oversimplified implementation of the Python interface for Redis | |
| """ | |
| class Redis: | |
| def __init__(self, db=0): | |
| self.db = db | |
| self.data = {self.db: {}} | |
| def get(self, key): | |
| """Gets the value associated with a key""" | |
| return self.data.get(self.db, {}).get(key) |
This file contains hidden or 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
| import json | |
| import random | |
| def scramble(text: str) -> str: | |
| return "".join(random.sample(text, len(text))) | |
| def handler(event, context): | |
| return { |
This file contains hidden or 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
| variable "env_name" { | |
| description = "Environment name" | |
| } | |
| locals { | |
| function_name = "text_scrambler" | |
| function_handler = "main.handler" | |
| function_runtime = "python3.9" | |
| function_timeout_in_seconds = 5 |
NewerOlder