Skip to content

uorat/hello-apex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Hello Apex

Documentation

Apex – Serverless Infrastructure

Installation

Install Apex on your machine

$ curl https://raw.githubusercontent.com/apex/apex/master/install.sh | sh

Auto completion (Mac OS X)

$ brew install bash_completion
$ vim /usr/local/etc/bash_completion.d/apex
$ cat /usr/local/etc/bash_completion.d/apex
_apex()  {
  COMPREPLY=()
  local cur="${COMP_WORDS[COMP_CWORD]}"
  local opts="$(apex autocomplete -- ${COMP_WORDS[@]:1})"
  COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  return 0
}

complete -F _apex apex

$ exec $SHELL -l
$ apex
Apex version 0.15.0
$ apex <TAB>
--chdir      --iamrole    --region     delete       exec         init         logs         upgrade
--dry-run    --log-level  alias        deploy       help         invoke       metrics      version
--env        --profile    build        docs         infra        list         rollback

Preparation

(otherwise, run $ apex init)

  1. make IAM User for executing Apex and install the credentials to $HOME/.aws/
  2. make IAM Role for Lambda functions hello-apex_lambda_function
  3. set environment variables, $ export AWS_PROFILE="your profile name"

How to run these programs

List

$ apex list
  hello (not deployed)
    description: sample program for nodejs with apex
    runtime: nodejs6.10
    memory: 128mb
    timeout: 5s
    role: arn:aws:iam::xxxxxxxxxxxx:role/hello-apex_lambda_function
    handler: index.handle

  helloworld-python (not deployed)
    description: sample program for python with apex
    runtime: python2.7
    memory: 128mb
    timeout: 5s
    role: arn:aws:iam::xxxxxxxxxxxx:role/hello-apex_lambda_function
    handler: main.handle

Deploy

$ apex deploy
   • creating function         env= function=hello
   • creating function         env= function=helloworld-python
   • created alias current     env= function=hello version=2
   • function created          env= function=hello name=hello-apex_hello version=2
   • created alias current     env= function=helloworld-python version=2
   • function created          env= function=helloworld-python name=hello-apex_helloworld-python version=2

Run the sample program for Node.js

$ apex invoke hello -L
START RequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Version: 1
2017-07-21T11:16:29.805Z        xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx    processing event: {}
END RequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
REPORT RequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx  Duration: 0.89 ms       Billed Duration: 100 ms         Memory Size: 128 MB   Max Memory Used: 23 MB
{"hello":"world"}

Run the sample program for Python, with parameters

$ echo '{ "region": "ap-northeast-1"}' | apex invoke helloworld-python
["13.112.0.0/14", "13.230.0.0/15", "27.0.0.0/22", "46.51.224.0/19", "52.68.0.0/15", "52.92.60.0/22", "52.92.80.0/22", "52.94.8.0/24", "52.94.200.0/24", "52.94.248.80/28", "52.95.30.0/23", "52.95.34.0/24", "52.95.56.0/22", "52.95.243.0/24", "52.95.255.48/28", "52.119.216.0/21", "52.192.0.0/15", "52.196.0.0/14", "52.219.0.0/20", "52.219.16.0/22", "52.219.68.0/22", "54.64.0.0/15", "54.92.0.0/17", "54.95.0.0/16", "54.150.0.0/16", "54.168.0.0/16", "54.178.0.0/16", "54.199.0.0/16", "54.231.224.0/21", "54.238.0.0/16", "54.239.0.80/28", "54.239.52.0/23", "54.239.96.0/24", "54.240.200.0/24", "54.240.225.0/24", "54.248.0.0/15", "54.250.0.0/16", "103.4.8.0/22", "103.4.12.0/22", "103.246.150.0/23", "175.41.192.0/18", "176.32.64.0/19", "176.34.0.0/19", "176.34.32.0/19", "54.248.220.0/26", "54.250.253.192/26", "52.92.60.0/22", "52.92.80.0/22", "52.219.0.0/20", "52.219.16.0/22", "52.219.68.0/22", "54.231.224.0/21", "13.112.0.0/14", "13.230.0.0/15", "46.51.224.0/19", "52.68.0.0/15", "52.95.243.0/24", "52.95.255.48/28", "52.192.0.0/15", "52.196.0.0/14", "54.64.0.0/15", "54.92.0.0/17", "54.95.0.0/16", "54.150.0.0/16", "54.168.0.0/16", "54.178.0.0/16", "54.199.0.0/16", "54.238.0.0/16", "54.248.0.0/15", "54.250.0.0/16", "103.4.8.0/22", "103.4.12.0/22", "175.41.192.0/18", "176.32.64.0/19", "176.34.0.0/19", "176.34.32.0/19", "13.113.203.0/24", "52.199.127.192/26"]

How to use AssumeRole (SwitchRole)

Use --iamrole | -i that means the Role for AssumeRole.

$ apex -p [YOUR_PROFILE_NAME] -i [IAM_ROLE] [command]

Description below.

$ apex --help|tail -n 12

  Flags:
    -C, --chdir string       Working directory
    -D, --dry-run            Perform a dry-run
    -e, --env string         Environment name
    -i, --iamrole string     AWS iamrole
    -l, --log-level string   Log severity level (default "info")
    -p, --profile string     AWS profile
    -r, --region string      AWS region

  Use "apex [command] --help" for more information about a command.

Example.

# base profile (arn:aws:iam::123456789012:user/uorat)
apex -p uorat deploy
# the other role (arn:aws:iam::987654321098:role/lambda-maintener)
apex -p uorat --iamrole arn:aws:iam::987654321098:role/lambda-maintener deploy

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published