-
Notifications
You must be signed in to change notification settings - Fork 251
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
24 changed files
with
3,549 additions
and
12 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
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
16 changes: 16 additions & 0 deletions
16
...snapshot/asset.0ac0535f48d1ada09cde7f11fc72195d9d32da75a2719aeb20c4e5c45b28e62e/index.mjs
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,16 @@ | ||
export const handler = async (event) => { | ||
switch (event.httpMethod) { | ||
case 'POST': | ||
return { | ||
statusCode: 200, | ||
body: JSON.stringify({"message": "NEW - successfully handled POST from messages lambda"}) | ||
}; | ||
case 'GET': | ||
return { | ||
statusCode: 200, | ||
body: JSON.stringify({"message": "NEW - successfully handled GET from messages lambda"}) | ||
}; | ||
default: | ||
throw new Error(`cannot handle httpMethod: ${event.httpMethod}`); | ||
} | ||
}; |
66 changes: 66 additions & 0 deletions
66
....snapshot/asset.37a6f0964e9c5c4133e01db00bbcaebc6da2a25a21e27aa0f87add1eb65546e7/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
73 changes: 73 additions & 0 deletions
73
....snapshot/asset.37a6f0964e9c5c4133e01db00bbcaebc6da2a25a21e27aa0f87add1eb65546e7/index.ts
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,73 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance | ||
* with the License. A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES | ||
* OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
|
||
import { S3Client, GetObjectCommand, PutObjectCommand } from "@aws-sdk/client-s3"; | ||
import * as crypto from 'crypto'; | ||
|
||
const s3Client = new S3Client({ region: process.env.REGION }); | ||
|
||
export const handler = async (event: any, context: any) => { | ||
let status = 'SUCCESS'; | ||
let responseData = {}; | ||
|
||
// These are the standard Create/Update/Delete custom resource request types defined here: | ||
// https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-requesttypes.html | ||
if (event.RequestType === 'Create' || event.RequestType === 'Update') { | ||
try { | ||
const templateValues = JSON.parse(event.ResourceProperties.TemplateValues).templateValues; | ||
const templateInputBucket = event.ResourceProperties.TemplateInputBucket; | ||
const templateInputKey = event.ResourceProperties.TemplateInputKey; | ||
const templateOutputBucket = event.ResourceProperties.TemplateOutputBucket; | ||
const templateOutputKey = crypto.randomBytes(32).toString('hex'); | ||
|
||
const getObjectResponse = await s3Client.send(new GetObjectCommand({ | ||
Bucket: templateInputBucket, | ||
Key: templateInputKey | ||
})); | ||
|
||
let template = await getObjectResponse.Body?.transformToString(); | ||
|
||
templateValues.forEach((templateValue: any) => { | ||
template = template?.replace( | ||
new RegExp(templateValue.id, 'g'), | ||
templateValue.value | ||
); | ||
}); | ||
|
||
await s3Client.send(new PutObjectCommand({ | ||
Bucket: templateOutputBucket, | ||
Key: templateOutputKey, | ||
Body: template | ||
})); | ||
|
||
responseData = { | ||
TemplateOutputKey: templateOutputKey | ||
}; | ||
} catch (err) { | ||
status = 'FAILED'; | ||
responseData = { | ||
Error: err | ||
}; | ||
} | ||
} | ||
|
||
return { | ||
Status: status, | ||
Reason: JSON.stringify(responseData), | ||
PhysicalResourceId: event.PhysicalResourceId ?? context.logStreamName, | ||
StackId: event.StackId, | ||
RequestId: event.RequestId, | ||
LogicalResourceId: event.LogicalResourceId, | ||
Data: responseData, | ||
}; | ||
}; |
16 changes: 16 additions & 0 deletions
16
...snapshot/asset.654d49d4ea47a6be417d57b94dc0310933d0e971a3e48a3080c3e48487af3e50/index.mjs
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,16 @@ | ||
export const handler = async (event) => { | ||
switch (event.httpMethod) { | ||
case 'POST': | ||
return { | ||
statusCode: 200, | ||
body: JSON.stringify({"message": "successfully handled POST from photos lambda"}) | ||
}; | ||
case 'GET': | ||
return { | ||
statusCode: 200, | ||
body: JSON.stringify({"message": "successfully handled GET from photos lambda"}) | ||
}; | ||
default: | ||
throw new Error(`cannot handle httpMethod: ${event.httpMethod}`); | ||
} | ||
}; |
3 changes: 3 additions & 0 deletions
3
...liases.js.snapshot/asset.7dbcd6245c5c6f70da313d31e9bd533af2214c565d855fb2f669666e927c125e
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 @@ | ||
DO-NOT-DELETE | ||
|
||
This file is used to create an aws_s3_assets.Asset that will be referenced when writing the transformed asset. |
1 change: 1 addition & 0 deletions
1
...ot/asset.bdc104ed9cab1b5b6421713c8155f0b753380595356f710400609664d3635eca/cfn-response.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.