Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cloud-monitor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Edouard DE BRYE
cloud-monitor
Commits
8e4a3cfe
Commit
8e4a3cfe
authored
4 years ago
by
Edouard DE BRYE
Browse files
Options
Downloads
Patches
Plain Diff
added lambda provisionning
parent
52be5bf0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
deploy/cloudwatch_api_logs.tf
+1
-1
1 addition, 1 deletion
deploy/cloudwatch_api_logs.tf
deploy/lambda.tf
+22
-2
22 additions, 2 deletions
deploy/lambda.tf
deploy/lambda/src/create-one.js
+1
-0
1 addition, 0 deletions
deploy/lambda/src/create-one.js
with
24 additions
and
3 deletions
deploy/cloudwatch_api_logs.tf
+
1
−
1
View file @
8e4a3cfe
...
...
@@ -61,7 +61,7 @@ resource "aws_iam_role_policy_attachment" "lambda_apigw" {
}
resource
"aws_iam_policy"
"apigw_read_only"
{
name
=
"ApiGatewayReadOnly"
name
=
"
${
local
.
prefix
}
-
ApiGatewayReadOnly"
path
=
"/"
description
=
"Read only for describing APIGateway services"
# Terraform's "jsonencode" function converts a
...
...
This diff is collapsed.
Click to expand it.
deploy/lambda.tf
+
22
−
2
View file @
8e4a3cfe
...
...
@@ -9,9 +9,10 @@ resource "aws_lambda_function" "crud" {
role
=
aws_iam_role
.
iam_for_lambda
.
arn
handler
=
"
${
each
.
key
}
.handler"
timeout
=
10
source_code_hash
=
filebase64sha256
(
data
.
archive_file
.
lambda_file
.
output_
path
)
source_code_hash
=
data
.
archive_file
.
lambda_file
.
output_
base64sha256
runtime
=
"nodejs12.x"
reserved_concurrent_executions
=
2
publish
=
true
layers
=
[
"arn:aws:lambda:eu-west-1:580247275435:layer:LambdaInsightsExtension:14"
]
...
...
@@ -36,7 +37,7 @@ resource "aws_lambda_function" "index" {
role
=
aws_iam_role
.
iam_for_lambda
.
arn
handler
=
"index.handler"
timeout
=
10
source_code_hash
=
filebase64sha256
(
data
.
archive_file
.
lambda_index_file
.
output_
path
)
source_code_hash
=
data
.
archive_file
.
lambda_index_file
.
output_
base64sha256
runtime
=
"nodejs12.x"
reserved_concurrent_executions
=
2
layers
=
[
...
...
@@ -46,6 +47,10 @@ resource "aws_lambda_function" "index" {
tags
=
local
.
common_tags
}
###############
# Permissions #
###############
resource
"aws_iam_role"
"iam_for_lambda"
{
name
=
"
${
local
.
prefix
}
-lambda"
assume_role_policy
=
file
(
"./templates/lambda/assume-role-policy.json"
)
...
...
@@ -75,6 +80,10 @@ resource "aws_iam_role_policy_attachment" "lambda_insights" {
policy_arn
=
"arn:aws:iam::aws:policy/CloudWatchLambdaInsightsExecutionRolePolicy"
}
#########
# Files #
#########
data
"archive_file"
"lambda_file"
{
type
=
"zip"
output_path
=
"
${
local
.
lambda_loc
}
/zip/lambda.zip"
...
...
@@ -86,3 +95,14 @@ data "archive_file" "lambda_index_file" {
output_path
=
"
${
local
.
lambda_loc
}
/zip/index.zip"
source_file
=
"
${
local
.
lambda_loc
}
/src/index.js"
}
#################
# Provisionning #
#################
resource
"aws_lambda_provisioned_concurrency_config"
"crud"
{
for_each
=
local
.
lambdas
function_name
=
aws_lambda_function
.
crud
[
each
.
key
].
function_name
provisioned_concurrent_executions
=
1
qualifier
=
aws_lambda_function
.
crud
[
each
.
key
].
version
}
This diff is collapsed.
Click to expand it.
deploy/lambda/src/create-one.js
+
1
−
0
View file @
8e4a3cfe
...
...
@@ -5,6 +5,7 @@ const {v4:uuidv4} = require('uuid');
const
TABLE_NAME
=
process
.
env
.
TABLE_NAME
||
''
;
const
PRIMARY_KEY
=
process
.
env
.
TABLE_KEY
||
''
;
const
RESERVED_RESPONSE
=
`Error: You're using AWS reserved keywords as attributes`
,
DYNAMODB_EXECUTION_ERROR
=
`Error: Execution update, caused a Dynamodb error, please take a look at your CloudWatch Logs.`
;
exports
.
handler
=
async
(
event
=
{})
=>
{
console
.
log
(
event
)
if
(
!
event
.
body
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment