-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yml
58 lines (48 loc) · 1.46 KB
/
template.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
58
AWSTemplateFormatVersion: 2010-09-09
Transform:
- AWS::Serverless-2016-10-31
Parameters:
ProjectId:
Type: String
Description: AWS projectID to be used to associate ressources.
VpcId:
Type: AWS::EC2::VPC::Id
Description: VPC id.
VpcSecurityGroupIds:
Type: List<AWS::EC2::SecurityGroup::Id>
Description: VPC security groups ids.
VpcSubnetIds:
Type: List<AWS::EC2::Subnet::Id>
Description: VPC subnet ids.
Resources:
EcsServiceDiscoverySchedule:
Type: "AWS::Events::Rule"
Properties:
Description: "ScheduledRule"
ScheduleExpression: "rate(2 minutes)"
State: "ENABLED"
Targets:
-
Arn: !GetAtt EcsServiceDiscovery.Arn
Id: !Join ['-', [!Ref 'ProjectId', 'ecs-service-discovery']]
PermissionForEventsToInvokeLambda:
Type: "AWS::Lambda::Permission"
Properties:
FunctionName: !Ref EcsServiceDiscovery
Action: "lambda:InvokeFunction"
Principal: "events.amazonaws.com"
SourceArn: !GetAtt EcsServiceDiscoverySchedule.Arn
EcsServiceDiscovery:
Type: AWS::Serverless::Function
Properties:
Handler: main
Runtime: go1.x
Environment:
Variables:
PROJECT_ID: !Ref 'ProjectId'
VpcConfig:
SecurityGroupIds: !Ref 'VpcSecurityGroupIds'
SubnetIds: !Ref 'VpcSubnetIds'
Role:
Fn::ImportValue:
!Join ['-', [!Ref 'ProjectId', !Ref 'AWS::Region', 'LambdaTrustRole']]