flexentry

package module
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2022 License: MIT Imports: 16 Imported by: 0

README

flexentry

Latest GitHub release Github Actions test Go Report Card License

Flexible entry point for Amazon ECS Task and Amazon Lambda container images

Usage

FROM golang:1.17-buster

RUN apt-get update && \
    apt-get install -y unzip && \
    apt-get clean

RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
    unzip awscliv2.zip && \
    ./aws/install && \
    rm -R aws && \
    rm awscliv2.zip

ARG FLEXENTRY_VERSION=0.2.0
RUN curl -L https://github.com/mashiike/flexentry/releases/download/v${FLEXENTRY_VERSION}/flexentry_${FLEXENTRY_VERSION}_linux_amd64.tar.gz | tar zxvf - && \
    install flexentry /usr/local/bin/

ENTRYPOINT ["flexentry"]

Basically, all you have to do is specify the entry point of the container image.

Run on ECS Task
{
   "containerDefinitions": [ 
      { 
         "command": [
            "aws --version"
         ],
         "essential": true,
         "image": "<ecr image path>",
         "name": "sample-app"
      }
   ],
   "cpu": "256",
   "executionRoleArn": "arn:aws:iam::012345678910:role/ecsTaskExecutionRole",
   "family": "sample-task-definition",
   "memory": "512",
   "networkMode": "awsvpc",
   "requiresCompatibilities": [ 
       "FARGATE" 
    ]
}

Decide what to execute with command, as in the task definition above.

Run on Lambda with container image

If the environment variable FLEXENTRY_COMMAND is specified, the command will be executed. Otherwise, the command to be executed will be determined according to the payload of the event.

{
    "cmd": "aws --version",
    "description": "this is sample"
}

If the event payload is a string, it will be interpreted as a command. Otherwise, by default, it looks at the cmd key to decide which command to execute. To change the key, specify a jq expression for reference with FLEXENTRY_COMMAND_JQ_EXPR. For example export FLEXENTRY_COMMAND_JQ_EXPR=".command"

When executed by Amazon Lambda, the event payload is passed directly to the standard input as JSON data.

LICENSE

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergeEnv added in v0.3.0

func MergeEnv(base, other []string) []string

func MergeEnvWithMap added in v0.3.0

func MergeEnvWithMap(base []string, otherMap map[string]string) []string

Types

type Entrypoint

type Entrypoint struct {
	Executer
	// contains filtered or unexported fields
}

func (*Entrypoint) DetectCommand

func (e *Entrypoint) DetectCommand(ctx context.Context, event Event) ([]string, error)

func (*Entrypoint) DetectEnviron added in v0.3.0

func (e *Entrypoint) DetectEnviron(ctx context.Context, event Event) ([]string, error)

func (*Entrypoint) Execute

func (e *Entrypoint) Execute(ctx context.Context, opt *ExecuteOption, commands ...string) error

func (*Entrypoint) Run

func (e *Entrypoint) Run(ctx context.Context, args ...string) error

type Event

type Event interface{}

type ExecuteOption added in v0.3.0

type ExecuteOption struct {
	Stdin   io.Reader
	Stdout  io.Writer
	Stderr  io.Writer
	Environ []string
}

type Executer

type Executer interface {
	Execute(ctx context.Context, opt *ExecuteOption, commands ...string) error
}

type SSMWrapExecuter

type SSMWrapExecuter struct {
	Executer
	// contains filtered or unexported fields
}

func NewSSMWrapExecuter

func NewSSMWrapExecuter(executer Executer, cacheExpires time.Duration) *SSMWrapExecuter

func (*SSMWrapExecuter) Execute

func (e *SSMWrapExecuter) Execute(ctx context.Context, opt *ExecuteOption, commands ...string) error

type ShellExecuter

type ShellExecuter struct {
	// contains filtered or unexported fields
}

func NewShellExecuter

func NewShellExecuter() *ShellExecuter

func (*ShellExecuter) Clone

func (e *ShellExecuter) Clone() *ShellExecuter

func (*ShellExecuter) Execute

func (e *ShellExecuter) Execute(ctx context.Context, opt *ExecuteOption, commands ...string) error

func (*ShellExecuter) SetShell

func (e *ShellExecuter) SetShell(shell string, shellArgs []string) *ShellExecuter

Directories

Path Synopsis
cmd
flexentry command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL