-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudformation.yml
57 lines (53 loc) · 2.07 KB
/
cloudformation.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
AWSTemplateFormatVersion: "2010-09-09"
Description: A CloudFormation template example demonstrating how to execute an HTTP request within the inline evaluator function.
# Resources declared by this template.
Resources:
# Definition of the evaluation resource stack.
EvaluationResourceStack:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: ../../cloudformation.yml
# Definition of a Node.js code performing an HTTP request against the Github API
# and returns information about the user `HQarroum` on Github and binds them to
# the outputs of the Cloudformation stack.
GithubRequestFunction:
Type: Custom::GithubRequestFunction
Properties:
ServiceToken: !Sub ${EvaluationResourceStack.Outputs.EvaluationResourceFunctionArn}
Username: HQarroum
Code: |
return (new Promise((resolve, reject) => {
const https = require('https');
let data = '';
const req = https.get({
hostname: 'api.github.com',
path: `/users/${props.Username}`,
headers: {'user-agent':'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)'}
}, (response) => {
response.on('data', (d) => data += d)
.on('end', () => resolve(JSON.parse(data)))
.on('error', reject);
}).on('error', reject).end();
}));
# The outputs to be generated by this template.
Outputs:
Login:
Description: The login of the Github user.
Value: !Sub ${GithubRequestFunction.login}
Export:
Name: !Sub ${AWS::StackName}-Login
Id:
Description: The identifier of the Github user.
Value: !Sub ${GithubRequestFunction.id}
Export:
Name: !Sub ${AWS::StackName}-Id
PublicRepos:
Description: The number of public repositories of the Github user.
Value: !Sub ${GithubRequestFunction.public_repos}
Export:
Name: !Sub ${AWS::StackName}-PublicRepos
Followers:
Description: The number of followers of the Github user.
Value: !Sub ${GithubRequestFunction.followers}
Export:
Name: !Sub ${AWS::StackName}-Followers