Skip to main content

Opinionated Modular Cloud Deployment Tool (EasySAM)

Project description

EasySAM - Opinionated Modular Cloud Deployment Tool

EasySAM is a simple, opinionated tool for deploying cloud resources with a focus on simplicity and modularity. It provides a streamlined way to define and deploy AWS resources using YAML configuration files, making cloud infrastructure management more accessible and maintainable.

Features

  • Simple YAML-based resource definitions
  • Modular architecture with import support
  • Comprehensive AWS resource support:
    • Lambda functions
    • DynamoDB tables with stream support
    • S3 buckets
    • SQS queues
    • Kinesis streams
    • API Gateway integrations
  • Event-driven architecture:
    • DynamoDB Streams for table change notifications
    • SQS polling
    • Kinesis stream processing
  • Easy initialization of new projects

Installation

pip install easysam

Quick Start

  1. Initialize a new application:
easysam init my-app
  1. Deploy your application:
easysam deploy --tag my-tag=my-value --environment my-environment-name my-app

Please note that at least one tag is required.

For more options, use the --help flag:

easysam --help

Windows

On Windows, it may be necessary to run the deploy command with the -sam-tool sam.cmd option.

Prerequisites

  • Python 3.12 or higher with pip on PATH
  • uv 0.5 or higher
  • AWS SAM CLI 1.138 or higher on PATH
  • AWS Credentials Configured

Usage

First, initialize a new application. This command creates a new directory with the given name and generates the necessary files for a single lambda function and table. This version only supports AWS as a backend, and Python as a language.

easysam init <app-name>

Deploy the application:

easysam deploy <app-directory> <aws-environment-name>

For more options, use the --help flag:

easysam --help

Resource Definitions

The entry point for all cloud resources definitions in the resources.yaml file. See example applications for how applications are structures.

Table Definitions

tables:
  - name: String (e.g., Items)
    attributes:
      - name: String (e.g., ItemID)
        type: String (e.g., S), dynamodb type
        hash: Boolean Optional (e.g., true), means Partition Key
        range: Boolean Optional (e.g., true) means Sort Key
    indices:
      - name: String
        attributes:
          - name: String
            type: String
            hash: Boolean Optional
            range: Boolean Optional
    trigger: String or Object - lambda function to trigger on table changes
      # Simple form (just function name, uses defaults):
      # trigger: my-lambda
      # Advanced form (with options):
      # trigger:
      #   function: my-lambda
      #   viewtype: new-and-old  # Optional: keys-only, new, old, new-and-old (default: new-and-old)
      #   batchsize: 10          # Optional: number of records per batch
      #   batchwindow: 5         # Optional: seconds to wait for batch
      #   startingposition: latest  # Optional: trim-horizon, latest (default: latest)

Bucket Definitions

buckets:
  - name: String (e.g., my-bucket)
    public Boolean Optional (e.g., true), means Public read policy

Queue Definitions

queues:
  - name: String (e.g., my-queue)

Stream Definitions

streams:
  - name: String (e.g., my-stream)

Lambda Definition

  - name: String (e.g., my-lambda)
    uri: String (i.e., local path to the source)
    tables:
      - String (e.g., Items)
    polls:
      - String (e.g., my-stream) - incoming stream's name
    buckets:
      - String (e.g., my-bucket)
    send:
      - String (e.g., my-queue) - outgoing queue's name
    services:
      - comprehend

API Gateway Definition

Lambda Function Integration

  path: # (e.g., /my-lambda)
    function: String # (e.g., my-lambda)
    authorizer: String # (e.g., my-authorizer)
    greedy: Boolean # (e.g., false)

Direct DynamoDB Integration

  path: # (e.g., /my-lambda)
    integration: dynamo
    method: String # (e.g., get)
    parameters: [String] # (e.g., [channel])
    role: GatewayDynamoRole
    action: String # (e.g., GetItem)
    requestTemplate: VTL Template 
    responseTemplateFile: VTL File Path

Direct SQS Integration

  path: # (e.g., /my-lambda)
    integration: sqs
    method: String # (e.g., post)
    role: GatewaySQSRole
    queue: String # (e.g., my-queue)
    requestTemplate: String # VTL Template
    responseTemplateFile: String # VTL File Path
    authorizer: String # (e.g., my-authorizer)

Import

import:
  - <directory>

The import directive searches recursively for easysam.yaml files (local definitions) in the specified directory and merges them into the current template.

Local Lambda Definition

lambda:
  name: <name>
  resources:
    tables:
      - <table>
    buckets:
      - <bucket>
    send:
      - <queue>
    polls:
      - <stream>
  integration:
    path: <path>
    open: <boolean>
    greedy: <boolean>
    authorizer: <authorizer-lambda-name>

Locally-defined lambda URI is set to the path of the easysam.yaml file.

Local Import

import:
  - <file>

Prismarine Support

prismarine:
  default-base: <base-path>
  access-module: <access-module-path>
  extra-imports:
    - <path.to.module:ClassName>
  tables:
    - package: <package-to-import>
      base: <optional-base-path>

For more information, see Prismarine README.

Conditional Resources

Conditional resources are defined using the !Conditional tag.

? !Conditional
  key: my-bucket
  environment: prod
  region: eu-west-2
:
  extaccesspolicy: ProdPolicy
  public: true

Negation

The ~ prefix negates the condition.

? !Conditional
  key: my-bucket
  environment: ~prod
  region: ~eu-west-2

Deployment Context File

The deployment context file is used to further control resources, especially in CI. This version has the following features:

  • override the resources.yaml file with the values in CI with <path>: <value> pairs.
overrides:
  buckets/my-bucket/public: true

Use the --context-file option to specify the deploy context file.

easysam deploy <app-directory> --environment <aws-environment-name> --context-file deploy-context.yaml

The deploy context file is a YAML file that contains the overrides.

Development

Setting up the development environment

  1. Clone the repository:
git clone https://github.com/adsight-app/easysam.git
cd easysam
  1. Install development dependencies and activate the virtual environment:
uv sync
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

Examples

See example folder for examples:

  • myapp- a simple application with a lambda function and a table.
  • prismarine- a simple application with a lambda function and a table, using Prismarine.
  • appwitherrors- an application with some errors in the resources.yaml file, to test the error handling.
  • conditionals- an application with conditional resources.
  • aoss- an application with Amazon OpenSearch Serverless and DynamoDB Streams integration.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you encounter any issues or have questions, please:

  1. Search existing issues
  2. Create a new issue if needed

Changelog

See CHANGELOG.md for a list of changes between versions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easysam-1.5.1.tar.gz (107.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easysam-1.5.1-py3-none-any.whl (32.0 kB view details)

Uploaded Python 3

File details

Details for the file easysam-1.5.1.tar.gz.

File metadata

  • Download URL: easysam-1.5.1.tar.gz
  • Upload date:
  • Size: 107.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for easysam-1.5.1.tar.gz
Algorithm Hash digest
SHA256 7118937c79fed4aa764bc0ffa5cb43128e304f21d5e4afb1755fc09862d78c5e
MD5 1cd42922ed1a65f385373e21bda2075c
BLAKE2b-256 05d8064964db7fd918685fc4579fd52a256097313a97949a6e15e966f8a9a360

See more details on using hashes here.

File details

Details for the file easysam-1.5.1-py3-none-any.whl.

File metadata

  • Download URL: easysam-1.5.1-py3-none-any.whl
  • Upload date:
  • Size: 32.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for easysam-1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ecdefec87e85a58815ac6335a3bf5e11dee31289932db046ef93a281bdf0c28f
MD5 860dc360a9def8ccff644bc461c4e71d
BLAKE2b-256 8d9f84fe50e1e99185900225699e97cd7b9841633c3d6e2a95685e34c846ca55

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page