Skip to content

Commit

Permalink
Merge branch 'v1' into ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiwara authored Jan 27, 2024
2 parents fe34326 + a5c03b3 commit d688811
Show file tree
Hide file tree
Showing 26 changed files with 1,165 additions and 249 deletions.
19 changes: 7 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
- "!**/*"
tags:
- "v*.*.*"
- "v*.*.*-rc*"

jobs:
release:
Expand All @@ -18,18 +19,12 @@ jobs:
check-latest: true

- name: Check out code into the Go module directory
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: setup tools
run: |
mkdir ~/bin
curl -sL https://github.com/Songmu/goxz/releases/download/v0.8.1/goxz_v0.8.1_linux_amd64.tar.gz | tar zxvf - && install goxz_v0.8.1_linux_amd64/goxz ~/bin/
curl -sL https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz | tar zxvf - && install ghr_v0.13.0_linux_amd64/ghr ~/bin/
- name: dist
run: PATH=~/bin:$PATH make dist

- name: release
run: PATH=~/bin:$PATH make release
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33 changes: 33 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
- go mod download
builds:
- env:
- CGO_ENABLED=0
main: ./cmd/lambroll
binary: lambroll
ldflags:
- -s -w
- -X main.Version=v{{.Version}}
goos:
- darwin
- linux
goarch:
- amd64
- arm64
release:
prerelease: "true"
archives:
- name_template: "{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}"
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ .Env.NIGHTLY_VERSION }}"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
16 changes: 5 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ DATE := $(shell date +%Y-%m-%dT%H:%M:%S%z)
export GO111MODULE := on

.PHONY: test binary install clean dist
cmd/lambroll/lambroll: *.go cmd/lambroll/*.go
cmd/lambroll/lambroll: *.go cmd/lambroll/*.go go.mod go.sum
cd cmd/lambroll && go build -ldflags "-s -w -X main.Version=${GIT_VER}" -gcflags="-trimpath=${PWD}"

install: cmd/lambroll/lambroll
Expand All @@ -16,17 +16,11 @@ clean:
rm -f cmd/lambroll/lambroll
rm -fr dist/

dist:
CGO_ENABLED=0 \
goxz -pv=$(GIT_VER) \
-build-ldflags="-s -w -X main.Version=${GIT_VER}" \
-os=darwin,linux -arch=amd64,arm64 -d=dist ./cmd/lambroll
packages:
goreleaser build --skip-validate --rm-dist

release:
ghr -u fujiwara -r lambroll -n "$(GIT_VER)" $(GIT_VER) dist/

prerelease:
ghr -replace -u fujiwara -r lambroll -n "$(GIT_VER)" $(GIT_VER) dist/
packages-snapshot:
goreleaser build --skip-validate --rm-dist --snapshot

orb/publish:
circleci orb validate circleci-orb.yml
Expand Down
185 changes: 141 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ https://circleci.com/orbs/registry/orb/fujiwara/lambroll
```yml
version: 2.1
orbs:
lambroll: fujiwara/lambroll@0.0.8
lambroll: fujiwara/lambroll@2.0.1
jobs:
deloy:
docker:
- image: cimg/base
steps:
- checkout
- lambroll/install:
version: v0.12.2
version: v1.0.0
- run:
command: |
lambroll deploy
Expand All @@ -71,10 +71,10 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: fujiwara/lambroll@v0
- uses: actions/checkout@v4
- uses: fujiwara/lambroll@v1
with:
version: v0.12.2
version: v1.0.0
- run: |
lambroll deploy
```
Expand Down Expand Up @@ -127,20 +127,19 @@ $ lambroll deploy
Usage: lambroll <command>
Flags:
-h, --help Show context-sensitive help.
--function=STRING Function file path
--log-level="info" log level (trace, debug, info, warn, error)
--color enable colored output
--region=REGION AWS region
--profile=PROFILE AWS credential profile name
--tfstate=TFSTATE URL to terraform.tfstate
--prefixed-tfstate=KEY=VALUE;...
key value pair of the prefix for template function name
and URL to terraform.tfstate
--endpoint=ENDPOINT AWS API Lambda Endpoint
--envfile=ENVFILE,... environment files
--ext-str=KEY=VALUE;... external string values for Jsonnet
--ext-code=KEY=VALUE;... external code values for Jsonnet
-h, --help Show context-sensitive help.
--function=STRING Function file path ($LAMBROLL_FUNCTION)
--log-level="info" log level (trace, debug, info, warn, error) ($LAMBROLL_LOGLEVEL)
--color enable colored output ($LAMBROLL_COLOR)
--region=REGION AWS region ($AWS_REGION)
--profile=PROFILE AWS credential profile name ($AWS_PROFILE)
--tfstate=TFSTATE URL to terraform.tfstate ($LAMBROLL_TFSTATE)
--prefixed-tfstate=KEY=VALUE;... key value pair of the prefix for template function name and URL to
terraform.tfstate ($LAMBROLL_PREFIXED_TFSTATE)
--endpoint=ENDPOINT AWS API Lambda Endpoint ($AWS_LAMBDA_ENDPOINT)
--envfile=ENVFILE,... environment files ($LAMBROLL_ENVFILE)
--ext-str=KEY=VALUE;... external string values for Jsonnet ($LAMBROLL_EXTSTR)
--ext-code=KEY=VALUE;... external code values for Jsonnet ($LAMBROLL_EXTCODE)
Commands:
deploy
Expand Down Expand Up @@ -170,48 +169,60 @@ Commands:
render
render function.json
status
show status of function
delete
delete function
versions
show versions of function
version
show version
Run "lambroll <command> --help" for more information on a command.
```

### Init

`lambroll init` initialize function.json by existing function.

```console
usage: lambroll init --function-name=FUNCTION-NAME [<flags>]
Usage: lambroll init --function-name=
init function.json
Flags:
(common flags snipped)
--function-name=FUNCTION-NAME Function name for initialize
--download Download function.zip
--function-name= Function name for init
--download-zip Download function.zip
--jsonnet render function.json as jsonnet
--qualifier=QUALIFIER function version or alias
--function-url create function url definition file
```

`init` creates `function.json` as a configuration file of the function.

### Deploy

```console
usage: lambroll deploy [<flags>]
Usage: lambroll deploy
deploy or create function
Flags:
(common flags snipped)
--src="." function zip archive or src dir
--exclude-file=".lambdaignore"
exclude file
--dry-run dry run
--publish publish function
--alias="current" alias name for publish
--alias-to-latest set alias to unpublished $LATEST version
--skip-archive skip to create zip archive. requires Code.S3Bucket and Code.S3Key in function definition
--keep-versions=0 Number of latest versions to keep. Older versions will be deleted. (Optional value: default 0).
--src="." function zip archive or src dir
--publish publish function
--alias-name="current" alias name for publish
--alias-to-latest set alias to unpublished $LATEST version
--dry-run dry run
--skip-archive skip to create zip archive. requires Code.S3Bucket and Code.S3Key in function
definition
--keep-versions=0 Number of latest versions to keep. Older versions will be deleted. (Optional
value: default 0).
--function-url="" path to function-url definiton
--skip-function skip to deploy a function. deploy function-url only
--exclude-file=".lambdaignore" exclude file
```

`deploy` works as below.
Expand Down Expand Up @@ -242,14 +253,13 @@ PackageType=Image and Code.ImageUri are required in function.json.
### Rollback

```
usage: lambroll rollback [<flags>]
Usage: lambroll rollback

rollback function

Flags:
(common flags snipped)
--delete-version Delete rolled back version
--dry-run dry run
--dry-run dry run
--delete-version delete rolled back version
```
`lambroll deploy` create/update alias `current` to the published function version on deploy.
Expand All @@ -263,15 +273,14 @@ Flags:
### Invoke
```
usage: lambroll invoke [<flags>]
Usage: lambroll invoke

invoke function

Flags:
(common flags snipped)
--async invocation type async
--log-tail output tail of log to STDERR
--qualifier=QUALIFIER version or alias to invoke
--async invocation type async
--log-tail output tail of log to STDERR
--qualifier=QUALIFIER version or alias to invoke
```
`lambroll invoke` accepts multiple JSON payloads for invocations from STDIN.
Expand Down Expand Up @@ -474,7 +483,7 @@ lambroll also can read function.jsonnet as [Jsonnet](https://jsonnet.org/) forma
Handler: 'index.handler',
MemorySize: std.extVar('memorySize'),
Role: 'arn:aws:iam::%s:role/lambda_role' % [ std.extVar('accountID') ],
Runtime: 'nodejs14.x',
Runtime: 'nodejs20.x',
}
```

Expand Down Expand Up @@ -512,6 +521,94 @@ Edge functions require two preconditions:

Otherwise, it works as usual.

### Lambda Function URLs support

lambroll can deploy [Lambda function URLs](https://docs.aws.amazon.com/lambda/latest/dg/lambda-urls.html).

`lambroll deploy --function-url=function_url.json` deploys a function URL after the function deploied.

When you want to deploy a public (without authentication) function URL, `function_url.json` is shown below.

```json
{
"Config": {
"AuthType": "NONE"
}
}
```

When you want to deploy a private (requires AWS IAM authentication) function URL, `function_url.json` is shown below.

```json
{
"Config": {
"AuthType": "AWS_IAM"
},
"Permissions": [
{
"Principal": "0123456789012"
},
{
"PrincipalOrgID": "o-123456789",
"Principal": "*"
}
]
}
```

- `Config` maps to [CreateFunctionUrlConfigInput](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/lambda#CreateFunctionUrlConfigInput) in AWS SDK Go v2.
- `Config.AuthType` must be `AWS_IAM` or `NONE`.
- `Config.Qualifer` is optional.
- `Permissions` is optional.
- If `Permissions` is not defined and `AuthType` is `NONE`, `Principal` is set to `*` automatically.
- When `AuthType` is `AWS_IAM`, you must define `Permissions` to specify allowed principals.
- Each elements of `Permissons` maps to [AddPermissionInput](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/lambda#AddPermissionInput) in AWS SDK Go v2.
- `function_url.jsonnet` is also supported like `function.jsonnet`.

### FunctionURL support

lambroll can deploy [Lambda function URLs](https://docs.aws.amazon.com/lambda/latest/dg/lambda-urls.html).

`lambroll deploy --function-url=function_url.json` deploys a function URL after the function deploied.

When you want to deploy a public (without authentication) function URL, `function_url.json` is shown below.

```json
{
"Config": {
"AuthType": "NONE"
}
}
```

When you want to deploy a private (requires AWS IAM authentication) function URL, `function_url.json` is shown below.

```json
{
"Config": {
"AuthType": "AWS_IAM"
},
"Permissions": [
{
"Principal": "0123456789012"
},
{
"PrincipalOrgID": "o-123456789",
"Principal": "*"
}
]
}
```

- `Config` maps to [CreateFunctionUrlConfigInput](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/lambda#CreateFunctionUrlConfigInput) in AWS SDK Go v2.
- `Config.AuthType` must be `AWS_IAM` or `NONE`.
- `Config.Qualifer` is optional.
- `Permissions` is optional.
- If `Permissions` is not defined and `AuthType` is `NONE`, `Principal` is set to `*` automatically.
- When `AuthType` is `AWS_IAM`, you must define `Permissions` to specify allowed principals.
- Each elements of `Permissons` maps to [AddPermissionInput](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/lambda#AddPermissionInput) in AWS SDK Go v2.
- `function_url.jsonnet` is also supported like `function.jsonnet`.

## LICENSE

MIT License
Expand Down
8 changes: 4 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
inputs:
version:
description: "A version to install lamroll"
default: "v0.10.0"
default: "v1.0.0"
runs:
using: "composite"
steps:
- run: |
cd /tmp
mkdir -p /tmp/lambroll-${{ inputs.version }}
cd /tmp/lambroll-${{ inputs.version }}
curl -sL https://github.com/fujiwara/lambroll/releases/download/${{ inputs.version }}/lambroll_${{ inputs.version}}_linux_amd64.tar.gz | tar zxvf -
sudo install lambroll_${{ inputs.version }}_linux_amd64/lambroll /usr/local/bin
rm -rf lambroll_${{ inputs.version }}_linux_amd64/
sudo install lambroll /usr/local/bin
shell: bash
Loading

0 comments on commit d688811

Please sign in to comment.