Class: Jets::Cfn::Resource::Lambda::Permission
- Inherits:
-
Base
- Object
- Base
- Jets::Cfn::Resource::Lambda::Permission
show all
- Defined in:
- lib/jets/cfn/resource/lambda/permission.rb
Instance Method Summary
collapse
Methods inherited from Base
#attributes, #logical_id, #outputs, #parameters, #permission, #properties, #replacements, #replacer, #standarize, #template, truncate_id, #type
#camelize
Constructor Details
#initialize(replacements, associated_resource, options = {}) ⇒ Permission
6
7
8
9
10
11
12
|
# File 'lib/jets/cfn/resource/lambda/permission.rb', line 6
def initialize(replacements, associated_resource, options={})
@replacements = replacements
@associated_resource = associated_resource
@principal = options[:Principal]
@source_arn = options[:SourceArn]
end
|
Instance Method Details
#definition ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/jets/cfn/resource/lambda/permission.rb', line 14
def definition
logical_id = permission_logical_id
definition = {
logical_id => {
Type: "AWS::Lambda::Permission",
Properties: {
FunctionName: "!Ref {namespace}LambdaFunction",
Action: "lambda:InvokeFunction",
Principal: principal
}
}
}
definition[logical_id][:Properties][:SourceArn] = source_arn if source_arn
definition
end
|
#permission_logical_id ⇒ Object
35
36
37
38
39
40
|
# File 'lib/jets/cfn/resource/lambda/permission.rb', line 35
def permission_logical_id
logical_id = "{namespace}Permission"
md = @associated_resource.logical_id.match(/(\d+)$/)
counter = md[1] if md
[logical_id, counter].compact.join('')
end
|
#principal ⇒ Object
Auto-detect principal from the associated resources.
43
44
45
|
# File 'lib/jets/cfn/resource/lambda/permission.rb', line 43
def principal
@principal || replacer.principal_map(@associated_resource.type)
end
|
#source_arn ⇒ Object
47
48
49
|
# File 'lib/jets/cfn/resource/lambda/permission.rb', line 47
def source_arn
@source_arn || replacer.source_arn_map(@associated_resource.type)
end
|