-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
1,736 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
main.tf | ||
.terraform | ||
.terraform.lock.hcl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package deploy | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/atoz-technology/mantil-backend/internal/deploy" | ||
"github.com/atoz-technology/mantil-backend/internal/mantil" | ||
) | ||
|
||
type Deploy struct{} | ||
|
||
type DeployRequest struct { | ||
ProjectBucket string //TODO use mantil token here | ||
FunctionUpdates []mantil.FunctionUpdate | ||
} | ||
type DeployResponse struct { | ||
Response string | ||
} | ||
|
||
func (h *Deploy) Init(ctx context.Context) {} | ||
|
||
func (h *Deploy) Invoke(ctx context.Context, req *DeployRequest) (*DeployResponse, error) { | ||
return h.Deploy(ctx, req) | ||
} | ||
|
||
func (h *Deploy) Deploy(ctx context.Context, req *DeployRequest) (*DeployResponse, error) { | ||
p, err := mantil.LoadProject(req.ProjectBucket) | ||
if err != nil { | ||
return nil, err | ||
} | ||
d, err := deploy.New(p, req.FunctionUpdates, ".") | ||
if err != nil { | ||
return nil, err | ||
} | ||
if err := d.Deploy(); err != nil { | ||
return nil, err | ||
} | ||
rsp := DeployResponse{Response: "success"} | ||
return &rsp, nil | ||
} | ||
|
||
func New() *Deploy { | ||
return &Deploy{} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash -e | ||
|
||
WORK_DIR=~/work | ||
ASSETS_DIR=$WORK_DIR/mantil-backend/internal/assets | ||
|
||
zip -j funcs.zip $WORK_DIR/terraform-aws-modules/funcs/*.tf | ||
mv funcs.zip $ASSETS_DIR/terraform/modules | ||
|
||
zip -j dynamodb.zip $WORK_DIR/terraform-aws-modules/dynamodb/*.tf | ||
mv dynamodb.zip $ASSETS_DIR/terraform/modules | ||
|
||
(cd $ASSETS_DIR && go-bindata -pkg=assets -fs github/ terraform/modules/ terraform/templates/ aws/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
FROM public.ecr.aws/lambda/go:latest | ||
|
||
# terrraform install | ||
RUN yum -y install unzip wget git | ||
ARG version=1.0.0 | ||
ARG arch=_linux_amd64 #_linux_arm64 | ||
RUN wget https://releases.hashicorp.com/terraform/$version/terraform_${version}${arch}.zip \ | ||
&& unzip terraform_${version}${arch}.zip \ | ||
&& rm terraform_${version}${arch}.zip \ | ||
&& mv terraform /usr/bin/ \ | ||
&& terraform --version | ||
ENV TF_IN_AUTOMATION=1 | ||
|
||
# aws cli install | ||
# ref: https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html#cliv2-linux-install | ||
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \ | ||
&& unzip awscliv2.zip \ | ||
&& ./aws/install | ||
|
||
# ARG AWS_ACCESS_KEY_ID | ||
# ARG AWS_SECRET_ACCESS_KEY | ||
# ARG AWS_DEFAULT_REGION | ||
|
||
# get secrets from s3 bucket | ||
# RUN mkdir -p /secrets \ | ||
# && cd /secrets \ | ||
# && aws s3 sync s3://atoz-technology-mantil-secrets /secrets \ | ||
# && mkdir -p /root/.aws \ | ||
# && cp /secrets/atoz/config /root/.aws \ | ||
# && cp /secrets/atoz/credentials /root/.aws | ||
|
||
# ENV AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID | ||
# ENV AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY | ||
# ENV AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION | ||
|
||
COPY deploy /var/task/ | ||
CMD [ "deploy" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/atoz-technology/mantil-backend/api/hello" | ||
"github.com/atoz-technology/mantil-backend/api/deploy" | ||
"github.com/atoz-technology/mantil.go" | ||
) | ||
|
||
func main() { | ||
var api = hello.New() | ||
var api = deploy.New() | ||
mantil.LambdaHandler(api) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Action": "s3:ListBucket", | ||
"Resource": "arn:aws:s3:::{{.Bucket}}" | ||
}, | ||
{ | ||
"Effect": "Allow", | ||
"Action": "s3:*", | ||
"Resource": "arn:aws:s3:::{{.Bucket}}/*" | ||
}, | ||
{ | ||
"Effect": "Allow", | ||
"Action": "ecr:*", | ||
"Resource": "arn:aws:ecr:*:*:repository/mantil-project-{{.Organization.Name}}-{{.Name}}" | ||
} | ||
] | ||
} |
Oops, something went wrong.