8000 Adding python3 version of lambda and tests. Also added SNS topic and… · dacdo/aws-lambda-ddns-function@bbfefaf · GitHub
[go: up one dir, main page]

Skip to content

Commit bbfefaf

Browse files
William RubelWilliam Rubel
authored andcommitted
Adding python3 version of lambda and tests. Also added SNS topic and ability to publish to topic for errors.
1 parent e67176b commit bbfefaf

18 files changed

+4714
-1
lines changed

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.idea
2+
.idea/*
3+
.tox
4+
.tox/*
5+
htmlcov
6+
htmlcov/*
7+
.coverage
8+
.coverage*
9+
.coverage/*
10+
.pytest_cache
11+
.pytest_cache/*
12+
__pycache__
13+
__pycache__/*

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ The policy includes **ec2:Describe permission**, required for the function to ob
8383
"Resource": [
8484
"*"
8585
]
86+
},
87+
{
88+
"Effect": "Allow",
89+
"Action": [
90+
"SNS:Publish"
91+
],
92+
"Resource": [
93+
{ "Fn::Join": ["", [ "arn:aws:sns:",{"Ref":"AWS::Region"}, ":",{"Ref":"AWS::AccountId"},":DDNSAlerts"]]}
94+
]
8695
}]
8796
}
8897
```
@@ -240,6 +249,13 @@ In this step, you verify that your Lambda function successfully updated the Rout
240249

241250
10) Verify that the records have been removed from the zone file by the Lambda function.
242251

252+
## Python3 Lambda
253+
254+
The python3 version of the lambda introduces some new features:
255+
256+
* Has SNS notifications for errors. NOTE: The cloudformation template will setup an SNS topic named DDNSAlerts. Manually setup the subscriptions you want to this topic.
257+
* For CNAME tags, an CNAME record is created to to the dns address, and a PTR record it created to point to the CNAME
258+
* Tests have been added to test the lambda, and any changes. Run 'tox' command in bash shell to run tests and view coverage report in htmlcov directory
243259

244260
## Conclusion
245261

ddns.template

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@
99
}
1010
},
1111
"Resources": {
12+
"snsTopic" : {
13+
"Type" : "AWS::SNS::Topic",
14+
"Properties" : {
15+
"Subscription" : [{
16+
"Endpoint" : "willrubel@gmail.com",
17+
"Protocol" : "email"
18+
}
19+
],
20+
"TopicName" : "DDNSAlerts"
21+
}
22+
},
1223
"ddnslambdarole": {
1324
"Type": "AWS::IAM::Role",
1425
"Properties": {
@@ -61,6 +72,17 @@
6172
"Resource": [
6273
"*"
6374
]
75+
},
76+
{
77+
"Effect": "Allow",
78+
"Action": [
79+
"SNS:Publish"
80+
],
81+
"Resource": [
82+
83+
{ "Fn::Join": ["", [ "arn:aws:sns:",{"Ref":"AWS::Region"}, ":",{"Ref":"AWS::AccountId"},":DDNSAlerts"]]}
84+
]
85+
6486
}
6587
]
6688
}
@@ -86,7 +108,7 @@
86108
},
87109
"S3Key": "union.py.zip"
88110
},
89-
"Runtime": "python2.7",
111+
"Runtime": "python3.6",
90112
"Timeout": "90"
91113
}
92114
},

requirements-dev.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
tox==3.7.0
2+
pytest==4.3.0
3+
coverage==4.5.3
4+
mock==2.0.0
5+
boto3==1.9.111
6+
botocore==1.12.111
7+
moto
8+
wheel
9+
setuptools
10+
freezegun
11+
sure

tests/__init__.py

Whitespace-only changes.

tests/python3/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)
0