-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
debug and implement update and post accommodation through api
- Loading branch information
1 parent
448dbaa
commit 50f500c
Showing
18 changed files
with
511 additions
and
57 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
6 changes: 6 additions & 0 deletions
6
amplify/backend/function/generateEncryptionKeyAPI/amplify.state
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,6 @@ | ||
{ | ||
"pluginId": "amplify-nodejs-function-runtime-provider", | ||
"functionRuntime": "nodejs", | ||
"useLegacyBuild": true, | ||
"defaultEditorFile": "src\\index.js" | ||
} |
6 changes: 6 additions & 0 deletions
6
amplify/backend/function/generateEncryptionKeyAPI/custom-policies.json
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,6 @@ | ||
[ | ||
{ | ||
"Action": [], | ||
"Resource": [] | ||
} | ||
] |
3 changes: 3 additions & 0 deletions
3
amplify/backend/function/generateEncryptionKeyAPI/function-parameters.json
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 @@ | ||
{ | ||
"lambdaLayers": [] | ||
} |
202 changes: 202 additions & 0 deletions
202
...d/function/generateEncryptionKeyAPI/generateEncryptionKeyAPI-cloudformation-template.json
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,202 @@ | ||
{ | ||
"AWSTemplateFormatVersion": "2010-09-09", | ||
"Description": "{\"createdOn\":\"Windows\",\"createdBy\":\"Amplify\",\"createdWith\":\"12.13.0\",\"stackType\":\"function-Lambda\",\"metadata\":{\"whyContinueWithGen1\":\"\"}}", | ||
"Parameters": { | ||
"CloudWatchRule": { | ||
"Type": "String", | ||
"Default": "NONE", | ||
"Description": " Schedule Expression" | ||
}, | ||
"deploymentBucketName": { | ||
"Type": "String" | ||
}, | ||
"env": { | ||
"Type": "String" | ||
}, | ||
"s3Key": { | ||
"Type": "String" | ||
} | ||
}, | ||
"Conditions": { | ||
"ShouldNotCreateEnvResources": { | ||
"Fn::Equals": [ | ||
{ | ||
"Ref": "env" | ||
}, | ||
"NONE" | ||
] | ||
} | ||
}, | ||
"Resources": { | ||
"LambdaFunction": { | ||
"Type": "AWS::Lambda::Function", | ||
"Metadata": { | ||
"aws:asset:path": "./src", | ||
"aws:asset:property": "Code" | ||
}, | ||
"Properties": { | ||
"Code": { | ||
"S3Bucket": { | ||
"Ref": "deploymentBucketName" | ||
}, | ||
"S3Key": { | ||
"Ref": "s3Key" | ||
} | ||
}, | ||
"Handler": "index.handler", | ||
"FunctionName": { | ||
"Fn::If": [ | ||
"ShouldNotCreateEnvResources", | ||
"generateEncryptionKeyAPI", | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"generateEncryptionKeyAPI", | ||
"-", | ||
{ | ||
"Ref": "env" | ||
} | ||
] | ||
] | ||
} | ||
] | ||
}, | ||
"Environment": { | ||
"Variables": { | ||
"ENV": { | ||
"Ref": "env" | ||
}, | ||
"REGION": { | ||
"Ref": "AWS::Region" | ||
} | ||
} | ||
}, | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"LambdaExecutionRole", | ||
"Arn" | ||
] | ||
}, | ||
"Runtime": "nodejs18.x", | ||
"Layers": [], | ||
"Timeout": 25 | ||
} | ||
}, | ||
"LambdaExecutionRole": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"RoleName": { | ||
"Fn::If": [ | ||
"ShouldNotCreateEnvResources", | ||
"unirentLambdaRolef4eecc0c", | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"unirentLambdaRolef4eecc0c", | ||
"-", | ||
{ | ||
"Ref": "env" | ||
} | ||
] | ||
] | ||
} | ||
] | ||
}, | ||
"AssumeRolePolicyDocument": { | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": [ | ||
"lambda.amazonaws.com" | ||
] | ||
}, | ||
"Action": [ | ||
"sts:AssumeRole" | ||
] | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"lambdaexecutionpolicy": { | ||
"DependsOn": [ | ||
"LambdaExecutionRole" | ||
], | ||
"Type": "AWS::IAM::Policy", | ||
"Properties": { | ||
"PolicyName": "lambda-execution-policy", | ||
"Roles": [ | ||
{ | ||
"Ref": "LambdaExecutionRole" | ||
} | ||
], | ||
"PolicyDocument": { | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"logs:CreateLogGroup", | ||
"logs:CreateLogStream", | ||
"logs:PutLogEvents" | ||
], | ||
"Resource": { | ||
"Fn::Sub": [ | ||
"arn:aws:logs:${region}:${account}:log-group:/aws/lambda/${lambda}:log-stream:*", | ||
{ | ||
"region": { | ||
"Ref": "AWS::Region" | ||
}, | ||
"account": { | ||
"Ref": "AWS::AccountId" | ||
}, | ||
"lambda": { | ||
"Ref": "LambdaFunction" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"Outputs": { | ||
"Name": { | ||
"Value": { | ||
"Ref": "LambdaFunction" | ||
} | ||
}, | ||
"Arn": { | ||
"Value": { | ||
"Fn::GetAtt": [ | ||
"LambdaFunction", | ||
"Arn" | ||
] | ||
} | ||
}, | ||
"Region": { | ||
"Value": { | ||
"Ref": "AWS::Region" | ||
} | ||
}, | ||
"LambdaExecutionRole": { | ||
"Value": { | ||
"Ref": "LambdaExecutionRole" | ||
} | ||
}, | ||
"LambdaExecutionRoleArn": { | ||
"Value": { | ||
"Fn::GetAtt": [ | ||
"LambdaExecutionRole", | ||
"Arn" | ||
] | ||
} | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
amplify/backend/function/generateEncryptionKeyAPI/src/event.json
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,5 @@ | ||
{ | ||
"key1": "value1", | ||
"key2": "value2", | ||
"key3": "value3" | ||
} |
24 changes: 24 additions & 0 deletions
24
amplify/backend/function/generateEncryptionKeyAPI/src/index.js
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,24 @@ | ||
const AWS = require("aws-sdk"); | ||
const kms = new AWS.KMS(); | ||
|
||
AWS.config.update({ region: "ap-southeast-1" }); | ||
|
||
exports.handler = async (event) => { | ||
console.log(`EVENT: ${JSON.stringify(event)}`); | ||
try { | ||
const dekParams = { KeyId: keyId, KeySpec: "AES_256" }; | ||
const dekResponse = await kms.generateDataKey(dekParams).promise(); | ||
const plaintextDek = dekResponse.Plaintext.toString("base64"); | ||
console.log("plaintextDek: " + plaintextDek); | ||
return { | ||
statusCode: 200, | ||
body: JSON.stringify({ dek: plaintextDek }) | ||
}; | ||
} catch (error) { | ||
console.error("Error generating DEK:", error); | ||
return { | ||
statusCode: 500, | ||
body: JSON.stringify({ error: error.message }), | ||
}; | ||
} | ||
}; |
10 changes: 10 additions & 0 deletions
10
amplify/backend/function/generateEncryptionKeyAPI/src/package.json
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,10 @@ | ||
{ | ||
"name": "generateencryptionkeyapi", | ||
"version": "2.0.0", | ||
"description": "Lambda function generated by Amplify", | ||
"main": "index.js", | ||
"license": "Apache-2.0", | ||
"devDependencies": { | ||
"@types/aws-lambda": "^8.10.92" | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
amplify/backend/function/generateEncryptionKeyAPI/src/yarn.lock
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,8 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
"@types/aws-lambda@^8.10.92": | ||
version "8.10.145" | ||
resolved "https://registry.yarnpkg.com/@types/aws-lambda/-/aws-lambda-8.10.145.tgz#b2d31a987f4888e5553ff1819f57cafa475594d9" | ||
integrity sha512-dtByW6WiFk5W5Jfgz1VM+YPA21xMXTuSFoLYIDY0L44jDLLflVPtZkYuu3/YxpGcvjzKFBZLU+GyKjR0HOYtyw== |
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
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
Oops, something went wrong.