set up to use AWS. using Serverless
This commit is contained in:
parent
876cd0d84f
commit
66524e5d79
82
.serverless/cloudformation-template-create-stack.json
Normal file
82
.serverless/cloudformation-template-create-stack.json
Normal file
@ -0,0 +1,82 @@
|
||||
{
|
||||
"AWSTemplateFormatVersion": "2010-09-09",
|
||||
"Description": "The AWS CloudFormation template for this Serverless application",
|
||||
"Resources": {
|
||||
"ServerlessDeploymentBucket": {
|
||||
"Type": "AWS::S3::Bucket",
|
||||
"Properties": {
|
||||
"BucketEncryption": {
|
||||
"ServerSideEncryptionConfiguration": [
|
||||
{
|
||||
"ServerSideEncryptionByDefault": {
|
||||
"SSEAlgorithm": "AES256"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"ServerlessDeploymentBucketPolicy": {
|
||||
"Type": "AWS::S3::BucketPolicy",
|
||||
"Properties": {
|
||||
"Bucket": {
|
||||
"Ref": "ServerlessDeploymentBucket"
|
||||
},
|
||||
"PolicyDocument": {
|
||||
"Statement": [
|
||||
{
|
||||
"Action": "s3:*",
|
||||
"Effect": "Deny",
|
||||
"Principal": "*",
|
||||
"Resource": [
|
||||
{
|
||||
"Fn::Join": [
|
||||
"",
|
||||
[
|
||||
"arn:",
|
||||
{
|
||||
"Ref": "AWS::Partition"
|
||||
},
|
||||
":s3:::",
|
||||
{
|
||||
"Ref": "ServerlessDeploymentBucket"
|
||||
},
|
||||
"/*"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"Fn::Join": [
|
||||
"",
|
||||
[
|
||||
"arn:",
|
||||
{
|
||||
"Ref": "AWS::Partition"
|
||||
},
|
||||
":s3:::",
|
||||
{
|
||||
"Ref": "ServerlessDeploymentBucket"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
],
|
||||
"Condition": {
|
||||
"Bool": {
|
||||
"aws:SecureTransport": false
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Outputs": {
|
||||
"ServerlessDeploymentBucketName": {
|
||||
"Value": {
|
||||
"Ref": "ServerlessDeploymentBucket"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
404
.serverless/cloudformation-template-update-stack.json
Normal file
404
.serverless/cloudformation-template-update-stack.json
Normal file
@ -0,0 +1,404 @@
|
||||
{
|
||||
"AWSTemplateFormatVersion": "2010-09-09",
|
||||
"Description": "The AWS CloudFormation template for this Serverless application",
|
||||
"Resources": {
|
||||
"ServerlessDeploymentBucket": {
|
||||
"Type": "AWS::S3::Bucket",
|
||||
"Properties": {
|
||||
"BucketEncryption": {
|
||||
"ServerSideEncryptionConfiguration": [
|
||||
{
|
||||
"ServerSideEncryptionByDefault": {
|
||||
"SSEAlgorithm": "AES256"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"ServerlessDeploymentBucketPolicy": {
|
||||
"Type": "AWS::S3::BucketPolicy",
|
||||
"Properties": {
|
||||
"Bucket": {
|
||||
"Ref": "ServerlessDeploymentBucket"
|
||||
},
|
||||
"PolicyDocument": {
|
||||
"Statement": [
|
||||
{
|
||||
"Action": "s3:*",
|
||||
"Effect": "Deny",
|
||||
"Principal": "*",
|
||||
"Resource": [
|
||||
{
|
||||
"Fn::Join": [
|
||||
"",
|
||||
[
|
||||
"arn:",
|
||||
{
|
||||
"Ref": "AWS::Partition"
|
||||
},
|
||||
":s3:::",
|
||||
{
|
||||
"Ref": "ServerlessDeploymentBucket"
|
||||
},
|
||||
"/*"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"Fn::Join": [
|
||||
"",
|
||||
[
|
||||
"arn:",
|
||||
{
|
||||
"Ref": "AWS::Partition"
|
||||
},
|
||||
":s3:::",
|
||||
{
|
||||
"Ref": "ServerlessDeploymentBucket"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
],
|
||||
"Condition": {
|
||||
"Bool": {
|
||||
"aws:SecureTransport": false
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"AppLogGroup": {
|
||||
"Type": "AWS::Logs::LogGroup",
|
||||
"Properties": {
|
||||
"LogGroupName": "/aws/lambda/localstack-lambda-dev-app"
|
||||
}
|
||||
},
|
||||
"IamRoleLambdaExecution": {
|
||||
"Type": "AWS::IAM::Role",
|
||||
"Properties": {
|
||||
"AssumeRolePolicyDocument": {
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"Service": [
|
||||
"lambda.amazonaws.com"
|
||||
]
|
||||
},
|
||||
"Action": [
|
||||
"sts:AssumeRole"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"Policies": [
|
||||
{
|
||||
"PolicyName": {
|
||||
"Fn::Join": [
|
||||
"-",
|
||||
[
|
||||
"localstack-lambda",
|
||||
"dev",
|
||||
"lambda"
|
||||
]
|
||||
]
|
||||
},
|
||||
"PolicyDocument": {
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"logs:CreateLogStream",
|
||||
"logs:CreateLogGroup"
|
||||
],
|
||||
"Resource": [
|
||||
{
|
||||
"Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/localstack-lambda-dev*:*"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"logs:PutLogEvents"
|
||||
],
|
||||
"Resource": [
|
||||
{
|
||||
"Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/localstack-lambda-dev*:*:*"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"Path": "/",
|
||||
"RoleName": {
|
||||
"Fn::Join": [
|
||||
"-",
|
||||
[
|
||||
"localstack-lambda",
|
||||
"dev",
|
||||
{
|
||||
"Ref": "AWS::Region"
|
||||
},
|
||||
"lambdaRole"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"AppLambdaFunction": {
|
||||
"Type": "AWS::Lambda::Function",
|
||||
"Properties": {
|
||||
"Code": {
|
||||
"S3Bucket": {
|
||||
"Ref": "ServerlessDeploymentBucket"
|
||||
},
|
||||
"S3Key": "serverless/localstack-lambda/dev/1620056787473-2021-05-03T15:46:27.473Z/localstack-lambda.zip"
|
||||
},
|
||||
"Handler": "api/server.handler",
|
||||
"Runtime": "nodejs12.x",
|
||||
"FunctionName": "localstack-lambda-dev-app",
|
||||
"MemorySize": 128,
|
||||
"Timeout": 6,
|
||||
"Role": {
|
||||
"Fn::GetAtt": [
|
||||
"IamRoleLambdaExecution",
|
||||
"Arn"
|
||||
]
|
||||
}
|
||||
},
|
||||
"DependsOn": [
|
||||
"AppLogGroup"
|
||||
]
|
||||
},
|
||||
"AppLambdaVersionpKt6OvdECa0w3L8STXgnFAZzVQXb1lv1UQDQyHZmwu8": {
|
||||
"Type": "AWS::Lambda::Version",
|
||||
"DeletionPolicy": "Retain",
|
||||
"Properties": {
|
||||
"FunctionName": {
|
||||
"Ref": "AppLambdaFunction"
|
||||
},
|
||||
"CodeSha256": "ti9O4pTltT2kEw78OJXfrJVusyoy/3C+KWaYQByAA20="
|
||||
}
|
||||
},
|
||||
"ApiGatewayRestApi": {
|
||||
"Type": "AWS::ApiGateway::RestApi",
|
||||
"Properties": {
|
||||
"Name": "dev-localstack-lambda",
|
||||
"EndpointConfiguration": {
|
||||
"Types": [
|
||||
"EDGE"
|
||||
]
|
||||
},
|
||||
"Policy": ""
|
||||
}
|
||||
},
|
||||
"ApiGatewayResourceProxyVar": {
|
||||
"Type": "AWS::ApiGateway::Resource",
|
||||
"Properties": {
|
||||
"ParentId": {
|
||||
"Fn::GetAtt": [
|
||||
"ApiGatewayRestApi",
|
||||
"RootResourceId"
|
||||
]
|
||||
},
|
||||
"PathPart": "{proxy+}",
|
||||
"RestApiId": {
|
||||
"Ref": "ApiGatewayRestApi"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ApiGatewayMethodAny": {
|
||||
"Type": "AWS::ApiGateway::Method",
|
||||
"Properties": {
|
||||
"HttpMethod": "ANY",
|
||||
"RequestParameters": {},
|
||||
"ResourceId": {
|
||||
"Fn::GetAtt": [
|
||||
"ApiGatewayRestApi",
|
||||
"RootResourceId"
|
||||
]
|
||||
},
|
||||
"RestApiId": {
|
||||
"Ref": "ApiGatewayRestApi"
|
||||
},
|
||||
"ApiKeyRequired": false,
|
||||
"AuthorizationType": "NONE",
|
||||
"Integration": {
|
||||
"IntegrationHttpMethod": "POST",
|
||||
"Type": "AWS_PROXY",
|
||||
"Uri": {
|
||||
"Fn::Join": [
|
||||
"",
|
||||
[
|
||||
"arn:",
|
||||
{
|
||||
"Ref": "AWS::Partition"
|
||||
},
|
||||
":apigateway:",
|
||||
{
|
||||
"Ref": "AWS::Region"
|
||||
},
|
||||
":lambda:path/2015-03-31/functions/",
|
||||
{
|
||||
"Fn::GetAtt": [
|
||||
"AppLambdaFunction",
|
||||
"Arn"
|
||||
]
|
||||
},
|
||||
"/invocations"
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"MethodResponses": []
|
||||
}
|
||||
},
|
||||
"ApiGatewayMethodProxyVarAny": {
|
||||
"Type": "AWS::ApiGateway::Method",
|
||||
"Properties": {
|
||||
"HttpMethod": "ANY",
|
||||
"RequestParameters": {},
|
||||
"ResourceId": {
|
||||
"Ref": "ApiGatewayResourceProxyVar"
|
||||
},
|
||||
"RestApiId": {
|
||||
"Ref": "ApiGatewayRestApi"
|
||||
},
|
||||
"ApiKeyRequired": false,
|
||||
"AuthorizationType": "NONE",
|
||||
"Integration": {
|
||||
"IntegrationHttpMethod": "POST",
|
||||
"Type": "AWS_PROXY",
|
||||
"Uri": {
|
||||
"Fn::Join": [
|
||||
"",
|
||||
[
|
||||
"arn:",
|
||||
{
|
||||
"Ref": "AWS::Partition"
|
||||
},
|
||||
":apigateway:",
|
||||
{
|
||||
"Ref": "AWS::Region"
|
||||
},
|
||||
":lambda:path/2015-03-31/functions/",
|
||||
{
|
||||
"Fn::GetAtt": [
|
||||
"AppLambdaFunction",
|
||||
"Arn"
|
||||
]
|
||||
},
|
||||
"/invocations"
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"MethodResponses": []
|
||||
}
|
||||
},
|
||||
"ApiGatewayDeployment1620056783201": {
|
||||
"Type": "AWS::ApiGateway::Deployment",
|
||||
"Properties": {
|
||||
"RestApiId": {
|
||||
"Ref": "ApiGatewayRestApi"
|
||||
},
|
||||
"StageName": "dev"
|
||||
},
|
||||
"DependsOn": [
|
||||
"ApiGatewayMethodAny",
|
||||
"ApiGatewayMethodProxyVarAny"
|
||||
]
|
||||
},
|
||||
"AppLambdaPermissionApiGateway": {
|
||||
"Type": "AWS::Lambda::Permission",
|
||||
"Properties": {
|
||||
"FunctionName": {
|
||||
"Fn::GetAtt": [
|
||||
"AppLambdaFunction",
|
||||
"Arn"
|
||||
]
|
||||
},
|
||||
"Action": "lambda:InvokeFunction",
|
||||
"Principal": "apigateway.amazonaws.com",
|
||||
"SourceArn": {
|
||||
"Fn::Join": [
|
||||
"",
|
||||
[
|
||||
"arn:",
|
||||
{
|
||||
"Ref": "AWS::Partition"
|
||||
},
|
||||
":execute-api:",
|
||||
{
|
||||
"Ref": "AWS::Region"
|
||||
},
|
||||
":",
|
||||
{
|
||||
"Ref": "AWS::AccountId"
|
||||
},
|
||||
":",
|
||||
{
|
||||
"Ref": "ApiGatewayRestApi"
|
||||
},
|
||||
"/*/*"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Outputs": {
|
||||
"ServerlessDeploymentBucketName": {
|
||||
"Value": {
|
||||
"Ref": "ServerlessDeploymentBucket"
|
||||
},
|
||||
"Export": {
|
||||
"Name": "sls-localstack-lambda-dev-ServerlessDeploymentBucketName"
|
||||
}
|
||||
},
|
||||
"AppLambdaFunctionQualifiedArn": {
|
||||
"Description": "Current Lambda function version",
|
||||
"Value": {
|
||||
"Ref": "AppLambdaVersionpKt6OvdECa0w3L8STXgnFAZzVQXb1lv1UQDQyHZmwu8"
|
||||
},
|
||||
"Export": {
|
||||
"Name": "sls-localstack-lambda-dev-AppLambdaFunctionQualifiedArn"
|
||||
}
|
||||
},
|
||||
"ServiceEndpoint": {
|
||||
"Description": "URL of the service endpoint",
|
||||
"Value": {
|
||||
"Fn::Join": [
|
||||
"",
|
||||
[
|
||||
"https://",
|
||||
{
|
||||
"Ref": "ApiGatewayRestApi"
|
||||
},
|
||||
".execute-api.",
|
||||
{
|
||||
"Ref": "AWS::Region"
|
||||
},
|
||||
".",
|
||||
{
|
||||
"Ref": "AWS::URLSuffix"
|
||||
},
|
||||
"/dev"
|
||||
]
|
||||
]
|
||||
},
|
||||
"Export": {
|
||||
"Name": "sls-localstack-lambda-dev-ServiceEndpoint"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
.serverless/localstack-lambda.zip
Normal file
BIN
.serverless/localstack-lambda.zip
Normal file
Binary file not shown.
546
.serverless/serverless-state.json
Normal file
546
.serverless/serverless-state.json
Normal file
@ -0,0 +1,546 @@
|
||||
{
|
||||
"service": {
|
||||
"service": "localstack-lambda",
|
||||
"serviceObject": {
|
||||
"name": "localstack-lambda"
|
||||
},
|
||||
"provider": {
|
||||
"name": "aws",
|
||||
"runtime": "nodejs12.x",
|
||||
"stage": "dev",
|
||||
"region": "us-east-1",
|
||||
"memorySize": 128,
|
||||
"variableSyntax": "\\${([^{}:]+?(?:\\(|:)(?:[^:{}][^{}]*?)?)}",
|
||||
"versionFunctions": true,
|
||||
"compiledCloudFormationTemplate": {
|
||||
"AWSTemplateFormatVersion": "2010-09-09",
|
||||
"Description": "The AWS CloudFormation template for this Serverless application",
|
||||
"Resources": {
|
||||
"ServerlessDeploymentBucket": {
|
||||
"Type": "AWS::S3::Bucket",
|
||||
"Properties": {
|
||||
"BucketEncryption": {
|
||||
"ServerSideEncryptionConfiguration": [
|
||||
{
|
||||
"ServerSideEncryptionByDefault": {
|
||||
"SSEAlgorithm": "AES256"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"ServerlessDeploymentBucketPolicy": {
|
||||
"Type": "AWS::S3::BucketPolicy",
|
||||
"Properties": {
|
||||
"Bucket": {
|
||||
"Ref": "ServerlessDeploymentBucket"
|
||||
},
|
||||
"PolicyDocument": {
|
||||
"Statement": [
|
||||
{
|
||||
"Action": "s3:*",
|
||||
"Effect": "Deny",
|
||||
"Principal": "*",
|
||||
"Resource": [
|
||||
{
|
||||
"Fn::Join": [
|
||||
"",
|
||||
[
|
||||
"arn:",
|
||||
{
|
||||
"Ref": "AWS::Partition"
|
||||
},
|
||||
":s3:::",
|
||||
{
|
||||
"Ref": "ServerlessDeploymentBucket"
|
||||
},
|
||||
"/*"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"Fn::Join": [
|
||||
"",
|
||||
[
|
||||
"arn:",
|
||||
{
|
||||
"Ref": "AWS::Partition"
|
||||
},
|
||||
":s3:::",
|
||||
{
|
||||
"Ref": "ServerlessDeploymentBucket"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
],
|
||||
"Condition": {
|
||||
"Bool": {
|
||||
"aws:SecureTransport": false
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"AppLogGroup": {
|
||||
"Type": "AWS::Logs::LogGroup",
|
||||
"Properties": {
|
||||
"LogGroupName": "/aws/lambda/localstack-lambda-dev-app"
|
||||
}
|
||||
},
|
||||
"IamRoleLambdaExecution": {
|
||||
"Type": "AWS::IAM::Role",
|
||||
"Properties": {
|
||||
"AssumeRolePolicyDocument": {
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"Service": [
|
||||
"lambda.amazonaws.com"
|
||||
]
|
||||
},
|
||||
"Action": [
|
||||
"sts:AssumeRole"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"Policies": [
|
||||
{
|
||||
"PolicyName": {
|
||||
"Fn::Join": [
|
||||
"-",
|
||||
[
|
||||
"localstack-lambda",
|
||||
"dev",
|
||||
"lambda"
|
||||
]
|
||||
]
|
||||
},
|
||||
"PolicyDocument": {
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"logs:CreateLogStream",
|
||||
"logs:CreateLogGroup"
|
||||
],
|
||||
"Resource": [
|
||||
{
|
||||
"Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/localstack-lambda-dev*:*"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"logs:PutLogEvents"
|
||||
],
|
||||
"Resource": [
|
||||
{
|
||||
"Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/localstack-lambda-dev*:*:*"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"Path": "/",
|
||||
"RoleName": {
|
||||
"Fn::Join": [
|
||||
"-",
|
||||
[
|
||||
"localstack-lambda",
|
||||
"dev",
|
||||
{
|
||||
"Ref": "AWS::Region"
|
||||
},
|
||||
"lambdaRole"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"AppLambdaFunction": {
|
||||
"Type": "AWS::Lambda::Function",
|
||||
"Properties": {
|
||||
"Code": {
|
||||
"S3Bucket": {
|
||||
"Ref": "ServerlessDeploymentBucket"
|
||||
},
|
||||
"S3Key": "serverless/localstack-lambda/dev/1620056787473-2021-05-03T15:46:27.473Z/localstack-lambda.zip"
|
||||
},
|
||||
"Handler": "api/server.handler",
|
||||
"Runtime": "nodejs12.x",
|
||||
"FunctionName": "localstack-lambda-dev-app",
|
||||
"MemorySize": 128,
|
||||
"Timeout": 6,
|
||||
"Role": {
|
||||
"Fn::GetAtt": [
|
||||
"IamRoleLambdaExecution",
|
||||
"Arn"
|
||||
]
|
||||
}
|
||||
},
|
||||
"DependsOn": [
|
||||
"AppLogGroup"
|
||||
]
|
||||
},
|
||||
"AppLambdaVersionpKt6OvdECa0w3L8STXgnFAZzVQXb1lv1UQDQyHZmwu8": {
|
||||
"Type": "AWS::Lambda::Version",
|
||||
"DeletionPolicy": "Retain",
|
||||
"Properties": {
|
||||
"FunctionName": {
|
||||
"Ref": "AppLambdaFunction"
|
||||
},
|
||||
"CodeSha256": "ti9O4pTltT2kEw78OJXfrJVusyoy/3C+KWaYQByAA20="
|
||||
}
|
||||
},
|
||||
"ApiGatewayRestApi": {
|
||||
"Type": "AWS::ApiGateway::RestApi",
|
||||
"Properties": {
|
||||
"Name": "dev-localstack-lambda",
|
||||
"EndpointConfiguration": {
|
||||
"Types": [
|
||||
"EDGE"
|
||||
]
|
||||
},
|
||||
"Policy": ""
|
||||
}
|
||||
},
|
||||
"ApiGatewayResourceProxyVar": {
|
||||
"Type": "AWS::ApiGateway::Resource",
|
||||
"Properties": {
|
||||
"ParentId": {
|
||||
"Fn::GetAtt": [
|
||||
"ApiGatewayRestApi",
|
||||
"RootResourceId"
|
||||
]
|
||||
},
|
||||
"PathPart": "{proxy+}",
|
||||
"RestApiId": {
|
||||
"Ref": "ApiGatewayRestApi"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ApiGatewayMethodAny": {
|
||||
"Type": "AWS::ApiGateway::Method",
|
||||
"Properties": {
|
||||
"HttpMethod": "ANY",
|
||||
"RequestParameters": {},
|
||||
"ResourceId": {
|
||||
"Fn::GetAtt": [
|
||||
"ApiGatewayRestApi",
|
||||
"RootResourceId"
|
||||
]
|
||||
},
|
||||
"RestApiId": {
|
||||
"Ref": "ApiGatewayRestApi"
|
||||
},
|
||||
"ApiKeyRequired": false,
|
||||
"AuthorizationType": "NONE",
|
||||
"Integration": {
|
||||
"IntegrationHttpMethod": "POST",
|
||||
"Type": "AWS_PROXY",
|
||||
"Uri": {
|
||||
"Fn::Join": [
|
||||
"",
|
||||
[
|
||||
"arn:",
|
||||
{
|
||||
"Ref": "AWS::Partition"
|
||||
},
|
||||
":apigateway:",
|
||||
{
|
||||
"Ref": "AWS::Region"
|
||||
},
|
||||
":lambda:path/2015-03-31/functions/",
|
||||
{
|
||||
"Fn::GetAtt": [
|
||||
"AppLambdaFunction",
|
||||
"Arn"
|
||||
]
|
||||
},
|
||||
"/invocations"
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"MethodResponses": []
|
||||
}
|
||||
},
|
||||
"ApiGatewayMethodProxyVarAny": {
|
||||
"Type": "AWS::ApiGateway::Method",
|
||||
"Properties": {
|
||||
"HttpMethod": "ANY",
|
||||
"RequestParameters": {},
|
||||
"ResourceId": {
|
||||
"Ref": "ApiGatewayResourceProxyVar"
|
||||
},
|
||||
"RestApiId": {
|
||||
"Ref": "ApiGatewayRestApi"
|
||||
},
|
||||
"ApiKeyRequired": false,
|
||||
"AuthorizationType": "NONE",
|
||||
"Integration": {
|
||||
"IntegrationHttpMethod": "POST",
|
||||
"Type": "AWS_PROXY",
|
||||
"Uri": {
|
||||
"Fn::Join": [
|
||||
"",
|
||||
[
|
||||
"arn:",
|
||||
{
|
||||
"Ref": "AWS::Partition"
|
||||
},
|
||||
":apigateway:",
|
||||
{
|
||||
"Ref": "AWS::Region"
|
||||
},
|
||||
":lambda:path/2015-03-31/functions/",
|
||||
{
|
||||
"Fn::GetAtt": [
|
||||
"AppLambdaFunction",
|
||||
"Arn"
|
||||
]
|
||||
},
|
||||
"/invocations"
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"MethodResponses": []
|
||||
}
|
||||
},
|
||||
"ApiGatewayDeployment1620056783201": {
|
||||
"Type": "AWS::ApiGateway::Deployment",
|
||||
"Properties": {
|
||||
"RestApiId": {
|
||||
"Ref": "ApiGatewayRestApi"
|
||||
},
|
||||
"StageName": "dev"
|
||||
},
|
||||
"DependsOn": [
|
||||
"ApiGatewayMethodAny",
|
||||
"ApiGatewayMethodProxyVarAny"
|
||||
]
|
||||
},
|
||||
"AppLambdaPermissionApiGateway": {
|
||||
"Type": "AWS::Lambda::Permission",
|
||||
"Properties": {
|
||||
"FunctionName": {
|
||||
"Fn::GetAtt": [
|
||||
"AppLambdaFunction",
|
||||
"Arn"
|
||||
]
|
||||
},
|
||||
"Action": "lambda:InvokeFunction",
|
||||
"Principal": "apigateway.amazonaws.com",
|
||||
"SourceArn": {
|
||||
"Fn::Join": [
|
||||
"",
|
||||
[
|
||||
"arn:",
|
||||
{
|
||||
"Ref": "AWS::Partition"
|
||||
},
|
||||
":execute-api:",
|
||||
{
|
||||
"Ref": "AWS::Region"
|
||||
},
|
||||
":",
|
||||
{
|
||||
"Ref": "AWS::AccountId"
|
||||
},
|
||||
":",
|
||||
{
|
||||
"Ref": "ApiGatewayRestApi"
|
||||
},
|
||||
"/*/*"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Outputs": {
|
||||
"ServerlessDeploymentBucketName": {
|
||||
"Value": {
|
||||
"Ref": "ServerlessDeploymentBucket"
|
||||
},
|
||||
"Export": {
|
||||
"Name": "sls-localstack-lambda-dev-ServerlessDeploymentBucketName"
|
||||
}
|
||||
},
|
||||
"AppLambdaFunctionQualifiedArn": {
|
||||
"Description": "Current Lambda function version",
|
||||
"Value": {
|
||||
"Ref": "AppLambdaVersionpKt6OvdECa0w3L8STXgnFAZzVQXb1lv1UQDQyHZmwu8"
|
||||
},
|
||||
"Export": {
|
||||
"Name": "sls-localstack-lambda-dev-AppLambdaFunctionQualifiedArn"
|
||||
}
|
||||
},
|
||||
"ServiceEndpoint": {
|
||||
"Description": "URL of the service endpoint",
|
||||
"Value": {
|
||||
"Fn::Join": [
|
||||
"",
|
||||
[
|
||||
"https://",
|
||||
{
|
||||
"Ref": "ApiGatewayRestApi"
|
||||
},
|
||||
".execute-api.",
|
||||
{
|
||||
"Ref": "AWS::Region"
|
||||
},
|
||||
".",
|
||||
{
|
||||
"Ref": "AWS::URLSuffix"
|
||||
},
|
||||
"/dev"
|
||||
]
|
||||
]
|
||||
},
|
||||
"Export": {
|
||||
"Name": "sls-localstack-lambda-dev-ServiceEndpoint"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"coreCloudFormationTemplate": {
|
||||
"AWSTemplateFormatVersion": "2010-09-09",
|
||||
"Description": "The AWS CloudFormation template for this Serverless application",
|
||||
"Resources": {
|
||||
"ServerlessDeploymentBucket": {
|
||||
"Type": "AWS::S3::Bucket",
|
||||
"Properties": {
|
||||
"BucketEncryption": {
|
||||
"ServerSideEncryptionConfiguration": [
|
||||
{
|
||||
"ServerSideEncryptionByDefault": {
|
||||
"SSEAlgorithm": "AES256"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"ServerlessDeploymentBucketPolicy": {
|
||||
"Type": "AWS::S3::BucketPolicy",
|
||||
"Properties": {
|
||||
"Bucket": {
|
||||
"Ref": "ServerlessDeploymentBucket"
|
||||
},
|
||||
"PolicyDocument": {
|
||||
"Statement": [
|
||||
{
|
||||
"Action": "s3:*",
|
||||
"Effect": "Deny",
|
||||
"Principal": "*",
|
||||
"Resource": [
|
||||
{
|
||||
"Fn::Join": [
|
||||
"",
|
||||
[
|
||||
"arn:",
|
||||
{
|
||||
"Ref": "AWS::Partition"
|
||||
},
|
||||
":s3:::",
|
||||
{
|
||||
"Ref": "ServerlessDeploymentBucket"
|
||||
},
|
||||
"/*"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"Fn::Join": [
|
||||
"",
|
||||
[
|
||||
"arn:",
|
||||
{
|
||||
"Ref": "AWS::Partition"
|
||||
},
|
||||
":s3:::",
|
||||
{
|
||||
"Ref": "ServerlessDeploymentBucket"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
],
|
||||
"Condition": {
|
||||
"Bool": {
|
||||
"aws:SecureTransport": false
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Outputs": {
|
||||
"ServerlessDeploymentBucketName": {
|
||||
"Value": {
|
||||
"Ref": "ServerlessDeploymentBucket"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"vpc": {}
|
||||
},
|
||||
"pluginsData": {},
|
||||
"functions": {
|
||||
"app": {
|
||||
"handler": "api/server.handler",
|
||||
"events": [
|
||||
{
|
||||
"http": "ANY /"
|
||||
},
|
||||
{
|
||||
"http": "ANY {proxy+}"
|
||||
}
|
||||
],
|
||||
"name": "localstack-lambda-dev-app",
|
||||
"package": {},
|
||||
"memory": 128,
|
||||
"timeout": 6,
|
||||
"runtime": "nodejs12.x",
|
||||
"vpc": {},
|
||||
"versionLogicalId": "AppLambdaVersionpKt6OvdECa0w3L8STXgnFAZzVQXb1lv1UQDQyHZmwu8"
|
||||
}
|
||||
},
|
||||
"configValidationMode": "warn",
|
||||
"serviceFilename": "serverless.yml",
|
||||
"layers": {},
|
||||
"initialServerlessConfig": {
|
||||
"service": {
|
||||
"$ref": "$[\"service\"][\"serviceObject\"]"
|
||||
},
|
||||
"frameworkVersion": "2",
|
||||
"provider": {
|
||||
"$ref": "$[\"service\"][\"provider\"]"
|
||||
},
|
||||
"functions": {
|
||||
"$ref": "$[\"service\"][\"functions\"]"
|
||||
}
|
||||
},
|
||||
"isDashboardMonitoringPreconfigured": false,
|
||||
"artifact": "/Users/duncanphelps/Documents/Learning/Javascript/sheetaki/sheetaki/.serverless/localstack-lambda.zip"
|
||||
},
|
||||
"package": {
|
||||
"artifactDirectoryName": "serverless/localstack-lambda/dev/1620056787473-2021-05-03T15:46:27.473Z",
|
||||
"artifact": "localstack-lambda.zip"
|
||||
}
|
||||
}
|
@ -6,10 +6,11 @@ const AWS = require('aws-sdk');
|
||||
module.exports = function (req, res) {
|
||||
res.setHeader('Access-Control-Allow-Origin', '*');
|
||||
const url = URL.parse(req.url, true);
|
||||
const s3 = new AWS.S3({ endpoint: 'http://localhost:4566', s3ForcePathStyle: true });
|
||||
// const s3 = new AWS.S3({ endpoint: 'http://localhost:4566', s3ForcePathStyle: true });
|
||||
const s3 = new AWS.S3();
|
||||
|
||||
const getFile = (filename) => {
|
||||
s3.getObject({ Bucket: 'localstacktest', Key: filename }, function (err, data) {
|
||||
s3.getObject({ Bucket: 'sheetaki-test', Key: filename }, function (err, data) {
|
||||
if (err) return res.status(500).send(err.message || err);
|
||||
do_wb(req, data.Body, url, res);
|
||||
});
|
||||
|
@ -7,7 +7,8 @@ const AWS = require('aws-sdk');
|
||||
module.exports = function (req, res) {
|
||||
res.setHeader('Access-Control-Allow-Origin', '*');
|
||||
const url = URL.parse(req.url, true);
|
||||
const s3 = new AWS.S3({ endpoint: 'http://localhost:4566', s3ForcePathStyle: true });
|
||||
// const s3 = new AWS.S3({ endpoint: 'http://localhost:4566', s3ForcePathStyle: true });
|
||||
const s3 = new AWS.S3();
|
||||
|
||||
/* parse form data */
|
||||
const form = formidable({ multiples: true, maxFileSize: 2 * 1024 * 1024 });
|
||||
@ -30,7 +31,7 @@ module.exports = function (req, res) {
|
||||
filename = filename.split("/");
|
||||
filename = filename[filename.length-1]
|
||||
const params = {
|
||||
Bucket: "localstacktest",
|
||||
Bucket: "sheetaki-test",
|
||||
Key: filename,
|
||||
Body: file
|
||||
};
|
||||
|
@ -1,3 +1,4 @@
|
||||
const serverless = require('serverless-http');
|
||||
const express = require('express');
|
||||
const app = express();
|
||||
const data = require('./data/index');
|
||||
@ -17,6 +18,7 @@ app.use('/api/upload', upload);
|
||||
app.use('/api/save', save);
|
||||
app.use('/api/file', file);
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Listening on port: ${port}`);
|
||||
});
|
||||
// app.listen(port, () => {
|
||||
// console.log(`Listening on port: ${port}`);
|
||||
// });
|
||||
module.exports.handler = serverless(app);
|
14
docker-compose.yml
Executable file
14
docker-compose.yml
Executable file
@ -0,0 +1,14 @@
|
||||
version: '3.1'
|
||||
|
||||
services:
|
||||
localstack:
|
||||
image: localstack/localstack:latest
|
||||
environment:
|
||||
- AWS_DEFAULT_REGION=us-east-1
|
||||
- EDGE_PORT=4566
|
||||
- SERVICES=lambda,s3,cloudformation,sts,apigateway,iam,route53
|
||||
ports:
|
||||
- '4566-4597:4566-4597'
|
||||
volumes:
|
||||
- "${TEMPDIR:-/tmp/localstack}:/temp/localstack"
|
||||
- "/var/run/docker.sock:/var/run/docker.sock"
|
6
localstack_endpoints.json
Executable file
6
localstack_endpoints.json
Executable file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"CloudFormation" : "http://localhost:4566",
|
||||
"CloudWatch" : "http://localhost:4566",
|
||||
"Lambda" : "http://localhost:4566",
|
||||
"S3" : "http://localhost:4566"
|
||||
}
|
61
package-lock.json
generated
61
package-lock.json
generated
@ -13,10 +13,18 @@
|
||||
"express": "^4.17.1",
|
||||
"formidable-serverless": "",
|
||||
"request": "",
|
||||
"serverless-http": "^2.7.0",
|
||||
"serverless-localstack": "^0.4.30",
|
||||
"tmp": "^0.2.1",
|
||||
"xlsx": ""
|
||||
}
|
||||
},
|
||||
"node_modules/@types/aws-lambda": {
|
||||
"version": "8.10.76",
|
||||
"resolved": "https://registry.npmjs.org/@types/aws-lambda/-/aws-lambda-8.10.76.tgz",
|
||||
"integrity": "sha512-lCTyeRm3NWqSwDnoji0z82Pl0tsOpr1p+33AiNeidgarloWXh3wdiVRUuxEa+sY9S5YLOYGz5X3N3Zvpibvm5w==",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/accepts": {
|
||||
"version": "1.3.7",
|
||||
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
|
||||
@ -387,6 +395,11 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/es6-promisify": {
|
||||
"version": "6.1.1",
|
||||
"resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-6.1.1.tgz",
|
||||
"integrity": "sha512-HBL8I3mIki5C1Cc9QjKUenHtnG0A5/xA8Q/AllRcfiwl2CZFXGK7ddBiCoRwAix4i2KxcQfjtIVcrVbB3vbmwg=="
|
||||
},
|
||||
"node_modules/escape-html": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
|
||||
@ -1045,6 +1058,26 @@
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/serverless-http": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/serverless-http/-/serverless-http-2.7.0.tgz",
|
||||
"integrity": "sha512-iWq0z1X2Xkuvz6wL305uCux/SypbojHlYsB5bzmF5TqoLYsdvMNIoCsgtWjwqWoo3AR2cjw3zAmHN2+U6mF99Q==",
|
||||
"engines": {
|
||||
"node": ">=8.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@types/aws-lambda": "^8.10.56"
|
||||
}
|
||||
},
|
||||
"node_modules/serverless-localstack": {
|
||||
"version": "0.4.30",
|
||||
"resolved": "https://registry.npmjs.org/serverless-localstack/-/serverless-localstack-0.4.30.tgz",
|
||||
"integrity": "sha512-x0lVIcWE1id6EpVK/N/dhpp2yWDwb8Pbru8JDF3fFCNK9w+KR+WOUlmNL7Knpg+5mlcZjEvrza+s+QXLBIhMTg==",
|
||||
"dependencies": {
|
||||
"aws-sdk": "^2.402.0",
|
||||
"es6-promisify": "^6.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/setprototypeof": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
|
||||
@ -1282,6 +1315,12 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/aws-lambda": {
|
||||
"version": "8.10.76",
|
||||
"resolved": "https://registry.npmjs.org/@types/aws-lambda/-/aws-lambda-8.10.76.tgz",
|
||||
"integrity": "sha512-lCTyeRm3NWqSwDnoji0z82Pl0tsOpr1p+33AiNeidgarloWXh3wdiVRUuxEa+sY9S5YLOYGz5X3N3Zvpibvm5w==",
|
||||
"optional": true
|
||||
},
|
||||
"accepts": {
|
||||
"version": "1.3.7",
|
||||
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
|
||||
@ -1576,6 +1615,11 @@
|
||||
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
|
||||
"integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
|
||||
},
|
||||
"es6-promisify": {
|
||||
"version": "6.1.1",
|
||||
"resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-6.1.1.tgz",
|
||||
"integrity": "sha512-HBL8I3mIki5C1Cc9QjKUenHtnG0A5/xA8Q/AllRcfiwl2CZFXGK7ddBiCoRwAix4i2KxcQfjtIVcrVbB3vbmwg=="
|
||||
},
|
||||
"escape-html": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
|
||||
@ -2102,6 +2146,23 @@
|
||||
"send": "0.17.1"
|
||||
}
|
||||
},
|
||||
"serverless-http": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/serverless-http/-/serverless-http-2.7.0.tgz",
|
||||
"integrity": "sha512-iWq0z1X2Xkuvz6wL305uCux/SypbojHlYsB5bzmF5TqoLYsdvMNIoCsgtWjwqWoo3AR2cjw3zAmHN2+U6mF99Q==",
|
||||
"requires": {
|
||||
"@types/aws-lambda": "^8.10.56"
|
||||
}
|
||||
},
|
||||
"serverless-localstack": {
|
||||
"version": "0.4.30",
|
||||
"resolved": "https://registry.npmjs.org/serverless-localstack/-/serverless-localstack-0.4.30.tgz",
|
||||
"integrity": "sha512-x0lVIcWE1id6EpVK/N/dhpp2yWDwb8Pbru8JDF3fFCNK9w+KR+WOUlmNL7Knpg+5mlcZjEvrza+s+QXLBIhMTg==",
|
||||
"requires": {
|
||||
"aws-sdk": "^2.402.0",
|
||||
"es6-promisify": "^6.0.1"
|
||||
}
|
||||
},
|
||||
"setprototypeof": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
|
||||
|
@ -16,6 +16,8 @@
|
||||
"express": "^4.17.1",
|
||||
"formidable-serverless": "",
|
||||
"request": "",
|
||||
"serverless-http": "^2.7.0",
|
||||
"serverless-localstack": "^0.4.30",
|
||||
"tmp": "^0.2.1",
|
||||
"xlsx": ""
|
||||
},
|
||||
|
28
serverless.yml
Executable file
28
serverless.yml
Executable file
@ -0,0 +1,28 @@
|
||||
service: localstack-lambda
|
||||
# plugins:
|
||||
# - serverless-localstack
|
||||
|
||||
# custom:
|
||||
# localstack:
|
||||
# debug: true
|
||||
# stages:
|
||||
# - local
|
||||
# - dev
|
||||
# host: http://localhost # optional - LocalStack host to connect to
|
||||
# edgePort: 4566 # optional - LocalStack edge port to connect to
|
||||
# endpointFile: localstack_endpoints.json
|
||||
|
||||
frameworkVersion: '2'
|
||||
|
||||
provider:
|
||||
name: aws
|
||||
runtime: nodejs12.x
|
||||
stage: dev
|
||||
region: us-east-1
|
||||
memorySize: 128
|
||||
functions:
|
||||
app:
|
||||
handler: api/server.handler
|
||||
events:
|
||||
- http: ANY /
|
||||
- http: 'ANY {proxy+}'
|
Loading…
Reference in New Issue
Block a user