Skip to content

Commit f1a4fd9

Browse files
author
sourabh
committed
updating packaged template name. Adding deploy sh file to deploy SAM app. Adding serverless to template.
1 parent 1349293 commit f1a4fd9

File tree

4 files changed

+85
-51
lines changed

4 files changed

+85
-51
lines changed
Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,56 @@
11
AWSTemplateFormatVersion: '2010-09-09'
22
Transform: AWS::Serverless-2016-10-31
33
Description: >
4-
This function is invoked by AWS CloudWatch events in response to state change in your AWS resources which matches a event target definition. The event payload received is then forwarded to Sumo Logic HTTP source endpoint.
4+
This function is invoked by AWS CloudWatch events in response to state change in your AWS resources which matches a event target definition. The event payload received is then forwarded to Sumo Logic HTTP source endpoint.
55
66
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
77
Globals:
8-
Function:
9-
Timeout: 300
8+
Function:
9+
Timeout: 300
10+
11+
Metadata:
12+
AWS::ServerlessRepo::Application:
13+
Author: Sumo Logic
14+
Description: This function is invoked by AWS CloudWatch events in response to state change in your AWS resources which matches a event target definition. The event payload received is then forwarded to Sumo Logic HTTP source endpoint.
15+
HomePageUrl: https://github.com/SumoLogic/sumologic-aws-lambda
16+
Labels:
17+
- sumologic
18+
- serverless
19+
- guardduty
20+
- security
21+
- cloudwatchevents
22+
- guardduty
23+
Name: sumologic-guardduty-events-processor
24+
LicenseUrl: ../LICENSE
25+
ReadmeUrl: ./README.md
26+
SemanticVersion: 1.0.3
27+
SourceCodeUrl: https://github.com/SumoLogic/sumologic-aws-lambda/tree/master/cloudwatchevents/guardduty
28+
SpdxLicenseId: Apache-2.0
1029

1130
Parameters:
12-
SumoEndpointUrl:
13-
Type: String
31+
SumoEndpointUrl:
32+
Type: String
1433

1534
Resources:
1635

17-
CloudWatchEventFunction:
18-
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
19-
Properties:
20-
CodeUri: ../src/
21-
Handler: cloudwatchevents.handler
22-
Runtime: nodejs12.x
23-
Environment:
24-
Variables:
25-
SUMO_ENDPOINT: !Ref SumoEndpointUrl
26-
Events:
27-
CloudWatchEventTrigger:
28-
Type: CloudWatchEvent
29-
Properties:
30-
Pattern:
31-
source:
32-
- aws.guardduty
36+
CloudWatchEventFunction:
37+
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
38+
Properties:
39+
CodeUri: ../src/
40+
Handler: cloudwatchevents.handler
41+
Runtime: nodejs12.x
42+
Environment:
43+
Variables:
44+
SUMO_ENDPOINT: !Ref SumoEndpointUrl
45+
Events:
46+
CloudWatchEventTrigger:
47+
Type: CloudWatchEvent
48+
Properties:
49+
Pattern:
50+
source:
51+
- aws.guardduty
3352
Outputs:
3453

35-
CloudWatchEventFunction:
36-
Description: "CloudWatchEvent Processor Function ARN"
37-
Value: !GetAtt CloudWatchEventFunction.Arn
54+
CloudWatchEventFunction:
55+
Description: "CloudWatchEvent Processor Function ARN"
56+
Value: !GetAtt CloudWatchEventFunction.Arn

cloudwatchevents/guarddutybenchmark/template_v2.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Metadata:
5656
Name: sumologic-guardduty-benchmark
5757
LicenseUrl: ../LICENSE
5858
ReadmeUrl: ./README.md
59-
SemanticVersion: 1.0.10
59+
SemanticVersion: 1.0.11
6060
SourceCodeUrl: https://github.com/SumoLogic/sumologic-aws-lambda/tree/master/cloudwatchevents/guarddutybenchmark
6161
SpdxLicenseId: Apache-2.0
6262

cloudwatchevents/guarddutybenchmark/testdeploy.sh

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
export AWS_REGION="us-east-1"
4+
export AWS_PROFILE="personal"
5+
6+
if [[ "${AWS_PROFILE}" == "personal" ]]
7+
then
8+
SAM_S3_BUCKET="cf-templates-1qpf3unpuo1hw-us-east-1"
9+
else
10+
SAM_S3_BUCKET="appdevstore"
11+
fi
12+
13+
# define all application names that needs to be published.
14+
app_names=(
15+
"GuardDuty:template.yaml"
16+
"guarddutybenchmark:template_V2.yaml"
17+
)
18+
19+
sam --version
20+
# Regex to deploy only expected templates.
21+
match_case=""
22+
23+
for app_name in "${app_names[@]}"
24+
do
25+
KEY="${app_name%%:*}"
26+
VALUE="${app_name##*:}"
27+
28+
if [[ "${KEY}" == *"${match_case}"* ]]; then
29+
# Grep Version from the SAM Template.
30+
version=$(grep AWS::ServerlessRepo::Application: ../"${KEY}/${VALUE}" -A 20 | grep SemanticVersion | cut -d ':' -f 2 | xargs)
31+
echo "Package and publish the Template file ${VALUE} with version ${version}."
32+
33+
sam validate -t ../"${KEY}/${VALUE}"
34+
35+
sam package --profile ${AWS_PROFILE} --template-file ../"${KEY}/${VALUE}" --s3-bucket ${SAM_S3_BUCKET} --output-template-file ../"${KEY}"/packaged.yaml \
36+
--s3-prefix "${KEY}/v${version}"
37+
38+
sam publish --template ../"${KEY}"/packaged.yaml --region ${AWS_REGION} --semantic-version "${version}"
39+
echo "Publish done"
40+
fi
41+
done

0 commit comments

Comments
 (0)