Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aws-simple

Package Overview
Dependencies
Maintainers
1
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-simple

A Node.js interface for AWS that allows easy configuration and deployment of simple web projects.

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.1K
decreased by-18.93%
Maintainers
1
Weekly downloads
 
Created
Source

aws-simple

A Node.js interface for AWS that allows easy configuration and deployment of simple web projects.

Quick Overview

aws-simple allows you to easily create and deploy an API Gateway with a custom domain and optional alias record, make static files available via S3 and e.g. provision a BFF (Backend for Frontend) via Lambda. In addition, a local DEV server can be started to emulate the resulting AWS infrastructure.

Motivation

In my job I mainly build frontend web applications for existing backend/CMS systems. Since many of the frontend tech stacks are similar again and again, I created an abstraction for the AWS CDK/SDK for a faster and easier setup.

Since existing backend/CMS systems are used, there is rarely a need for own persistence layers. Therefore, setting these up is not part of this abstraction for the time being.

I deliberately kept it simple. A project with a more complex setup should be set up manually with the AWS CDK/SDK.

Getting Started

Install

Install aws-simple as development dependency, e.g. with:

yarn add --dev aws-simple

Create AWS IAM User

Create an AWS IAM user with programmatic access and the following attached policy:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["cloudformation:*", "apigateway:*", "s3:*"],
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": ["lambda:*"],
      "Resource": "arn:aws:lambda:*:*:function:mystack-*"
    },
    {
      "Effect": "Allow",
      "Action": ["iam:*"],
      "Resource": "arn:aws:iam::*:role/mystack-*"
    },
    {
      "Effect": "Allow",
      "Action": ["iam:CreateServiceLinkedRole"],
      "Resource": "arn:aws:iam::*:role/aws-service-role/ops.apigateway.amazonaws.com/*"
    },
    {
      "Effect": "Allow",
      "Action": ["route53:*"],
      "Resource": "arn:aws:route53:::*"
    }
  ]
}

Note: Please replace the stack ID (mystack) with your own. All resources created with CloudFormation will have this stack ID as prefix.

Create AWS CLI profile

Install the aws CLI, e.g. with:

brew install awscli

Then set up the AWS CLI profile using the access key from the AWS IAM user you just created:

aws configure --profile johndoe
AWS Access Key ID [None]: XXXXXXXXXXXXXXXXXXXX
AWS Secret Access Key [None]: YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
Default region name [None]: eu-central-1
Default output format [None]: json

Note: Please replace the profile (johndoe) and also the region (eu-central-1) if necessary.

Create Config File

Create a top-level configuration file called aws-simple.config.js in your project. The following describes a very simple stack including a static HTML file:

exports.default = {
  stackId: 'mystack',
  s3Configs: [
    {
      type: 'file',
      publicPath: '/',
      localPath: 'dist/app/index.html',
      bucketPath: 'index.html'
    }
  ]
};
Use TypeScript for auto-completion support
// @ts-check

/**
 * @type {import('aws-simple').StackConfig}
 */
exports.default = {
  stackId: 'mystack'
};

Note: The StackConfig interface can be viewed here.

Bootstrap AWS Environment

Before you can use the AWS CDK you must bootstrap your AWS environment to create the infrastructure that the AWS CDK CLI needs to deploy your AWS CDK app:

yarn cdk bootstrap --app 'yarn aws-simple create' --profile johndoe

Note: This command only needs to be executed once. For more information see here.

Deploy Stack to AWS

yarn cdk deploy --app 'yarn aws-simple create' --profile johndoe
yarn aws-simple upload --profile johndoe --region eu-central-1
package.json Scripts Example
{
  "scripts": {
    "deploy": "cdk deploy --app 'yarn aws-simple create' --profile johndoe",
    "postdeploy": "aws-simple upload --profile johndoe --region eu-central-1"
  }
}

Start Local DEV Server

yarn aws-simple start --port 1985 --cached

Note: If a bundler such as Parcel or Webpack is used, its watcher must be started in addition to the DEV server.

When changing the aws-simple config file, the DEV server must be restarted.

CLI Usage

Usage: aws-simple <command> [options]

Commands:
  aws-simple create [options]  Create a stack using the CDK
  aws-simple upload [options]  Upload files to S3
  aws-simple start [options]   Start local DEV server

Options:
  --version   Show version number                                      [boolean]
  -h, --help  Show help                                                [boolean]

Development

Publish a New Release

npm version 1.0.0 && git push --follow-tags

After a new release has been created by pushing the tag, it must be published via the GitHub UI. This triggers the final publication to npm.


Copyright (c) 2019, Clemens Akens. Released under the terms of the MIT License.

Keywords

FAQs

Package last updated on 25 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc