Skip to content

Commit bf59445

Browse files
committed
Merge branch 'master' into darcy.rayner/add-integration-tests
2 parents b3de13c + a00dec3 commit bf59445

File tree

6 files changed

+425
-218
lines changed

6 files changed

+425
-218
lines changed

aws/logs_monitoring/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@ Note: you can find the installed Forwarder under the stack's "Resources" tab.
3535
Since version 3.0.0, the forwarder Lambda function is managed by CloudFormation. To upgrade an older forwarder installation to 3.0.0 and above, follow the steps below.
3636

3737
1. Install a new forwarder following the [installation](#installation) steps.
38-
1. Manually migrate a few triggers on the old forwarder to the new one.
39-
1. Ensure the new forwarder is working as expected.
38+
1. Manually migrate a few triggers (CloudWatch log group subscription filter and S3 bucket event notification) on the old forwarder to the new one.
39+
1. Ensure the new forwarder is working as expected, i.e., being invoked regularly without errors.
40+
1. Ensure the logs from the migrated triggers (sources) are showing up in Datadog log explorer and look right to you.
4041
1. Update all the triggers on the old forwarder to the new one, following these [steps](https://docs.datadoghq.com/integrations/amazon_web_services/?tab=allpermissions#send-aws-service-logs-to-datadog).
42+
1. Ensure the old forwarder Lambda function's invocations count drops to zero.
4143
1. Delete the old forwarder Lambda function when you feel comfortable.
44+
1. If you have old forwarder Lambda functions installed in multiple AWS accounts and regions, repeat the steps above in every account and region combination.
4245

4346
### Adjusting forwarder settings
4447

aws/logs_monitoring/lambda_function.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def compileRegex(rule, pattern):
321321
DD_CUSTOM_TAGS = "ddtags"
322322
DD_SERVICE = "service"
323323
DD_HOST = "host"
324-
DD_FORWARDER_VERSION = "3.2.0"
324+
DD_FORWARDER_VERSION = "3.3.0"
325325

326326

327327
class RetriableException(Exception):

aws/logs_monitoring/release.sh

Lines changed: 61 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ else
1212
BUCKET=$1
1313
fi
1414

15-
# Get the latest code
16-
git checkout master
17-
git pull origin master
18-
1915
# Read the current version
2016
CURRENT_VERSION=$(grep -o 'Version: \d\+\.\d\+\.\d\+' template.yaml | cut -d' ' -f2)
2117

@@ -26,60 +22,89 @@ if [ -z "$2" ]; then
2622
elif [[ ! $2 =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
2723
echo "Must use a semantic version, e.g., 3.1.4"
2824
exit 1
29-
elif [[ ! "$2" > "$CURRENT_VERSION" ]]; then
30-
echo "Must use a version greater than the current ($CURRENT_VERSION)"
31-
exit 1
3225
else
3326
VERSION=$2
3427
fi
3528

36-
# Make the template private (default is public) - useful for developers
37-
if [[ $# -eq 3 ]] && [[ $3 = "--private" ]]; then
38-
PRIVATE_TEMPLATE=true
29+
# Do a production release (default is staging) - useful for developers
30+
if [[ $# -eq 3 ]] && [[ $3 = "--prod" ]]; then
31+
PROD_RELEASE=true
3932
else
40-
PRIVATE_TEMPLATE=false
33+
PROD_RELEASE=false
4134
fi
4235

36+
# Validate identity
37+
aws sts get-caller-identity
38+
4339
# Validate the template
4440
echo "Validating template.yaml"
4541
aws cloudformation validate-template --template-body file://template.yaml
4642

47-
# Confirm to proceed
48-
read -p "About to bump the version from ${CURRENT_VERSION} to ${VERSION}, create a release aws-dd-forwarder-${VERSION} on Github and upload the template.yaml to s3://${BUCKET}/aws/forwarder/${VERSION}.yaml. Continue (y/n)?" CONT
49-
if [ "$CONT" != "y" ]; then
50-
echo "Exiting"
51-
exit 1
52-
fi
43+
if [ "$PROD_RELEASE" = true ] ; then
5344

54-
# Bump version number
55-
echo "Bumping the current version number to the desired"
56-
perl -pi -e "s/DD_FORWARDER_VERSION = \"${CURRENT_VERSION}/DD_FORWARDER_VERSION = \"${VERSION}/g" lambda_function.py
57-
perl -pi -e "s/Version: ${CURRENT_VERSION}/Version: ${VERSION}/g" template.yaml
45+
if [[ ! $(./tools/semver.sh "$VERSION" "$CURRENT_VERSION") > 0 ]]; then
46+
echo "Must use a version greater than the current ($CURRENT_VERSION)"
47+
exit 1
48+
fi
49+
# Make sure we are on master
50+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
51+
if [ $BRANCH != "master" ]; then
52+
echo "Not on master, aborting"
53+
exit 1
54+
fi
5855

59-
# Commit version number changes to git
60-
git add lambda_function.py template.yaml README.md
61-
git commit -m "Bump version from ${CURRENT_VERSION} to ${VERSION}"
62-
git push origin master
56+
# Confirm to proceed
57+
read -p "About to bump the version from ${CURRENT_VERSION} to ${VERSION}, create a release aws-dd-forwarder-${VERSION} on Github and upload the template.yaml to s3://${BUCKET}/aws/forwarder/${VERSION}.yaml. Continue (y/n)?" CONT
58+
if [ "$CONT" != "y" ]; then
59+
echo "Exiting"
60+
exit 1
61+
fi
6362

64-
# Create a github release
65-
echo "Release aws-dd-forwarder-${VERSION} to github"
66-
go get github.com/github/hub
67-
rm -f aws-dd-forwarder-*.zip
68-
zip -r aws-dd-forwarder-${VERSION}.zip .
69-
hub release create -a aws-dd-forwarder-${VERSION}.zip -m "aws-dd-forwarder-${VERSION}" aws-dd-forwarder-${VERSION}
63+
# Get the latest code
64+
git pull origin master
65+
66+
# Bump version number
67+
echo "Bumping the current version number to the desired"
68+
perl -pi -e "s/DD_FORWARDER_VERSION = \"${CURRENT_VERSION}/DD_FORWARDER_VERSION = \"${VERSION}/g" lambda_function.py
69+
perl -pi -e "s/Version: ${CURRENT_VERSION}/Version: ${VERSION}/g" template.yaml
70+
71+
# Commit version number changes to git
72+
git add lambda_function.py template.yaml README.md
73+
git commit -m "Bump version from ${CURRENT_VERSION} to ${VERSION}"
74+
git push origin master
75+
76+
# Create a github release
77+
echo "Release aws-dd-forwarder-${VERSION} to github"
78+
go get github.com/github/hub
79+
rm -f aws-dd-forwarder-*.zip
80+
zip -r aws-dd-forwarder-${VERSION}.zip .
81+
hub release create -a aws-dd-forwarder-${VERSION}.zip -m "aws-dd-forwarder-${VERSION}" aws-dd-forwarder-${VERSION}
82+
TEMPLATE_URL="https://${BUCKET}.s3.amazonaws.com/aws/forwarder/latest.yaml"
83+
FORWARDER_SOURCE_URL="https://github.com/DataDog/datadog-serverless-functions/releases/download/aws-dd-forwarder-${VERSION}/aws-dd-forwarder-${VERSION}.zip'"
84+
else
85+
echo "About to release non-public staging version of forwarder, upload aws-dd-forwarder-${VERSION} to s3, and upload the template.yaml to s3://${BUCKET}/aws/forwarder-staging/${VERSION}.yaml"
86+
# Upload to s3 instead of github
87+
rm -f aws-dd-forwarder-*.zip
88+
zip -r aws-dd-forwarder-${VERSION}.zip .
89+
aws s3 cp aws-dd-forwarder-${VERSION}.zip s3://${BUCKET}/aws/forwarder-staging-zip/aws-dd-forwarder-${VERSION}.zip
90+
TEMPLATE_URL="https://${BUCKET}.s3.amazonaws.com/aws/forwarder-staging/latest.yaml"
91+
FORWARDER_SOURCE_URL="s3://${BUCKET}/aws/forwarder-staging-zip/aws-dd-forwarder-${VERSION}.zip"
92+
fi
7093

7194
# Upload the template to the S3 bucket
7295
echo "Uploading template.yaml to s3://${BUCKET}/aws/forwarder/${VERSION}.yaml"
73-
if [ "$PRIVATE_TEMPLATE" = true ] ; then
74-
aws s3 cp template.yaml s3://${BUCKET}/aws/forwarder/${VERSION}.yaml
75-
aws s3 cp template.yaml s3://${BUCKET}/aws/forwarder/latest.yaml
76-
else
96+
97+
if [ "$PROD_RELEASE" = true ] ; then
7798
aws s3 cp template.yaml s3://${BUCKET}/aws/forwarder/${VERSION}.yaml \
7899
--grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers
79100
aws s3 cp template.yaml s3://${BUCKET}/aws/forwarder/latest.yaml \
80101
--grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers
102+
else
103+
aws s3 cp template.yaml s3://${BUCKET}/aws/forwarder-staging/${VERSION}.yaml
104+
aws s3 cp template.yaml s3://${BUCKET}/aws/forwarder-staging/latest.yaml
81105
fi
106+
82107
echo "Done uploading the template, and here is the CloudFormation quick launch URL"
83-
echo "https://console.aws.amazon.com/cloudformation/home#/stacks/new?stackName=datadog-serverless&templateURL=https://${BUCKET}.s3.amazonaws.com/aws/forwarder/latest.yaml"
108+
echo "https://console.aws.amazon.com/cloudformation/home#/stacks/new?stackName=datadog-serverless&templateURL=${TEMPLATE_URL}"
84109

85110
echo "Done!"

0 commit comments

Comments
 (0)