Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @moritzzimmer
* @moritzzimmer
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
uses: actions/checkout@v2
-
name: Set up Go
uses: actions/setup-go@v2.1.3
uses: actions/setup-go@v2.1.4
with:
go-version: "1.14.x"
go-version: "1.x"
-
name: Build, test and static check code
run: make ci
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
uses: actions/checkout@v2
-
name: Set up Go
uses: actions/setup-go@v2.1.3
uses: actions/setup-go@v2.1.4
with:
go-version: 1.14.x
go-version: 1.x
-
name: Unshallow
run: git fetch --prune --unshallow
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
repos:
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.0.1
hooks:
- id: check-merge-conflict
- id: trailing-whitespace
- id: end-of-file-fixer

- repo: git://github.com/dnephin/pre-commit-golang
rev: v0.3.5
rev: v0.4.0
hooks:
- id: go-fmt
- id: go-vet
2 changes: 1 addition & 1 deletion cmd/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func init() {
rootCmd.AddCommand(newCmd)

newCmd.Flags().BoolP("dry-run", "d", false, "dry run")
newCmd.Flags().StringP("event", "e", "cloudwatch-event", "event type triggering the Lambda function [cloudwatch-event, dynamodb, kinesis, s3, sns, sqs]")
newCmd.Flags().StringP("event", "e", "cloudwatch-event", "event type triggering the Lambda function [cloudwatch-event, dynamodb, kinesis, sns, sqs]")
newCmd.Flags().String("ci", "none", "ci provider config file to generate [none, gh]")
viper.BindPFlags(newCmd.Flags())
}
6 changes: 3 additions & 3 deletions generate/core/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ func DefaultOpts() *Options {
},
Aws: &Aws{Region: "eu-west-1"},
Terraform: &Terraform{
AwsProvider: "3.32.0",
Version: "0.14.8",
AwsProvider: "3.62",
Version: "1.0",
Module: &Module{
Source: "moritzzimmer/lambda/aws",
Version: "5.12.0",
Version: "6.0.0",
},
},
}
Expand Down
13 changes: 7 additions & 6 deletions generate/core/templates/Makefile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,19 @@ package: release ## Creates deployment package
.PHONY: init
init: ## Initialize Terraform working directory and backend configuration
@echo "+ $@"
@terraform init -input=false terraform/
@terraform -chdir=terraform init -input=false


.PHONY: validate
validate: ## Validates and rewrites Terraform files to canonical format
@echo "+ $@"
@terraform fmt -check=true terraform/
@terraform validate terraform/
@terraform -chdir=terraform fmt -check=true
@terraform -chdir=terraform validate

.PHONY: plan
plan: ## Generate and show a Terraform execution plan
@echo "+ $@"
@terraform plan -input=false -var region=$(REGION) terraform/
@terraform plan -chdir=terraform -input=false -var region=$(REGION)

ifeq ($(AUTO_DEPLOY), true)
FORCE=-auto-approve
Expand All @@ -85,12 +86,12 @@ endif
.PHONY: deploy
deploy: ## Builds or changes infrastructure using Terraform
@echo "+ $@"
@terraform apply $(FORCE) -input=false -var region=$(REGION) terraform/
@terraform apply $(FORCE) -chdir=terraform -input=false -var region=$(REGION)

.PHONY: destroy
destroy: ## Destroy Terraform-managed infrastructure
@echo "+ $@"
@terraform destroy -var region=$(REGION) terraform/
@terraform destroy -chdir=terraform -var region=$(REGION)

.PHONY: clean
clean: ## Cleanup any build binaries or packages
Expand Down
10 changes: 10 additions & 0 deletions generate/core/templates/terraform/backend.tf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = "~> {{.opts.Terraform.Version}}"

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> {{.opts.Terraform.AwsProvider}}"
}
}
}
17 changes: 2 additions & 15 deletions generate/core/templates/terraform/main.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ module "{{.opts.App.Name}}" {
runtime = "go1.x"
source_code_hash = filebase64sha256(local.artifact)

tags = {
managed_by = "terraform"
}

{{if eq .opts.App.Event "cloudwatch-event" -}}
// see https://github.com/moritzzimmer/terraform-aws-lambda/tree/master/examples/with-cloudwatch-event-rules for details
cloudwatch_event_rules = {
Expand Down Expand Up @@ -89,21 +85,12 @@ module "{{.opts.App.Name}}" {
{{if eq .opts.App.Event "kinesis" -}}
// see https://github.com/moritzzimmer/terraform-aws-lambda/tree/master/examples/with-event-source-mappings/kinesis for details
event_source_mappings = {
stream_1 = {
stream_1 = {
event_source_arn = aws_kinesis_stream.stream_1.arn
}
}
{{end -}}

{{if eq .opts.App.Event "s3" -}}
// s3 events are deprecated and will be removed in the next major version of https://github.com/moritzzimmer/terraform-aws-lambda
event = {
type = "s3"
s3_bucket_arn = data.aws_s3_bucket.example.arn
s3_bucket_id = data.aws_s3_bucket.example.id
}
{{end -}}

{{if eq .opts.App.Event "sns" -}}
// see https://github.com/moritzzimmer/terraform-aws-lambda/tree/master/examples/with-sns-subscriptions for details
sns_subscriptions = {
Expand All @@ -116,7 +103,7 @@ module "{{.opts.App.Name}}" {
{{if eq .opts.App.Event "sqs" -}}
// see https://github.com/moritzzimmer/terraform-aws-lambda/tree/master/examples/with-event-source-mappings/sqs for details
event_source_mappings = {
queue_1 = {
queue_1 = {
event_source_arn = aws_sqs_queue.queue_1.arn
}
}
Expand Down
6 changes: 6 additions & 0 deletions generate/core/templates/terraform/provider.tf.tmpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
provider "aws" {
region = var.region

default_tags {
tags = {
managed_by = "terraform"
}
}
}
7 changes: 0 additions & 7 deletions generate/core/templates/terraform/versions.tf.tmpl

This file was deleted.

41 changes: 36 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,16 +1,47 @@
module github.com/moritzzimmer/func

go 1.16
go 1.17

require (
github.com/gobuffalo/genny v0.6.0
github.com/gobuffalo/gogen v0.2.0
github.com/gobuffalo/packr/v2 v2.7.1
github.com/spf13/cobra v1.2.1
github.com/spf13/viper v1.9.0
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616
honnef.co/go/tools v0.2.1
)

require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/gobuffalo/envy v1.8.1 // indirect
github.com/gobuffalo/logger v1.0.3 // indirect
github.com/gobuffalo/packd v1.0.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/joho/godotenv v1.3.0 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/markbates/safe v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pkg/errors v0.8.1 // indirect
github.com/rogpeppe/go-internal v1.5.2 // indirect
github.com/spf13/cobra v0.0.7
github.com/sirupsen/logrus v1.4.2 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.7.1
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f
honnef.co/go/tools v0.1.3
github.com/subosito/gotenv v1.2.0 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/mod v0.4.2 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf // indirect
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/tools v0.1.5 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/ini.v1 v1.63.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Loading